ColorNameLookup { public String getColorNameFromStr(String colorStr) { String str = colorStr.trim(); for (ColorName c : colorList) { if (c.getName().equalsIgnoreCase(str)) { return c.getName(); } } return ""; } ColorNameLookup(); String getColorNameFromStr(String colorStr); Color getColorFromName(String colorStr);  }
@Test public void testGetColorNameFromStrWhite() { String colorStr = "white"; System.out.println("GetColorNameFromStr ["+ colorStr +"]"); ColorNameLookup c = new ColorNameLookup(); String result = c.getColorNameFromStr(colorStr); assertEquals("White", result); }
@Test public void testGetColorNameFromStrBadColorName() { String colorStr = "BadColorName"; System.out.println("GetColorNameFromStr ["+ colorStr +"]"); ColorNameLookup c = new ColorNameLookup(); String result = c.getColorNameFromStr(colorStr); assertEquals("", result); }
@Test public void testGetColorNameFromStrBadCaseWidthSpaces() { String colorStr = " darkmagenta "; System.out.println("GetColorNameFromStr ["+ colorStr +"]"); ColorNameLookup c = new ColorNameLookup(); String result = c.getColorNameFromStr(colorStr); assertEquals("DarkMagenta", result); }