Search in sources :

Example 1 with StringList

use of org.geotoolkit.processing.chain.model.StringList in project geotoolkit by Geomatys.

the class ChainProcessTest method testXmlRW.

@Test
public void testXmlRW() throws ProcessException, JAXBException, IOException {
    // test various problematic case
    final Chain chain = new Chain("myChain");
    // sting/string in user map
    Parameter param = new Parameter("in1", String.class, "enumerated string", "none", 0, 12, "def", new String[] { "def", "undef" });
    Map<String, Object> userMap = new HashMap<>();
    userMap.put("test", "test");
    param.setUserMap(userMap);
    chain.getInputs().add(param);
    Parameter param2 = new Parameter("in2", Character.class, "char", "none", 0, 12, 'c');
    chain.getInputs().add(param2);
    File f = File.createTempFile("chain", ".xml");
    chain.write(f);
    final Chain chainr = Chain.read(f);
    Parameter p = chainr.getInput("in2");
    // assertEquals('c', p.getDefaultValue()); problem here char are rw to integer...
    // sting/double in user map
    userMap = new HashMap<>();
    userMap.put("test-double", 125d);
    param.setUserMap(userMap);
    f = File.createTempFile("chain", ".xml");
    chain.write(f);
    // sting/map in user map
    userMap = new HashMap<>();
    HashMap<String, String> typeMap = new HashMap<>();
    typeMap.put("String", "String");
    userMap.put("test-map", new StringMap(typeMap));
    param.setUserMap(userMap);
    f = File.createTempFile("chain", ".xml");
    chain.write(f);
    // sting/map/list in user map
    userMap = new HashMap<>();
    HashMap<String, StringList> typeMapList = new HashMap<>();
    ArrayList a = new ArrayList<>();
    a.add("String");
    a.add("String2");
    typeMapList.put("String", new StringList(a));
    userMap.put("test-map", new StringMapList(typeMapList));
    param.setUserMap(userMap);
    f = File.createTempFile("chain", ".xml");
    chain.write(f);
}
Also used : Chain(org.geotoolkit.processing.chain.model.Chain) StringMap(org.geotoolkit.processing.chain.model.StringMap) HashMap(java.util.HashMap) StringList(org.geotoolkit.processing.chain.model.StringList) ArrayList(java.util.ArrayList) StringMapList(org.geotoolkit.processing.chain.model.StringMapList) Parameter(org.geotoolkit.processing.chain.model.Parameter) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Chain (org.geotoolkit.processing.chain.model.Chain)1 Parameter (org.geotoolkit.processing.chain.model.Parameter)1 StringList (org.geotoolkit.processing.chain.model.StringList)1 StringMap (org.geotoolkit.processing.chain.model.StringMap)1 StringMapList (org.geotoolkit.processing.chain.model.StringMapList)1 Test (org.junit.Test)1