UiSchema { @Nullable public Color getColor(Class<?> type) { checkInitialized(); final Color color = colorRegistry.get(type.getName()); if (color == null && type.getSuperclass() != null) { final Color tmp = getColor(type.getSuperclass()); if (tmp != null) { colorRegistry.put(type.getName(), tmp); return tmp; } } if (color == null && useDefault) { return colorRegistry.get(DEFAULT); } return color; } UiSchema(boolean pUseDefault);  UiSchema(); void add(Class<?> type, RGB rgb); void add(Class<?> type, int defaultColor); void add(String key, RGB rgb); void add(Class<?> type, String fileName); @Nullable Image getImage(Class<?> type); @Nullable Color getColor(Class<?> type); Color getDefaultColor(); Color getColor(String key); void initialize(Device d); static final String DEFAULT; }
@Test(expected = IllegalStateException.class) public void getColorFail() { schema2.getColor(A.class); }
@Test public void getColor() { assertEquals(rgbA, schema1.getColor(A.class).getRGB()); assertNull(schema1.colorRegistry.get(AA.class.getName())); assertEquals(rgbA, schema1.getColor(AA.class).getRGB()); assertEquals(rgbA, schema1.colorRegistry.get(AA.class.getName()).getRGB()); assertEquals(rgbB, schema1.getColor(B.class).getRGB()); assertNull(schema1.colorRegistry.get(BB.class.getName())); assertNull(schema1.colorRegistry.get(BBB.class.getName())); assertEquals(rgbB, schema1.getColor(BBB.class).getRGB()); assertEquals(rgbB, schema1.colorRegistry.get(BBB.class.getName()).getRGB()); assertEquals(rgbB, schema1.colorRegistry.get(BB.class.getName()).getRGB()); }