### Question:
DockerUtil { public Optional<String> getContainerStatus(String containerId) { Optional<String> result = Optional.empty(); try { LoggingService.logDebug(MODULE_NAME ,"Start get Container status"); InspectContainerResponse inspectInfo = dockerClient.inspectContainerCmd(containerId).exec(); ContainerState status = inspectInfo.getState(); result = Optional.ofNullable(status.getStatus()); } catch (Exception exp) { logError(MODULE_NAME, "Error getting container status", new AgentSystemException(exp.getMessage(), exp)); } LoggingService.logDebug(MODULE_NAME ,"Finished get Container status"); return result; } private  DockerUtil(); static DockerUtil getInstance(); void reInitDockerClient(); String getDockerBridgeName(); void startContainer(Microservice microservice); void stopContainer(String id); void removeContainer(String id, Boolean withRemoveVolumes); @SuppressWarnings("deprecation") String getContainerIpAddress(String id); String getContainerName(Container container); String getContainerMicroserviceUuid(Container container); static String getIoFogContainerName(String microserviceUuid); Optional<Container> getContainer(String microserviceUuid); MicroserviceStatus getMicroserviceStatus(String containerId); List<Container> getRunningContainers(); List<Container> getRunningIofogContainers(); Optional<Statistics> getContainerStats(String containerId); long getContainerStartedAt(String id); boolean areMicroserviceAndContainerEqual(String containerId, Microservice microservice); Optional<String> getContainerStatus(String containerId); boolean isContainerRunning(String containerId); List<Container> getContainers(); void removeImageById(String imageId); @SuppressWarnings("resource") void pullImage(String imageName, String microserviceUuid, Registry registry); boolean findLocalImage(String imageName); String createContainer(Microservice microservice, String host); PruneResponse dockerPrune(); void update(PullResponseItem item, Map<String, ItemStatus> statuses);  }### Answer:
@Test public void testGetContainerStatus() { assertEquals(Optional.of("UNKNOWN"), dockerUtil.getContainerStatus(containerID)); Mockito.verify(dockerClient).inspectContainerCmd(any()); Mockito.verify(inspectContainerResponse).getState(); }
@Test public void testGetContainerStatusWhenContainerStateIsNull() { PowerMockito.when(inspectContainerResponse.getState()).thenReturn(null); assertEquals(Optional.empty(), dockerUtil.getContainerStatus(containerID)); Mockito.verify(dockerClient).inspectContainerCmd(any()); Mockito.verify(inspectContainerResponse).getState(); }
@Test public void throwsExceptionWhenExecISCalledGetContainerStatus() { PowerMockito.doThrow(spy(new NotFoundException("Exception"))).when(inspectContainerCmd).exec(); assertEquals(Optional.empty(), dockerUtil.getContainerStatus(containerID)); Mockito.verify(dockerClient).inspectContainerCmd(any()); Mockito.verify(inspectContainerResponse, Mockito.never()).getState(); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logError(eq(MODULE_NAME), eq("Error getting container status"), any()); }