CalvalusDataInputs { public String getValue(String parameterName) { return inputMapFormatted.get(parameterName); } CalvalusDataInputs(ExecuteRequestExtractor executeRequestExtractor,
                       WpsProcess calvalusProcessor,
                       ProductSet[] productSets,
                       CalvalusFacade calvalusFacade); String getValue(String parameterName); @Override String toString(); static final long MIN_DATE; static final long MAX_DATE; static SimpleDateFormat ISO_DATE_FORMAT; }
@Test public void canGetProductionParameters() throws Exception { Map<String, String> mockInputMapRaw = getProductionParametersRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); when(mockCalvalusProcessor.getDefaultSnapBundle()).thenReturn("snap-3.0.0"); when(mockCalvalusProcessor.getDefaultCalvalusBundle()).thenReturn("calvalus-2.0b411"); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("productionType"), equalTo("L2Plus")); assertThat(calvalusDataInputs.getValue("calvalus.calvalus.bundle"), equalTo("calvalus-2.0b411")); assertThat(calvalusDataInputs.getValue("calvalus.snap.bundle"), equalTo("snap-3.0.0")); assertThat(calvalusDataInputs.getValue("productionName"), equalTo("dummyProductionName")); }
@Test public void canGetProcessorInfoParameters() throws Exception { Map<String, String> mockInputMapRaw = getMinimalRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); when(mockCalvalusProcessor.getBundleName()).thenReturn("beam-idepix"); when(mockCalvalusProcessor.getBundleVersion()).thenReturn("2.0.9"); when(mockCalvalusProcessor.getName()).thenReturn("Idepix.Water"); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("processorBundleName"), equalTo("beam-idepix")); assertThat(calvalusDataInputs.getValue("processorBundleVersion"), equalTo("2.0.9")); assertThat(calvalusDataInputs.getValue("processorName"), equalTo("Idepix.Water")); }
@Test public void canHandleNoProcessorInfoParameters() throws Exception { Map<String, String> mockInputMapRaw = getMinimalRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("processorBundleName"), equalTo(null)); assertThat(calvalusDataInputs.getValue("processorBundleVersion"), equalTo(null)); assertThat(calvalusDataInputs.getValue("processorName"), equalTo(null)); }
@Test public void canGetProductSetParameters() throws Exception { Map<String, String> mockInputMapRaw = getProductSetParametersRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("inputPath"), equalTo("/calvalus/eodata/MER_RR__1P/r03/${yyyy}/${MM}/${dd}/.*.N1")); assertThat(calvalusDataInputs.getValue("minDate"), equalTo("2009-06-01")); assertThat(calvalusDataInputs.getValue("maxDate"), equalTo("2009-06-30")); assertThat(calvalusDataInputs.getValue("periodLength"), equalTo("30")); assertThat(calvalusDataInputs.getValue("regionWKT"), equalTo("polygon((10.00 54.00, 14.27 53.47))")); assertThat(calvalusDataInputs.getValue("outputFormat"), equalTo("NetCDF4")); }
@Test public void canGetMultiPatternProductSetParameters() throws Exception { Map<String, String> mockInputMapRaw = getProductSetParametersRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); ProductSet[] productSetsMultiPattern = getMockProductSetsWithMultiPatterns(); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSetsMultiPattern, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("inputPath"), equalTo("/calvalus/eodata/MER_RR__1P/r03/${yyyy}/${MM}/${dd}/.*.N1," + "/calvalus/eodata/MER_RRG__1P/r03/${yyyy}/${MM}/${dd}/.*.N1," + "/calvalus/eodata/MER_FRS__1P/r03/${yyyy}/${MM}/${dd}/.*.N1")); assertThat(calvalusDataInputs.getValue("minDate"), equalTo("2009-06-01")); assertThat(calvalusDataInputs.getValue("maxDate"), equalTo("2009-06-30")); assertThat(calvalusDataInputs.getValue("periodLength"), equalTo("30")); assertThat(calvalusDataInputs.getValue("regionWKT"), equalTo("polygon((10.00 54.00, 14.27 53.47))")); assertThat(calvalusDataInputs.getValue("outputFormat"), equalTo("NetCDF4")); }
@Test public void canTransformProcessorParameters() throws Exception { Map<String, String> mockInputMapRaw = getProcessorParametersRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); ParameterDescriptor[] mockParameterDescriptors = getMockParameterDescriptorArray(); when(mockCalvalusProcessor.getParameterDescriptors()).thenReturn(mockParameterDescriptors); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("processorParameters"), equalTo("<parameters>\n" + "<doAtmosphericCorrection>true</doAtmosphericCorrection>\n" + "<doSmileCorrection>false</doSmileCorrection>\n" + "<outputNormReflec>true</outputNormReflec>\n" + "</parameters>")); }
@Test public void canIgnoreProcessorParametersThatAreNotProvided() throws Exception { Map<String, String> mockInputMapRaw = getLessProcessorParametersRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); ParameterDescriptor[] mockParameterDescriptors = getMockParameterDescriptorArray(); when(mockCalvalusProcessor.getParameterDescriptors()).thenReturn(mockParameterDescriptors); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("processorParameters"), equalTo("<parameters>\n" + "<doAtmosphericCorrection>true</doAtmosphericCorrection>\n" + "<doSmileCorrection>false</doSmileCorrection>\n" + "</parameters>")); }
@Test public void canGetDefaultProcessorParametersWhenNotProvided() throws Exception { Map<String, String> mockInputMapRaw = getNoProcessorParametersRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); ParameterDescriptor[] mockParameterDescriptors = getMockParameterDescriptorArray(); when(mockCalvalusProcessor.getParameterDescriptors()).thenReturn(mockParameterDescriptors); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("processorParameters"), equalTo("<parameters>\n" + "<doSmileCorrection>false</doSmileCorrection>\n" + "</parameters>")); }
@Test public void canGetDefaultProcessorParameters() throws Exception { Map<String, String> mockInputMapRaw = getMinimalRawMap(); when(mockExecuteRequestExtractor.getInputParametersMapRaw()).thenReturn(mockInputMapRaw); when(mockCalvalusProcessor.getDefaultParameters()).thenReturn(getMockDefaultParameters()); CalvalusFacade mockCalvalusFacade = getMockCalvalusFacade(); calvalusDataInputs = new CalvalusDataInputs(mockExecuteRequestExtractor, mockCalvalusProcessor, productSets, mockCalvalusFacade); assertThat(calvalusDataInputs.getValue("processorParameters"), equalTo("########################\n" + "# POLYMER COMMAND FILE #\n" + "########################\n" + "# NB: paths can be given as relative or absolute\n" + "# lines starting with character '#' are ignored\n" + "# INPUT/OUTPUT ######\n" + "L1_FORMAT MERIS\n" + "# output format: HDF, NETCDF, NETCDF_CLASSIC\n" + "OUTPUT_FORMAT NETCDF\n" + "# uncomments this to process only a subset of the rows in the L1 file\n" + "# PROCESS_ROWS 7700 9000\n" + "# NCEP and TOMS filenames\n" + "# if commented or missing, MERIS level1 ancillary data will be used\n" + "# ${ncep_toms}FILE_METEO $file_meteo\n" + "# ${ncep_toms}FILE_OZONE $file_oz\n" + "# possible values ERA_INTERIM or NCEP\n" + "AUXDATA NCEP\n" + "# BANDS DEFINITION #######\n" + "BANDS_CORR 412 443 490 510 560 620 665 754 779 865\n" + "BANDS_OC 412 443 490 510 560 620 665 754 779 865\n" + "BANDS_RW 412 443 490 510 560 620 665 754 779 865\n" + "BANDS_LUTS 412 443 490 510 560 620 665 681 709 754 760 779 865 885 900\n" + "BANDS_L1 412 443 490 510 560 620 665 681 709 754 760 779 865 885 900")); }