diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java')
-rw-r--r-- | openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java index c8ca1a554b..822b573886 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java @@ -20,13 +20,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.core.utilities.file.FileContentHandler; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - import static org.junit.Assert.assertEquals; +import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CREATED_BY_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY; @@ -39,6 +34,12 @@ import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.va import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_DEFINITION_FILEPATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_MANIFEST_FILEPATH; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.core.utilities.file.FileContentHandler; + public class ValidatorFactoryTest { private String metaFile; @@ -68,7 +69,7 @@ public class ValidatorFactoryTest { } @Test - public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException{ + public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException { handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), " ".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -79,7 +80,7 @@ public class ValidatorFactoryTest { @Test - public void testGivenNonSOL004MetaDirectoryCompliantMetaFile_thenONAPCSARValidatorIsReturned() throws IOException{ + public void testGivenNonSOL004MetaDirectoryCompliantMetaFile_thenONAPCSARValidatorIsReturned() throws IOException { metaFile = metaFile + ENTRY_DEFINITIONS.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_DEFINITION_FILEPATH; handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFile.getBytes(StandardCharsets.UTF_8)); @@ -88,21 +89,21 @@ public class ValidatorFactoryTest { } @Test - public void testGivenSOL004MetaDirectoryCompliantMetafile_thenONAPCsarValidatorIsReturned() throws IOException{ - + public void testGivenSOL004MetaDirectoryCompliantMetafile_thenONAPCsarValidatorIsReturned() throws IOException { metaFile = metaFile + - ENTRY_DEFINITIONS.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_DEFINITION_FILEPATH + "\n" - + ETSI_ENTRY_MANIFEST.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_MANIFEST_FILEPATH + "\n" - + ETSI_ENTRY_CHANGE_LOG.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_CHANGELOG_FILEPATH + "\n"; + ENTRY_DEFINITIONS.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_DEFINITION_FILEPATH + "\n" + + ETSI_ENTRY_MANIFEST.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_MANIFEST_FILEPATH + "\n" + + ETSI_ENTRY_CHANGE_LOG.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_CHANGELOG_FILEPATH + "\n"; handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFile.getBytes(StandardCharsets.UTF_8)); assertEquals(SOL004MetaDirectoryValidator.class, ValidatorFactory.getValidator(handler).getClass()); } @Test - public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned() throws IOException { - - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), ValidatorUtil.getFileResource("/validation.files/metafile/metaFileWithMultipleBlocks.meta")); + public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned() + throws IOException { + handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), + getResourceBytesOrFail("validation.files/metafile/metaFileWithMultipleBlocks.meta")); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); |