L3ProductionType extends HadoopProductionType { static List<DateRange> getDateRanges(ProductionRequest productionRequest, String periodLengthDefault) throws ProductionException { Date[] dateList = productionRequest.getDates("dateList", null); if (dateList != null) { return DateRangeCalculator.fromDateList(dateList); } else { Date minDate = productionRequest.getDate("minDate"); Date maxDate = productionRequest.getDate("maxDate"); String periodLength; if (periodLengthDefault != null) { periodLength = productionRequest.getString("periodLength", periodLengthDefault); } else { periodLength = productionRequest.getString("periodLength"); } String compositingPeriodLength = productionRequest.getString("compositingPeriodLength", periodLength); return DateRangeCalculator.fromMinMax(minDate, maxDate, periodLength, compositingPeriodLength); } } L3ProductionType(FileSystemService fileSystemService, HadoopProcessingService processingService,
                     StagingService stagingService); @Override Production createProduction(ProductionRequest productionRequest); static String getL3ConfigXml(ProductionRequest productionRequest);  }
@Test public void testGetDatePairList_MinMax_complex() throws ProductionException, ParseException { ProductionRequest productionRequest = new ProductionRequest("L3", "ewa", "minDate", "2010-06-15", "maxDate", "2010-08-15", "periodLength", "20", "compositingPeriodLength", "5"); List<DateRange> dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(3, dateRangeList.size()); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-06-19", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-07-05", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-07-09", asString(dateRangeList.get(1).getStopDate())); assertEquals("2010-07-25", asString(dateRangeList.get(2).getStartDate())); assertEquals("2010-07-29", asString(dateRangeList.get(2).getStopDate())); }
@Test public void testGetDatePairList_MinMax_simple() throws ProductionException, ParseException { ProductionRequest productionRequest = new ProductionRequest("L3", "ewa", "minDate", "2010-06-15", "maxDate", "2010-08-15", "periodLength", "20", "compositingPeriodLength", "20"); List<DateRange> dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(3, dateRangeList.size()); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-07-04", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-07-05", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-07-24", asString(dateRangeList.get(1).getStopDate())); assertEquals("2010-07-25", asString(dateRangeList.get(2).getStartDate())); assertEquals("2010-08-13", asString(dateRangeList.get(2).getStopDate())); }
@Test public void testGetDatePairList_DateList() throws ProductionException, ParseException { ProductionRequest productionRequest = new ProductionRequest("L3", "ewa", "dateList", "2010-06-15 2010-07-01 2010-07-19 "); List<DateRange> dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(3, dateRangeList.size()); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-07-01", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-07-01", asString(dateRangeList.get(1).getStopDate())); assertEquals("2010-07-19", asString(dateRangeList.get(2).getStartDate())); assertEquals("2010-07-19", asString(dateRangeList.get(2).getStopDate())); }
@Test public void testGetDatePairList_Monthly() throws ProductionException, ParseException { ProductionRequest productionRequest = new ProductionRequest("L3", "ewa", "minDate", "2010-06-15", "maxDate", "2010-08-15", "periodLength", "-30"); List<DateRange> dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(2, dateRangeList.size()); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-07-14", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-07-15", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-08-14", asString(dateRangeList.get(1).getStopDate())); productionRequest = new ProductionRequest("L3", "ewa", "minDate", "2010-06-15", "maxDate", "2010-08-15", "periodLength", "-30", "compositingPeriodLength", "5"); dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(2, dateRangeList.size()); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-06-19", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-07-15", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-07-19", asString(dateRangeList.get(1).getStopDate())); productionRequest = new ProductionRequest("L3", "ewa", "minDate", "2010-01-01", "maxDate", "2010-12-31", "periodLength", "100", "compositingPeriodLength", "-30"); dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(4, dateRangeList.size()); assertEquals("2010-01-01", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-01-31", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-04-11", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-05-10", asString(dateRangeList.get(1).getStopDate())); assertEquals("2010-07-20", asString(dateRangeList.get(2).getStartDate())); assertEquals("2010-08-19", asString(dateRangeList.get(2).getStopDate())); assertEquals("2010-10-28", asString(dateRangeList.get(3).getStartDate())); assertEquals("2010-11-27", asString(dateRangeList.get(3).getStopDate())); }
@Test public void testGetDatePairList_OverlappingPeriods() throws ProductionException, ParseException { ProductionRequest productionRequest = new ProductionRequest("L3", "ewa", "minDate", "2010-06-15", "maxDate", "2010-06-22", "periodLength", "1", "compositingPeriodLength", "5"); List<DateRange> dateRangeList = L3ProductionType.getDateRanges(productionRequest, null); assertEquals(4, dateRangeList.size()); assertEquals("2010-06-15", asString(dateRangeList.get(0).getStartDate())); assertEquals("2010-06-19", asString(dateRangeList.get(0).getStopDate())); assertEquals("2010-06-16", asString(dateRangeList.get(1).getStartDate())); assertEquals("2010-06-20", asString(dateRangeList.get(1).getStopDate())); assertEquals("2010-06-17", asString(dateRangeList.get(2).getStartDate())); assertEquals("2010-06-21", asString(dateRangeList.get(2).getStopDate())); assertEquals("2010-06-18", asString(dateRangeList.get(3).getStartDate())); assertEquals("2010-06-22", asString(dateRangeList.get(3).getStopDate())); }