### Question:
ColorFormatter { public String format(Object value) { String formatted = null; if (value instanceof Color) { Color color = (Color)value; if (myExportModel.getSelectedColorFormat() == ColorFormat.HEXADECIMAL) { formatted = Integer.toHexString(color.getRGB()); } else { StringBuilder sb = new StringBuilder("color[r=").append(color.getRed()).append(",g=").append(color.getGreen()) .append(",b=").append(color.getBlue()).append(",a=").append(color.getAlpha()).append(']'); formatted = sb.toString(); } } return formatted; } ColorFormatter(ExportOptionsModel exportModel); String format(Object value);  }### Answer:
@Test public void testFormat() { ExportOptionsModel model = new ExportOptionsModel(); ColorFormatter formatter = new ColorFormatter(model); String format = formatter.format(Color.RED); assertEquals(Integer.toHexString(Color.RED.getRGB()), format); }
@Test public void testFormatNull() { ExportOptionsModel model = new ExportOptionsModel(); ColorFormatter formatter = new ColorFormatter(model); String format = formatter.format(null); assertNull(format); }
@Test public void testFormatRgb() { ExportOptionsModel model = new ExportOptionsModel(); model.setSelectedColorFormat(ColorFormat.RGB_CODED); ColorFormatter formatter = new ColorFormatter(model); String format = formatter.format(Color.RED); assertEquals("color[r=255,g=0,b=0,a=255]", format); }