PositiveBoundHiveDate extends BoundaryDate<PositiveBoundHiveDate.PositiveBoundHiveDateTag> { public List<Map<String, String>> pipelinePossibleStates(PositiveBoundHiveDate.PositiveBoundHiveDateTag action, List<Map<String, String>> possibleStateList) { return returnStates(action, possibleStateList, setParameters(action, true)); }  Class<PositiveBoundHiveDateTag> getTagActionClass(); String getTagName(); String getTagNameSpace(); List<Map<String, String>> pipelinePossibleStates(PositiveBoundHiveDate.PositiveBoundHiveDateTag action,
                                                            List<Map<String, String>> possibleStateList);  }
@Test public void leapYearTest() { Map<String, String> variableDomains = new HashMap<>(); List<Map<String, String>> listOfMaps = new LinkedList<>(); listOfMaps.add(variableDomains); PositiveBoundHiveDate dateTest = new PositiveBoundHiveDate(); PositiveBoundHiveDate.PositiveBoundHiveDateTag tag = new PositiveBoundHiveDate.PositiveBoundHiveDateTag(); tag.setName("name"); tag.setEarliest("2016-02-28"); tag.setLatest("2016-03-01"); List<Map<String, String>> newList = dateTest.pipelinePossibleStates(tag, listOfMaps); Assert.assertEquals(newList.get(0).get("name"), "2016-02-28"); Assert.assertEquals(newList.get(1).get("name"), "2016-02-29"); Assert.assertEquals(newList.get(2).get("name"), "2016-02-29"); Assert.assertEquals(newList.get(3).get("name"), "2016-03-01"); }
@Test public void defaultTest() { Map<String, String> variableDomains = new HashMap<>(); List<Map<String, String>> listOfMaps = new LinkedList<>(); listOfMaps.add(variableDomains); PositiveBoundHiveDate dateTest = new PositiveBoundHiveDate(); PositiveBoundHiveDate.PositiveBoundHiveDateTag tag = new PositiveBoundHiveDate.PositiveBoundHiveDateTag(); tag.setName("name"); tag.setOnlyBusinessDays("false"); Calendar currDate = Calendar.getInstance(); Calendar prevDate = Calendar.getInstance(); prevDate.add(Calendar.DATE, -1); String current = new SimpleDateFormat("yyyy-MM-dd").format(currDate.getTime()); String prev = new SimpleDateFormat("yyyy-MM-dd").format(prevDate.getTime()); String day = current.substring(8, 10); String month = current.substring(5, 7); String year = current.substring(0, 4); String prevDay = prev.substring(8, 10); String prevMonth = prev.substring(5, 7); String preYear = prev.substring(0, 4); List<Map<String, String>> newList = dateTest.pipelinePossibleStates(tag, listOfMaps); Assert.assertEquals(newList.get(0).get("name"), "1970-01-01"); Assert.assertEquals(newList.get(1).get("name"), "1970-01-02"); Assert.assertEquals(newList.get(2).get("name"), preYear + "-" + prevMonth + "-" + prevDay); Assert.assertEquals(newList.get(3).get("name"), year + "-" + month + "-" + day); }
@Test public void onlyBusinessDayTest() { Map<String, String> variableDomains = new HashMap<>(); List<Map<String, String>> listOfMaps = new LinkedList<>(); listOfMaps.add(variableDomains); PositiveBoundHiveDate dateTest = new PositiveBoundHiveDate(); PositiveBoundHiveDate.PositiveBoundHiveDateTag tag = new PositiveBoundHiveDate.PositiveBoundHiveDateTag(); tag.setName("name"); tag.setEarliest("2012-12-31"); tag.setLatest("2014-01-02"); tag.setOnlyBusinessDays("true"); List<Map<String, String>> newList = dateTest.pipelinePossibleStates(tag, listOfMaps); Assert.assertEquals(newList.get(0).get("name"), "2012-12-31"); Assert.assertEquals(newList.get(1).get("name"), "2013-01-02"); Assert.assertEquals(newList.get(2).get("name"), "2013-12-31"); Assert.assertEquals(newList.get(3).get("name"), "2014-01-02"); }
@Test public void notOnlyBusinessDayTest() { Map<String, String> variableDomains = new HashMap<>(); List<Map<String, String>> listOfMaps = new LinkedList<>(); listOfMaps.add(variableDomains); PositiveBoundHiveDate dateTest = new PositiveBoundHiveDate(); PositiveBoundHiveDate.PositiveBoundHiveDateTag tag = new PositiveBoundHiveDate.PositiveBoundHiveDateTag(); tag.setName("name"); tag.setEarliest("2012-12-31"); tag.setLatest("2014-01-02"); tag.setOnlyBusinessDays("false"); List<Map<String, String>> newList = dateTest.pipelinePossibleStates(tag, listOfMaps); Assert.assertEquals(newList.get(0).get("name"), "2012-12-31"); Assert.assertEquals(newList.get(1).get("name"), "2013-01-01"); Assert.assertEquals(newList.get(2).get("name"), "2014-01-01"); Assert.assertEquals(newList.get(3).get("name"), "2014-01-02"); }