WpsXmlRequestConverter { public String toXml() { return getXmlHeader() + getIdentifier(productionRequest.getProductionType()) + getDataInputs(productionRequest.getParameters()) + "</wps:Execute>"; } WpsXmlRequestConverter(ProductionRequest productionRequest); String toXml();  }
@Test public void toXml() throws Exception { Map<String, String> productionParameters = new HashMap<>(); productionParameters.put("calvalus.processor.package", "beam-meris-radiometry"); productionParameters.put("calvalus.processor.version", "1.0-SNAPSHOT"); productionParameters.put("calvalus.input.format", "BEAM-DIMAP"); productionParameters.put("calvalus.output.dir", "hdfs: productionParameters.put("calvalus.input", "hdfs: productionParameters.put("calvalus.l2.operator", "Meris.CorrectRadiometry"); productionParameters.put("calvalus.l2.parameters", "<parameters>\n" + " <doSmile>true</doSmile>\n" + " <reproVersion>AUTO_DETECT</reproVersion>\n" + "</parameters>"); productionParameters.put("calvalus.plainText.parameter", "<parameters>\n" + "This is a multiline\n" + "Textfield\n" + "</parameters>"); ProductionRequest productionRequest = new ProductionRequest("L2Plus", "userName", productionParameters); String requestXml = new WpsXmlRequestConverter(productionRequest).toXml(); assertThat(requestXml, equalTo("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" + "\n" + "<wps:Execute service=\"WPS\"\n" + " version=\"1.0.0\"\n" + " xmlns:wps=\"http: " xmlns:ows=\"http: " xmlns:xlink=\"http: " xmlns:xsi=\"http: " xsi:schemaLocation=\"http: " <ows:Identifier>L2Plus</ows:Identifier>\n" + " <wps:DataInputs>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.processor.package</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>beam-meris-radiometry</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.output.dir</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>hdfs: " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.processor.version</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>1.0-SNAPSHOT</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.input</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>hdfs: " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.input.format</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>BEAM-DIMAP</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.l2.operator</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>Meris.CorrectRadiometry</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.l2.parameters</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>&lt;parameters&gt;\n" + " &lt;doSmile&gt;true&lt;/doSmile&gt;\n" + " &lt;reproVersion&gt;AUTO_DETECT&lt;/reproVersion&gt;\n" + "&lt;/parameters&gt;</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.plainText.parameter</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>&lt;parameters&gt;\n" + "This is a multiline\n" + "Textfield\n" + "&lt;/parameters&gt;</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " </wps:DataInputs>\n" + "</wps:Execute>")); WpsProductionRequestConverter wpsProductionRequestConverter = new WpsProductionRequestConverter(requestXml); ProductionRequest requestRestored = wpsProductionRequestConverter.loadProductionRequest("userName"); Set<String> keySet = productionParameters.keySet(); for (String key : keySet) { String orig = productionParameters.get(key); String now = requestRestored.getString(key); assertEquals("key="+key, orig, now); } }
@Test public void toXmlMultipleInputPath() throws Exception { Map<String, String> productionParameters = new HashMap<>(); productionParameters.put("calvalus.processor.package", "beam-meris-radiometry"); productionParameters.put("calvalus.processor.version", "1.0-SNAPSHOT"); productionParameters.put("calvalus.input.format", "BEAM-DIMAP"); productionParameters.put("calvalus.output.dir", "hdfs: productionParameters.put("calvalus.input", "hdfs: "hdfs: productionParameters.put("calvalus.l2.operator", "Meris.CorrectRadiometry"); productionParameters.put("calvalus.l2.parameters", "<parameters>\n" + " <doSmile>true</doSmile>\n" + " <reproVersion>AUTO_DETECT</reproVersion>\n" + "</parameters>"); productionParameters.put("calvalus.plainText.parameter", "<parameters>\n" + "This is a multiline\n" + "Textfield\n" + "</parameters>"); ProductionRequest productionRequest = new ProductionRequest("L2Plus", "userName", productionParameters); String requestXml = new WpsXmlRequestConverter(productionRequest).toXml(); assertThat(requestXml, equalTo("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" + "\n" + "<wps:Execute service=\"WPS\"\n" + " version=\"1.0.0\"\n" + " xmlns:wps=\"http: " xmlns:ows=\"http: " xmlns:xlink=\"http: " xmlns:xsi=\"http: " xsi:schemaLocation=\"http: " <wps:DataInputs>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.processor.package</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>beam-meris-radiometry</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.output.dir</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>hdfs: " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.processor.version</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>1.0-SNAPSHOT</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.input</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>hdfs: " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.input.format</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>BEAM-DIMAP</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.l2.operator</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>Meris.CorrectRadiometry</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.l2.parameters</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>&lt;parameters&gt;\n" + " &lt;doSmile&gt;true&lt;/doSmile&gt;\n" + " &lt;reproVersion&gt;AUTO_DETECT&lt;/reproVersion&gt;\n&lt;/parameters&gt;</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " <wps:Input>\n" + " <ows:Identifier>calvalus.plainText.parameter</ows:Identifier>\n" + " <ows:Title/>\n" + " <wps:Data>\n" + " <wps:LiteralData>&lt;parameters&gt;\n" + "This is a multiline\n" + "Textfield\n" + "&lt;/parameters&gt;</wps:LiteralData>\n" + " </wps:Data>\n" + " </wps:Input>\n" + " </wps:DataInputs>\n" + "</wps:Execute>")); }
@Test public void toXmlWhenNoDataInputs() throws Exception { Map<String, String> productionParameters = new HashMap<>(); ProductionRequest productionRequest = new ProductionRequest("L2Plus", "userName", productionParameters); String requestXml = new WpsXmlRequestConverter(productionRequest).toXml(); assertThat(requestXml, equalTo("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" + "\n" + "<wps:Execute service=\"WPS\"\n" + " version=\"1.0.0\"\n" + " xmlns:wps=\"http: " xmlns:ows=\"http: " xmlns:xlink=\"http: " xmlns:xsi=\"http: " xsi:schemaLocation=\"http: " <wps:DataInputs/>\n" + "</wps:Execute>")); }