### Question:
APIServiceStatusService { public List<ContainerStatusChangeEvent> getContainersStateAsEvents() { log.debug("Retrieving all containers statuses as events"); List<ContainerStatusChangeEvent> events = new ArrayList<>(); Iterable<APIContainer> allContainers = cachedProductFamilyService.getAllContainers(); allContainers.forEach(container -> { cachedProductFamilyService.calculateContainerServiceTotals(container); addContainerEvent(events, container); }); return events; } @Autowired  APIServiceStatusService(CachedProductFamilyService cachedProductFamilyService,
                                   CachedServicesService cachedServicesService,
                                   CachedApiDocService cachedApiDocService); ResponseEntity<Applications> getCachedApplicationStateResponse(); Applications getCachedApplicationState(); List<ContainerStatusChangeEvent> getContainersStateAsEvents(); ResponseEntity<String> getServiceCachedApiDocInfo(@NonNull String serviceId, String apiVersion); List<ContainerStatusChangeEvent> getRecentlyUpdatedContainersAsEvents();  }### Answer:
@Test public void testGetContainerStatusAsEvents() { List<APIContainer> containers = new ArrayList<>(createContainers()); when(cachedProductFamilyService.getAllContainers()).thenReturn(containers); doNothing().when(this.cachedProductFamilyService).calculateContainerServiceTotals(any(APIContainer.class)); List<ContainerStatusChangeEvent> expectedEvents = new ArrayList<>(); containers.forEach(container -> { STATUS_EVENT_TYPE eventType; if (InstanceInfo.InstanceStatus.DOWN.name().equalsIgnoreCase(container.getStatus())) { eventType = STATUS_EVENT_TYPE.CANCEL; } else { eventType = STATUS_EVENT_TYPE.RENEW; } expectedEvents.add(new ContainerStatusChangeEvent( container.getId(), container.getTitle(), container.getStatus(), container.getTotalServices(), container.getActiveServices(), container.getServices(), eventType) ); }); List<ContainerStatusChangeEvent> actualEvents = apiServiceStatusService.getContainersStateAsEvents(); assertEquals(expectedEvents.size(), actualEvents.size()); }