### Question:
ColorUtilities { public static int getBrightness(Color color) { Utilities.checkNull(color, "color"); final float redFactor = 0.241f; final float greenFactor = 0.691f; final float blueFactor = 0.068f; return (int)Math.round(Math.sqrt(redFactor * color.getRed() * color.getRed() + greenFactor * color.getGreen() * color.getGreen() + blueFactor * color.getBlue() * color.getBlue())); } 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 testGetBrightness() { Assert.assertEquals(0, ColorUtilities.getBrightness(Color.BLACK)); Assert.assertEquals(122, ColorUtilities.getBrightness(new Color(223, 53, 111))); Assert.assertEquals(255, ColorUtilities.getBrightness(Color.WHITE)); for (int index = 0; index < 256; ++index) { Assert.assertEquals(index, ColorUtilities.getBrightness(new Color(index, index, index))); } }
@Test(expected = IllegalArgumentException.class) public void testGetBrightnessNullArg() { ColorUtilities.getBrightness(null); }