L2ProductionType extends HadoopProductionType { @Override public Production createProduction(ProductionRequest productionRequest) throws ProductionException { final String productionId = Production.createId(productionRequest.getProductionType()); final String productionName = productionRequest.getProductionName( createProductionName("Level 2 ", productionRequest)); L2WorkflowItem workflowItem = createWorkflowItem(productionId, productionName, productionRequest); String stagingDir = productionRequest.getStagingDirectory(productionId); boolean autoStaging = productionRequest.isAutoStaging(); return new Production(productionId, productionName, workflowItem.getOutputDir(), stagingDir, autoStaging, productionRequest, workflowItem); } L2ProductionType(FileSystemService fileSystemService, HadoopProcessingService processingService,
                     StagingService stagingService); @Override Production createProduction(ProductionRequest productionRequest);  }
@Test public void testCreateProductionWithMinMaxDates() throws ProductionException, IOException { ProductionRequest productionRequest = new ProductionRequest("L2", "ewa", "inputPath", "MER_RR__1P/r03/${yyyy}/${MM}/${dd}", "productionName", "My Math Production", "minDate", "2005-01-01", "maxDate", "2005-01-31", "outputFormat", "NetCDF", "autoStaging", "true", ProcessorProductionRequest.PROCESSOR_BUNDLE_NAME, "beam", ProcessorProductionRequest.PROCESSOR_BUNDLE_VERSION, "4.9-SNAPSHOT", ProcessorProductionRequest.PROCESSOR_BUNDLE_LOCATION, "/software/test/system", ProcessorProductionRequest.PROCESSOR_NAME, "BandMaths", ProcessorProductionRequest.PROCESSOR_PARAMETERS, "<!-- no params -->", "minLon", "5", "maxLon", "25", "minLat", "50", "maxLat", "60" ); Production production = productionType.createProduction(productionRequest); assertNotNull(production); assertEquals("My Math Production", production.getName()); assertEquals(true, production.getStagingPath().startsWith("ewa/")); assertEquals(true, production.getId().contains("_" + "L2" + "_")); WorkflowItem workflow = production.getWorkflow(); assertNotNull(workflow); WorkflowItem[] workflowItems = workflow.getItems(); assertNotNull(workflowItems); assertEquals(0, workflowItems.length); assertTrue(workflow instanceof L2WorkflowItem); L2WorkflowItem l2WorkflowItem = (L2WorkflowItem) workflow; assertEquals(true, l2WorkflowItem.getOutputDir().startsWith("hdfs: assertEquals("POLYGON ((5 50, 25 50, 25 60, 5 60, 5 50))", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_REGION_GEOMETRY)); String inputPathPattern = l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_PATH_PATTERNS); assertEquals("MER_RR__1P/r03/${yyyy}/${MM}/${dd}", inputPathPattern); assertEquals("[2005-01-01:2005-01-31]", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_DATE_RANGES)); assertEquals("", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_REGION_NAME)); ProductSetSaver productSetSaver = getProductSetSaver(l2WorkflowItem); assertNotNull(productSetSaver); ProductSet productSet = productSetSaver.getProductSet(); assertNotNull(productSet); assertEquals("Generic-L2", productSet.getProductType()); assertEquals("My Math Production", productSet.getName()); assertEquals( "hdfs: productSet.getPath()); assertEquals("2005-01-01", ProductionRequest.getDateFormat().format(productSet.getMinDate())); assertEquals("2005-01-31", ProductionRequest.getDateFormat().format(productSet.getMaxDate())); assertEquals("", productSet.getRegionName()); assertEquals("POLYGON ((5 50, 25 50, 25 60, 5 60, 5 50))", productSet.getRegionWKT()); }
@Test public void testCreateProductionWithDatelist() throws ProductionException, IOException { ProductionRequest productionRequest = new ProductionRequest("L2", "ewa", "inputPath", "MER_RR__1P/r03/${yyyy}/${MM}/${dd}", "dateList", "2005-01-01 2005-01-15 2005-01-31", "outputFormat", "NetCDF", "autoStaging", "true", ProcessorProductionRequest.PROCESSOR_BUNDLE_NAME, "beam", ProcessorProductionRequest.PROCESSOR_BUNDLE_VERSION, "4.9-SNAPSHOT", ProcessorProductionRequest.PROCESSOR_BUNDLE_LOCATION, "/software/test/system", ProcessorProductionRequest.PROCESSOR_NAME, "BandMaths", ProcessorProductionRequest.PROCESSOR_PARAMETERS, "<!-- no params -->", "regionName", "Island In The Sun", "regionWKT", "POLYGON ((5 55, 25 50, 25 60, 5 60, 5 55))" ); Production production = productionType.createProduction(productionRequest); assertNotNull(production); assertEquals( "Level 2 BandMaths 2005-01-01 to 2005-01-31 (Island In The Sun)", production.getName()); assertEquals(true, production.getStagingPath().startsWith("ewa/")); assertEquals(true, production.getId().contains("_" + "L2" + "_")); WorkflowItem workflow = production.getWorkflow(); assertNotNull(workflow); WorkflowItem[] workflowItems = workflow.getItems(); assertNotNull(workflowItems); assertEquals(0, workflowItems.length); assertTrue(workflow instanceof L2WorkflowItem); L2WorkflowItem l2WorkflowItem = (L2WorkflowItem) workflow; assertEquals(true, l2WorkflowItem.getOutputDir().startsWith("hdfs: assertEquals("POLYGON ((5 55, 25 50, 25 60, 5 60, 5 55))", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_REGION_GEOMETRY)); String inputPathPattern = l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_PATH_PATTERNS); assertEquals("MER_RR__1P/r03/${yyyy}/${MM}/${dd}", inputPathPattern); assertEquals("[2005-01-01:2005-01-01],[2005-01-15:2005-01-15],[2005-01-31:2005-01-31]", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_DATE_RANGES)); assertEquals("Island In The Sun", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_REGION_NAME)); ProductSetSaver productSetSaver = getProductSetSaver(l2WorkflowItem); assertNotNull(productSetSaver); ProductSet productSet = productSetSaver.getProductSet(); assertNotNull(productSet); assertEquals("Generic-L2", productSet.getProductType()); assertEquals( "Level 2 BandMaths 2005-01-01 to 2005-01-31 (Island In The Sun)", productSet.getName()); assertEquals( "hdfs: productSet.getPath()); assertEquals("2005-01-01", ProductionRequest.getDateFormat().format(productSet.getMinDate())); assertEquals("2005-01-31", ProductionRequest.getDateFormat().format(productSet.getMaxDate())); assertEquals("Island In The Sun", productSet.getRegionName()); assertEquals("POLYGON ((5 55, 25 50, 25 60, 5 60, 5 55))", productSet.getRegionWKT()); }
@Test public void testCreateProductionWithoutDates() throws ProductionException, IOException { ProductionRequest productionRequest = new ProductionRequest("L2", "ewa", "inputPath", "MER_RR__1P/r03", "outputFormat", "NetCDF", "autoStaging", "true", ProcessorProductionRequest.PROCESSOR_BUNDLE_NAME, "beam", ProcessorProductionRequest.PROCESSOR_BUNDLE_VERSION, "4.9-SNAPSHOT", ProcessorProductionRequest.PROCESSOR_BUNDLE_LOCATION, "/software/test/system", ProcessorProductionRequest.PROCESSOR_NAME, "BandMaths", ProcessorProductionRequest.PROCESSOR_PARAMETERS, "<parameters/>", "minLon", "5", "maxLon", "25", "minLat", "50", "maxLat", "60" ); Production production = productionType.createProduction(productionRequest); assertNotNull(production); assertEquals("Level 2 BandMaths", production.getName()); assertEquals(true, production.getStagingPath().startsWith("ewa/")); assertEquals(true, production.getId().contains("_" + "L2" + "_")); WorkflowItem workflow = production.getWorkflow(); assertNotNull(workflow); WorkflowItem[] workflowItems = workflow.getItems(); assertNotNull(workflowItems); assertEquals(0, workflowItems.length); assertTrue(workflow instanceof L2WorkflowItem); L2WorkflowItem l2WorkflowItem = (L2WorkflowItem) workflow; assertEquals(true, l2WorkflowItem.getOutputDir().startsWith("hdfs: assertEquals("POLYGON ((5 50, 25 50, 25 60, 5 60, 5 50))", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_REGION_GEOMETRY)); assertEquals("MER_RR__1P/r03", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_PATH_PATTERNS)); assertEquals("[null:null]", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_DATE_RANGES)); assertEquals("", l2WorkflowItem.getJobConfig().get(JobConfigNames.CALVALUS_INPUT_REGION_NAME)); ProductSetSaver productSetSaver = getProductSetSaver(l2WorkflowItem); assertNotNull(productSetSaver); ProductSet productSet = productSetSaver.getProductSet(); assertNotNull(productSet); assertEquals("Generic-L2", productSet.getProductType()); assertEquals("Level 2 BandMaths", productSet.getName()); assertEquals( "hdfs: productSet.getPath()); assertNull(productSet.getMinDate()); assertNull(productSet.getMaxDate()); assertEquals("", productSet.getRegionName()); assertEquals("POLYGON ((5 50, 25 50, 25 60, 5 60, 5 50))", productSet.getRegionWKT()); }
@Test public void testCalvalusJobNameIsUsedForProductionId() throws Exception { String nameForProduction = "my own name"; ProductionRequest productionRequest = new ProductionRequest("L2", "marcop", "inputPath", "MER_RR__1P/r03", "productionName", nameForProduction, ProcessorProductionRequest.PROCESSOR_BUNDLE_NAME, "beam", ProcessorProductionRequest.PROCESSOR_BUNDLE_VERSION, "4.9-SNAPSHOT", ProcessorProductionRequest.PROCESSOR_BUNDLE_LOCATION, "/calvalus/test/bundles", ProcessorProductionRequest.PROCESSOR_NAME, "BandMaths"); Production production = productionType.createProduction(productionRequest); assertNotNull(production); assertEquals(nameForProduction, production.getName()); }