MonthlySalesFigureCalculator { public String summarize(List<List> salesDay) { Map<String, Map<String, String>> dailySalesCalendar = new LinkedHashMap<String, Map<String, String>>(); for (List salesDate : salesDay) { LOGGER.debug("Sales date: {} and value: {}", salesDate.get(0), salesDate.get(1)); setSalesValue(dailySalesCalendar, getMonthAndYearOfDate(salesDate.get(0).toString()), salesDate.get(0).toString(), salesDate.get(1).toString()); } return toRVector(summarizeMonthlyValues(dailySalesCalendar)); }  String summarize(List<List> salesDay);  }
@Test public void summarizeWrongDate() { final List date = new ArrayList<String>(); date.add(new StringBuilder().append(1).toString()); date.add(new StringBuilder().append(100).toString()); salesDate.add(date); try { salesCalculator.summarize(salesDate); } catch (Exception ex) { assertTrue("Did not receive an apropriate ", (ex instanceof ParseException)); } }
@Test public void summarizeValidDate() { for (int i = 0; i < 10; i++) { List date = new ArrayList<String>(); date.add(new StringBuilder().append('0').append(i).append("/01/2014").toString()); date.add(new StringBuilder().append(i * 100).toString()); salesDate.add(date); } String rCode = salesCalculator.summarize(salesDate); assertEquals("Comma separated values not received", "0,100,200,300,400,500,600,700,800,900", rCode); }