TimeService extends AbstractService { public boolean isSecondEarliestValue(Object var, String column) { if (secondEarliestValueMap.get(column) == null) { putAttributeValues(column); } return var.equals(secondEarliestValueMap.get(column)); } TimeService(DataSet dataset); void putAttributeValues(String column); boolean isLatestValue(Object var, String column); boolean isSecondEarliestValue(Object var, String column); boolean isSecondLatestValue(Object var, String column); boolean isEarliestValue(Object var, String column); @Override void init();  }
@Test public void testIsSecondEarliestValue() { List<Column> columnList = generateColumnList(); DataSet dataSet = new DataSet(columnList); dataSet.initData(generateInputData()); TimeService ts = new TimeService(dataSet); ts.putAttributeValues("date1"); ts.putAttributeValues("date2"); ts.putAttributeValues("date3"); ts.putAttributeValues("date4"); Assert.assertEquals("longestValueMap size should be 4", 4, ts.earliestValueMap.size()); Assert.assertEquals("secondLongestValueMap size should be 4", 4, ts.latestValueMap.size()); Assert.assertEquals("secondShortestValueMap size should be 4", 4, ts.secondEarliestValueMap.size()); Assert.assertEquals("shortestValueMap size should be 4", 4, ts.secondLatestValueMap.size()); Assert.assertEquals("The result of firstName column should be 2000-02-02", "2000-02-02", SampleData.dateToString(ts.secondEarliestValueMap.get("date1"), "yyyy-MM-dd")); Assert.assertEquals("The result of firstName column should be 2000-01-01", "2000-01-01", SampleData.dateToString(ts.secondEarliestValueMap.get("date2"), "yyyy-MM-dd")); Assert.assertEquals("The result of firstName column should be 2000-02-02", "2000-02-02", SampleData.dateToString(ts.secondEarliestValueMap.get("date3"), "yyyy-MM-dd")); Assert.assertEquals("The result of firstName column should be 2000-04-04", "2000-04-04", SampleData.dateToString(ts.secondEarliestValueMap.get("date4"), "yyyy-MM-dd")); ts.init(); }