IndexedColorMapper extends AbstractColorMapper<Integer> { public abstract Paint get(int value);  abstract Paint get(int value); Paint get(Number index);  }
@Test public void testGetNumber() { MockIndexedColorMapper c = new MockIndexedColorMapper(); assertEquals(c.get(128), c.get(128.0)); }
@Test public void testGetOmit() { MockIndexedColorMapper c = new MockIndexedColorMapper(); c.setMode(Mode.OMIT); assertNull(c.get(-128)); assertEquals(new Color(0, 0, 0), c.get(0)); assertEquals(new Color(128, 128, 128), c.get(128)); assertEquals(new Color(255, 255, 255), c.get(255)); assertNull(c.get(384)); }
@Test public void testGetRepeat() { MockIndexedColorMapper c = new MockIndexedColorMapper(); c.setMode(Mode.REPEAT); assertEquals(new Color(0, 0, 0), c.get(-128)); assertEquals(new Color(0, 0, 0), c.get(0)); assertEquals(new Color(128, 128, 128), c.get(128)); assertEquals(new Color(255, 255, 255), c.get(255)); assertEquals(new Color(255, 255, 255), c.get(384)); }
@Test public void testGetCircular() { MockIndexedColorMapper c = new MockIndexedColorMapper(); c.setMode(Mode.CIRCULAR); assertEquals(new Color(128, 128, 128), c.get(-128)); assertEquals(new Color(0, 0, 0), c.get(0)); assertEquals(new Color(128, 128, 128), c.get(128)); assertEquals(new Color(255, 255, 255), c.get(255)); assertEquals(new Color(128, 128, 128), c.get(384)); }
@Test public void testSerialization() throws IOException, ClassNotFoundException { MockIndexedColorMapper original = new MockIndexedColorMapper(); MockIndexedColorMapper deserialized = TestUtils.serializeAndDeserialize(original); assertEquals(original.getMode(), deserialized.getMode()); for (int i = -128; i <= 384; i += 128) { assertEquals(original.get(i), deserialized.get(i)); } }