### Question:
DockerUtils { @Nullable public String getContainerId() throws IOException { if (cgroupLocation == null) { return null; } final File procFile; try { procFile = new File(cgroupLocation.toURI()); } catch (URISyntaxException e) { logger.warn("Failed to read container ID because " + cgroupLocation.toString() + " didn't contain an ID."); return null; } if (procFile.exists()) { try (InputStream inputStream = new FileInputStream(procFile); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { String line; do { line = reader.readLine(); if (line == null) { logger.warn("Failed to read container ID because " + cgroupLocation.toString() + " didn't contain an ID."); } else if (line.length() > CONTAINER_ID_LENGTH) { return line.substring(line.length() - CONTAINER_ID_LENGTH); } } while (line != null); } } else { logger.warn("Failed to read container ID because " + cgroupLocation.toString() + " does not exist."); } return null; } DockerUtils();  DockerUtils(URL cgroupLocation); @Nullable String getContainerId();  }### Answer:
@Test void testEmptyCgroupFile() throws IOException { DockerUtils dockerUtils = new DockerUtils(DockerUtilsTest.class.getResource("/com/amazonaws/xray/utils/emptyCgroup")); String id = dockerUtils.getContainerId(); Assertions.assertNull(id); }
@Test void testInvalidCgroupFile() throws IOException { DockerUtils dockerUtils = new DockerUtils(DockerUtilsTest.class.getResource("/com/amazonaws/xray/utils/invalidCgroup")); String id = dockerUtils.getContainerId(); Assertions.assertNull(id); }
@Test void testValidFirstLineCgroupFile() throws IOException { DockerUtils dockerUtils = new DockerUtils(DockerUtilsTest.class.getResource("/com/amazonaws/xray/utils/validCgroup")); String id = dockerUtils.getContainerId(); Assertions.assertEquals(DOCKER_ID, id); }
@Test void testValidLaterLineCgroupFile() throws IOException { DockerUtils dockerUtils = new DockerUtils(DockerUtilsTest.class.getResource( "/com/amazonaws/xray/utils/validSecondCgroup")); String id = dockerUtils.getContainerId(); Assertions.assertEquals(DOCKER_ID, id); }