use of org.geotools.styling.ColorMapEntry in project sldeditor by robward-scisys.
the class MultipleColourMapEntryTest method testParseList.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.colourmap.MultipleColourMapEntry#parseList(java.util.List)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.colourmap.MultipleColourMapEntry#getColourMapEntry()}.
*/
@Test
public void testParseList() {
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
MultipleColourMapEntry testObj = new MultipleColourMapEntry();
assertNotNull(testObj.getColourMapEntry());
ColorMapEntry c1 = new ColorMapEntryImpl();
String expectedLabel = "abc";
String expectedColour = "#123456";
double expectedOpacity = 0.5;
int expectedQuantity = 42;
c1.setLabel(expectedLabel);
c1.setColor(ff.literal(expectedColour));
c1.setOpacity(ff.literal(expectedOpacity));
c1.setQuantity(ff.literal(expectedQuantity));
List<ColorMapEntry> expectedList = new ArrayList<ColorMapEntry>();
expectedList.add(c1);
ColorMapEntry c2 = new ColorMapEntryImpl();
c2.setLabel(expectedLabel);
c2.setColor(ff.literal(expectedColour));
c2.setOpacity(ff.literal(expectedOpacity));
c2.setQuantity(ff.literal(expectedQuantity));
expectedList.add(c2);
ColorMapEntry c3 = new ColorMapEntryImpl();
c3.setLabel(expectedLabel);
c3.setColor(ff.literal(expectedColour));
c3.setOpacity(ff.literal(expectedOpacity));
c3.setQuantity(ff.literal(expectedQuantity));
expectedList.add(c3);
testObj.parseList(expectedList);
ColorMapEntry actual = testObj.getColourMapEntry();
// All the same
assertNotNull(testObj.getColourMapEntry());
assertEquals(actual.getLabel(), expectedLabel);
assertEquals(actual.getColor().toString(), expectedColour);
assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
// Change label
c2.setLabel("different");
testObj.parseList(expectedList);
actual = testObj.getColourMapEntry();
assertNotNull(testObj.getColourMapEntry());
assertNull(actual.getLabel());
assertEquals(actual.getColor().toString(), expectedColour);
assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
// Change colour
c1.setColor(ff.literal("#987654"));
testObj.parseList(expectedList);
actual = testObj.getColourMapEntry();
assertNotNull(testObj.getColourMapEntry());
assertNull(actual.getLabel());
assertNull(actual.getColor());
assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
// Change opacity
c3.setOpacity(ff.literal(1.0));
testObj.parseList(expectedList);
actual = testObj.getColourMapEntry();
assertNotNull(testObj.getColourMapEntry());
assertNull(actual.getLabel());
assertNull(actual.getColor());
assertNull(actual.getOpacity());
assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
// Change quantity
c2.setQuantity(ff.literal(39.0));
testObj.parseList(expectedList);
actual = testObj.getColourMapEntry();
assertNotNull(testObj.getColourMapEntry());
assertNull(actual.getLabel());
assertNull(actual.getColor());
assertNull(actual.getOpacity());
assertNull(actual.getQuantity());
}
Aggregations