### Question:
ContainerDataYaml { public static ContainerData readContainerFile(File containerFile) throws IOException { Preconditions.checkNotNull(containerFile, "containerFile cannot be null"); try (FileInputStream inputFileStream = new FileInputStream(containerFile)) { return readContainer(inputFileStream); } } private  ContainerDataYaml(); static void createContainerFile(ContainerType containerType,
      ContainerData containerData, File containerFile); static ContainerData readContainerFile(File containerFile); static ContainerData readContainer(byte[] containerFileContent); static ContainerData readContainer(InputStream input); static Yaml getYamlForContainerType(ContainerType containerType);  }### Answer:
@Test public void testIncorrectContainerFile() throws IOException{ try { String containerFile = "incorrect.container"; ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(containerFile).getFile()); KeyValueContainerData kvData = (KeyValueContainerData) ContainerDataYaml .readContainerFile(file); fail("testIncorrectContainerFile failed"); } catch (IllegalArgumentException ex) { GenericTestUtils.assertExceptionContains("No enum constant", ex); } }
@Test public void testCheckBackWardCompatibilityOfContainerFile() throws IOException { try { String containerFile = "additionalfields.container"; ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(containerFile).getFile()); KeyValueContainerData kvData = (KeyValueContainerData) ContainerDataYaml .readContainerFile(file); ContainerUtils.verifyChecksum(kvData); assertEquals(ContainerProtos.ContainerDataProto.State.CLOSED, kvData .getState()); assertEquals(CONTAINER_DB_TYPE, kvData.getContainerDBType()); assertEquals(ContainerProtos.ContainerType.KeyValueContainer, kvData .getContainerType()); assertEquals(9223372036854775807L, kvData.getContainerID()); assertEquals("/hdds/current/aed-fg4-hji-jkl/containerDir0/1", kvData .getChunksPath()); assertEquals("/hdds/current/aed-fg4-hji-jkl/containerDir0/1", kvData .getMetadataPath()); assertEquals(FILE_PER_CHUNK, kvData.getLayOutVersion()); assertEquals(2, kvData.getMetadata().size()); } catch (Exception ex) { ex.printStackTrace(); fail("testCheckBackWardCompatibilityOfContainerFile failed"); } }
@Test public void testIncorrectChecksum() { try { String containerFile = "incorrect.checksum.container"; ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(containerFile).getFile()); KeyValueContainerData kvData = (KeyValueContainerData) ContainerDataYaml .readContainerFile(file); ContainerUtils.verifyChecksum(kvData); fail("testIncorrectChecksum failed"); } catch (Exception ex) { GenericTestUtils.assertExceptionContains("Container checksum error for " + "ContainerID:", ex); } }