Mockito.when(calendarService.getServiceDatesForServiceId(serviceIdC)).thenReturn(
serviceDatesC);
Mockito.when(calendarService.getServiceDatesForServiceId(serviceIdD)).thenReturn(
serviceDatesD);
ServiceIdOverlapCache cache = new ServiceIdOverlapCache();
cache.setCalendarService(calendarService);
List<ServiceIdActivation> combinations = cache.getOverlappingServiceIdCombinations(set(
lsidA, lsidB, lsidC,lsidD));
assertEquals(4, combinations.size());
ServiceIdActivation combo = combinations.get(0);
assertEquals(Arrays.asList(lsidA, lsidB),combo.getActiveServiceIds());
assertEquals(Arrays.asList(),combo.getInactiveServiceIds());
combo = combinations.get(1);
assertEquals(Arrays.asList(lsidB, lsidC),combo.getActiveServiceIds());
assertEquals(Arrays.asList(),combo.getInactiveServiceIds());
combo = combinations.get(2);
assertEquals(Arrays.asList(lsidC, lsidD),combo.getActiveServiceIds());
assertEquals(Arrays.asList(),combo.getInactiveServiceIds());
combo = combinations.get(3);
assertEquals(Arrays.asList(lsidA),combo.getActiveServiceIds());
assertEquals(Arrays.asList(lsidB),combo.getInactiveServiceIds());
combinations = cache.getOverlappingServiceIdCombinations(set(lsidA, lsidB,
lsidC, lsidD));
Mockito.verify(calendarService, Mockito.times(1)).getServiceDatesForServiceId(
serviceIdA);
Mockito.verify(calendarService, Mockito.times(1)).getServiceDatesForServiceId(