### Question:
Day implements Comparable { public static List<Day> buildSortedDays(List<Range> ranges) { List<IMSTimePoint> imsTimePointList = IMSTimePoint.build(ranges); Map<String, List<Integer>> timePointsMap = new HashMap<>(); for (IMSTimePoint imsTimePoint : imsTimePointList) { String date = imsTimePoint.getDate(); if (!timePointsMap.containsKey(date)) { timePointsMap.put(date, new ArrayList<>()); } timePointsMap.get(date).add(imsTimePoint.getHourIndex()); } Set<Day> days = new HashSet<>(); for (Map.Entry<String, List<Integer>> entry : timePointsMap.entrySet()) { Day day = new Day(entry.getKey(), entry.getValue()); days.add(day); } List<Day> sortedDays = new ArrayList<>(days); Collections.sort(sortedDays); return sortedDays; } Day(String dayStr);  Day(String dayStr, List<Integer> hours); String getDayStr(); List<Integer> getHours(); static List<Day> buildSortedDays(List<Range> ranges); static Set<String> getDayString(Set<Day> days); static Set<String> getDayStringTreated(Set<Day> days, String toBeRemoved); @Override int hashCode(); @Override boolean equals(Object dayObject); static String treatDayStr(String dayStr); @Override int compareTo(Object o);  }### Answer:
@Test public void buildSortedDays() { List<Range> ranges = new ArrayList(); Range r1 = new Range(); r1.setSt("2018-01-07"); r1.setEd("2018-01-07"); r1.setSh("0"); r1.setEh("23"); ranges.add(r1); String dayStr = "20180105"; Day day = new Day(dayStr); List<Day> exp = new ArrayList(); exp.add(new Day("2018-01-07")); assertEquals(exp, day.buildSortedDays(ranges)); }