### Question:
TexHexTriplet { public static TexHexTriplet parse(String s) throws NumberFormatException { String hex = s.startsWith("#") ? s.substring(1) : s; if(hex.length() == 6) { return parse(Integer.parseInt(hex, 16)); } else { throw new NumberFormatException(hex + " is not a valid hex triplet"); } } TexHexTriplet(int roughgrass, int mud, int dirt); int getRoughgrass(); int getMud(); int getDirt(); String getHexString(); int getTexture(); ColorDef getColorDef(); static TexHexTriplet of(double roughgrass, double mud, double dirt); static TexHexTriplet of(int roughgrass, int mud, int dirt); static TexHexTriplet of(ColorDef c); static TexHexTriplet parse(String s); static TexHexTriplet parse(int hex); static String convertToHexString(int roughgrass, int mud, int dirt); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); final int roughgrass; final int mud; final int dirt; }### Answer:
@Test public void testParseInt() { TexHexTriplet actual = TexHexTriplet.parse(0x42ff11); assertEquals(texExpected, actual); }
@Test public void testParseString() { TexHexTriplet actual = TexHexTriplet.parse(strExpected); assertEquals(texExpected, actual); }
@Test public void testParseString2() { TexHexTriplet actual = TexHexTriplet.parse("#" + strExpected); assertEquals(texExpected, actual); }
@Test public void testParseString3() { try { TexHexTriplet.parse("2f11"); fail("Should have thrown exception"); } catch(NumberFormatException e) { } }