Recode2Color extends Recode<ColorParameter, ColorLiteral> implements ColorParameter { @Override public Color getColor(ResultSet rs, long fid) throws ParameterException { return getParameter(rs, fid).getColor(rs, fid); } Recode2Color(ColorLiteral fallback, StringParameter lookupValue);  Recode2Color(JAXBElement<RecodeType> expr); @Override Color getColor(ResultSet rs, long fid); @Override Color getColor(Map<String,Object> map);  }
@Test public void testAddMapItems(){ try { recode.addMapItem(key1, c1); assertTrue(recode.getNumMapItem() == 1); assertTrue(recode.getMapItemKey(0).equals("k1")); assertTrue(recode.getMapItemValue(0).getColor(null, -1) == c1.getColor(null, -1)); assertTrue(recode.getMapItemValue("k1").getColor(null, -1) == c1.getColor(null, -1)); recode.addMapItem(key2, c2); assertTrue(recode.getNumMapItem() == 2); assertTrue(recode.getMapItemKey(0).equals("k1")); assertTrue(recode.getMapItemKey(1).equals("k2")); assertTrue(recode.getMapItemValue(1).getColor(null, -1) == c2.getColor(null, -1)); assertTrue(recode.getMapItemValue("k2").getColor(null, -1) == c2.getColor(null, -1)); recode.addMapItem(key3, c3); assertTrue(recode.getNumMapItem() == 3); assertTrue(recode.getMapItemKey(0).equals("k1")); assertTrue(recode.getMapItemKey(1).equals("k2")); assertTrue(recode.getMapItemKey(2).equals("k3")); assertTrue(recode.getMapItemValue(2).getColor(null, -1) == c3.getColor(null, -1)); assertTrue(recode.getMapItemValue("k3").getColor(null, -1) == c3.getColor(null, -1)); } catch (ParameterException ex) { Logger.getLogger(Recode2ColorTest.class.getName()).log(Level.SEVERE, null, ex); } }
@Test public void testGetParameter(){ try { testAddMapItems(); recode.setLookupValue(new StringLiteral("k1")); assertTrue(recode.getColor(null, -1) == c1.getColor(null, -1)); recode.setLookupValue(new StringLiteral("k2")); assertTrue(recode.getColor(null, -1) == c2.getColor(null, -1)); recode.setLookupValue(new StringLiteral("k3")); assertTrue(recode.getColor(null, -1) == c3.getColor(null, -1)); } catch (ParameterException ex) { Logger.getLogger(Recode2ColorTest.class.getName()).log(Level.SEVERE, null, ex); assertTrue(false); } }
@Test public void testMarshalUnmarshal() throws Exception { String xml = Recode2ColorTest.class.getResource("../../colorRecode.se").getFile(); Unmarshaller u = org.orbisgis.coremap.map.JaxbContainer.JAXBCONTEXT.createUnmarshaller(); JAXBElement<StyleType> ftsElem = (JAXBElement<StyleType>) u.unmarshal( new FileInputStream(xml)); Marshaller m = org.orbisgis.coremap.map.JaxbContainer.JAXBCONTEXT.createMarshaller(); m.marshal(ftsElem, new FileOutputStream("c2routput.se")); Style st = new Style(ftsElem, null); JAXBElement<StyleType> elem = st.getJAXBElement(); m.marshal(elem, new FileOutputStream("c2routput.se")); StyleType stype = elem.getValue(); RuleType rt = stype.getRule().get(0); LineSymbolizerType lst = ((LineSymbolizerType)(rt.getSymbolizer().getValue())); SolidFillType sf = ((SolidFillType)((PenStrokeType)lst.getStroke().getValue()).getFill().getValue()); JAXBElement je = (JAXBElement) (sf.getColor().getContent().get(0)); RecodeType rect = ((RecodeType)(je.getValue())); assertTrue(rect.getMapItem().size() == 4); }