L3ParameterXmlGenerator { public String createXml() { sb.append("<parameters>\n"); constructSingleElement("planetaryGrid", l3Parameters.getPlanetaryGrid()); constructSingleElement("numRows", l3Parameters.getNumRows() == 0 ? "" : "" + (l3Parameters.getNumRows())); constructSingleElement("compositingType", String.valueOf(l3Parameters.getCompositingType())); constructSingleElement("superSampling", String.valueOf(l3Parameters.getSuperSampling())); constructSingleElement("maskExpr", l3Parameters.getMaskExpr()); constructSingleElement("minDataHour", String.valueOf(l3Parameters.getMinDataHour())); constructSingleElement("metadataAggregatorName", l3Parameters.getMetadataAggregatorName()); constructSingleElement("startDateTime", l3Parameters.getStartDateTime()); constructSingleElement("periodDuration", String.valueOf(l3Parameters.getPeriodDuration())); constructSingleElement("timeFilterMethod", String.valueOf(l3Parameters.getTimeFilterMethod())); constructSingleElement("outputFile", l3Parameters.getOutputFile()); constructVariablesElement(); constructAggregatorsElement(); constructPostProcessorElement(); sb.append("</parameters>"); return sb.toString(); } L3ParameterXmlGenerator(L3Parameters l3Parameters); String createXml();  }
@Test public void canCreateXmlWithAllElements() throws Exception { constructL3ParametersMocking(); l3ParameterXmlGenerator = new L3ParameterXmlGenerator(mockL3Parameters); assertThat(l3ParameterXmlGenerator.createXml(), equalTo("<parameters>\n" + "<planetaryGrid>mockPlanetaryGrid</planetaryGrid>\n" + "<numRows>1</numRows>\n" + "<compositingType>BINNING</compositingType>\n" + "<superSampling>1</superSampling>\n" + "<maskExpr>mockMaskExpr</maskExpr>\n" + "<minDataHour>1.0</minDataHour>\n" + "<metadataAggregatorName>mockAggregatorName</metadataAggregatorName>\n" + "<startDateTime>mockDateTime</startDateTime>\n" + "<periodDuration>1.0</periodDuration>\n" + "<timeFilterMethod>SPATIOTEMPORAL_DATA_DAY</timeFilterMethod>\n" + "<outputFile>mockOutputFile</outputFile>\n" + "<variables>\n" + "<variable>\n" + "<name>mockVar</name>\n" + "<expr>mockExpr</expr>\n" + "</variable>\n</variables>\n" + "<aggregators>\n" + "<aggregator>\n" + "<type>AVG</type>\n" + "<varName>tsm</varName>\n" + "</aggregator>\n" + "</aggregators>\n" + "<postProcessor>\n" + "<type>mockProcessorType</type>\n" + "<varName>mockVarName</varName>\n" + "</postProcessor>\n" + "</parameters>")); }
@Test public void canCreateXmlWithVariables() throws Exception { Variables mockVariables = getVariables(); L3Parameters l3Parameters = new L3Parameters(); l3Parameters.setVariables(mockVariables); l3ParameterXmlGenerator = new L3ParameterXmlGenerator(l3Parameters); assertThat(l3ParameterXmlGenerator.createXml(), equalTo("<parameters>\n" + "<variables>\n" + "<variable>\n" + "<name>mockVar</name>\n" + "<expr>mockExpr</expr>\n" + "</variable>\n" + "</variables>\n" + "</parameters>")); }
@Test public void canCreateXmlWithAggregators() throws Exception { Aggregators mockAggregators = getAggregators(); L3Parameters l3Parameters = new L3Parameters(); l3Parameters.setAggregators(mockAggregators); l3ParameterXmlGenerator = new L3ParameterXmlGenerator(l3Parameters); assertThat(l3ParameterXmlGenerator.createXml(), equalTo("<parameters>\n" + "<aggregators>\n" + "<aggregator>\n" + "<type>AVG</type>\n" + "<varName>tsm</varName>\n" + "</aggregator>\n" + "</aggregators>\n" + "</parameters>")); }
@Test public void canCreateXmlWithProcessors() throws Exception { CellProcessorConfig mockProcessorConfig = getMockCellProcessorConfig(); L3Parameters l3Parameters = new L3Parameters(); l3Parameters.setPostProcessorConfig(mockProcessorConfig); l3ParameterXmlGenerator = new L3ParameterXmlGenerator(l3Parameters); assertThat(l3ParameterXmlGenerator.createXml(), equalTo("<parameters>\n" + "<postProcessor>\n" + "<type>mockProcessorType</type>\n" + "<varName>mockVarName</varName>\n" + "</postProcessor>\n" + "</parameters>")); }
@Test public void testCreateEmptyXml() throws Exception { L3Parameters l3Parameters = new L3Parameters(); l3ParameterXmlGenerator = new L3ParameterXmlGenerator(l3Parameters); assertThat(l3ParameterXmlGenerator.createXml(), equalTo("<parameters>\n" + "</parameters>")); }