### Question:
ColorUtilities { public static Color convertFromHexString(String color, int redIndex, int greenIndex, int blueIndex) throws NumberFormatException { if (color == null || color.length() == 0 || color.length() > 6) { throw new NumberFormatException("For input string: \"" + color + "\""); } long inputVal = Long.parseLong(color, 16); int outputVal = 0; outputVal |= 0xff0000 & MathUtil.byteShift(inputVal, redIndex - 1); outputVal |= 0xff00 & MathUtil.byteShift(inputVal, greenIndex - 2); outputVal |= 0xff & MathUtil.byteShift(inputVal, blueIndex - 3); outputVal |= 0xff000000; return new Color(outputVal, true); } private  ColorUtilities(); static Color blendColors(Color color1, Color color2); static Color brighten(Color input, double factor); static Color convertFromColorString(String color); static Color convertFromHexString(String color, int redIndex, int greenIndex, int blueIndex); static Color convertFromHexString(String color, int redIndex, int greenIndex, int blueIndex, int alphaIndex); static String convertToHexString(Color color, int redIndex, int greenIndex, int blueIndex); static String convertToHexString(Color color, int redIndex, int greenIndex, int blueIndex, int alphaIndex); static String convertToRGBAColorString(Color aColor); static Color darken(Color input, double factor); static Color lighten(Color color); static int getBrightness(Color color); static Color getContrastingColor(Color color); static Color getAlternateColor(Color color, int shift); static boolean isEqual(Color c1, Color c2); static boolean isEqualIgnoreAlpha(Color c1, Color c2); static Color opacitizeColor(Color startingColor, float alpha); static Color opacitizeColor(Color startingColor, int alpha); static final int COLOR_COMPONENT_MAX_VALUE; }### Answer:
@Test public void testConvertFromHexString() { Assert.assertEquals(new Color(0x12, 0x12, 0x12, 0x12), ColorUtilities.convertFromHexString("12345678", 0, 0, 0, 0)); Assert.assertEquals(new Color(0x12, 0x34, 0x56, 0x78), ColorUtilities.convertFromHexString("12345678", 0, 1, 2, 3)); Assert.assertEquals(new Color(0x78, 0x56, 0x34, 0x12), ColorUtilities.convertFromHexString("12345678", 3, 2, 1, 0)); Assert.assertEquals(new Color(0xff, 0xff, 0xff, 0xff), ColorUtilities.convertFromHexString("ffffffff", 3, 2, 1, 0)); }
@Test(expected = NumberFormatException.class) public void testConvertFromHexStringBadInput1() { ColorUtilities.convertFromHexString("", 0, 0, 0, 0); }
@Test(expected = NumberFormatException.class) public void testConvertFromHexStringBadInput2() { ColorUtilities.convertFromHexString(" 12345678", 0, 0, 0, 0); }
@Test(expected = NumberFormatException.class) public void testConvertFromHexStringBadInput3() { ColorUtilities.convertFromHexString("ffffffff0", 3, 2, 1, 0); }
@Test(expected = NumberFormatException.class) public void testConvertFromHexStringNullInput() { ColorUtilities.convertFromHexString(null, 0, 0, 0, 0); }