diff options
Diffstat (limited to 'openecomp-be/backend')
5 files changed, 101 insertions, 101 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java index 6597beb9f5..0d5aef58ac 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java @@ -26,7 +26,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.ELIGIBLE_FILES; import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_MF_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; +import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import java.io.IOException; import java.io.InputStream; @@ -71,7 +71,7 @@ class ONAPCsarValidator implements Validator { private void validateMetadata(FileContentHandler contentMap){ if (!validateTOSCAYamlFileInRootExist(contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME)) { - try (InputStream metaFileContent = contentMap.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME.getName())) { + try (InputStream metaFileContent = contentMap.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)) { ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(metaFileContent); String entryDefinitionsPath = onboardingToscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName()); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java index 8a297142b6..1d1ffdba91 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java @@ -37,9 +37,9 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CERTIFICATE; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; +import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_FILE_VERSION_1_0; +import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import java.io.IOException; import java.io.InputStream; @@ -127,13 +127,13 @@ class SOL004MetaDirectoryValidator implements Validator { } /** - * Parses the {@link ToscaMetaEntry#TOSCA_META_PATH_FILE_NAME;} file + * Parses the {@link org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo#TOSCA_META_PATH_FILE_NAME} file */ private void parseToscaMetadata() { try { toscaMetadata = OnboardingToscaMetadata - .parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME.getName())); + .parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); } catch (final IOException e) { reportError(ErrorLevel.ERROR, Messages.METADATA_PARSER_INTERNAL.getErrorMessage()); LOGGER.error(Messages.METADATA_PARSER_INTERNAL.getErrorMessage(), e.getMessage(), e); @@ -220,9 +220,8 @@ class SOL004MetaDirectoryValidator implements Validator { private void handleEntry(final Map.Entry<String, String> entry) { final String key = entry.getKey(); final ToscaMetaEntry toscaMetaEntry = ToscaMetaEntry.parse(entry.getKey()).orElse(null); + // allows any other unknown entry if (toscaMetaEntry == null) { - reportError(ErrorLevel.ERROR, Messages.METADATA_UNSUPPORTED_ENTRY.formatMessage(key)); - LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), key); return; } final String value = entry.getValue(); @@ -284,7 +283,7 @@ class SOL004MetaDirectoryValidator implements Validator { } private boolean isValidTOSCAVersion(final String key, final String version) { - return TOSCA_META_FILE_VERSION_ENTRY.getName().equals(key) && TOSCA_META_FILE_VERSION.getName().equals(version); + return TOSCA_META_FILE_VERSION_ENTRY.getName().equals(key) && TOSCA_META_FILE_VERSION_1_0.equals(version); } private boolean isValidCSARVersion(final String value, final String version) { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java index e203187183..654fb1a1af 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_MF_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; +import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import java.io.IOException; import java.io.InputStream; @@ -91,9 +91,6 @@ import org.openecomp.sdc.versioning.dao.types.VersionStatus; import org.openecomp.sdc.versioning.types.VersionInfo; import org.openecomp.sdc.versioning.types.VersionableEntityAction; -//import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; - - public class VendorSoftwareProductManagerImplTest { private static final String VSP_ID = "vspId"; @@ -161,7 +158,7 @@ public class VendorSoftwareProductManagerImplTest { final FileContentHandler handler = new FileContentHandler(); final byte[] metadataInputBytes = IOUtils.toByteArray(metadataInput); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metadataInputBytes); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metadataInputBytes); handler.addFile(TOSCA_META_ORIG_PATH_FILE_NAME, metadataInputBytes); handler.addFile(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, IOUtils.toByteArray(manifestInput)); final ToscaServiceModel toscaMetadata = new ToscaServiceModel(handler, new HashMap<>(), ""); @@ -185,7 +182,7 @@ public class VendorSoftwareProductManagerImplTest { try(InputStream metadataInput = getClass().getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta")) { FileContentHandler handler = new FileContentHandler(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), IOUtils.toByteArray(metadataInput)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, IOUtils.toByteArray(metadataInput)); ToscaServiceModel toscaMetadata = new ToscaServiceModel(handler, new HashMap<>(), ""); when(enrichedServiceModelDaoMock.getServiceModel(any(), any())).thenReturn(toscaMetadata ); VspDetails vsp = @@ -212,7 +209,7 @@ public class VendorSoftwareProductManagerImplTest { final FileContentHandler handler = new FileContentHandler(); final byte[] metadataInputBytes = IOUtils.toByteArray(metadataInput); handler.addFile(TOSCA_META_ORIG_PATH_FILE_NAME, metadataInputBytes); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metadataInputBytes); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metadataInputBytes); handler.addFile(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, IOUtils.toByteArray(manifestInput)); final ToscaServiceModel toscaMetadata = new ToscaServiceModel(handler, new HashMap<>(), ""); when(enrichedServiceModelDaoMock.getServiceModel(any(), any())).thenReturn(toscaMetadata); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java index 8bbf9c0cda..d64faa051b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java @@ -21,12 +21,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anEmptyMap; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -45,14 +44,13 @@ import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_RELEASE_DATE_TI import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CREATED_BY_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_EVENTS; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CERTIFICATE; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_LICENSES; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_TESTS; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; +import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.EMPTY_YAML_FILE_PATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.INVALID_YAML_FILE_PATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.SAMPLE_DEFINITION_FILE_PATH; @@ -77,7 +75,6 @@ import org.openecomp.sdc.common.utils.SdcCommon; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.tosca.csar.ManifestTokenType; -import org.openecomp.sdc.tosca.csar.ToscaMetaEntry; import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.OnboardingPackageContentHandler; import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager; import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManagerException; @@ -112,7 +109,7 @@ public class SOL004MetaDirectoryValidatorTest { final String metaFileWithInvalidEntry = "TOSCA-Meta-File-Version: \n" + "Entry-Definitions: " + TOSCA_DEFINITION_FILEPATH; - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler); @@ -133,7 +130,7 @@ public class SOL004MetaDirectoryValidatorTest { .append(ETSI_ENTRY_LICENSES.getName()) .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(entryLicenseFilePath).append("\n"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -143,7 +140,7 @@ public class SOL004MetaDirectoryValidatorTest { handler.addFile(entryLicenseFilePath, "".getBytes()); final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder() - .withSource(TOSCA_META_PATH_FILE_NAME.getName()) + .withSource(TOSCA_META_PATH_FILE_NAME) .withSource(TOSCA_DEFINITION_FILEPATH) .withSource(TOSCA_CHANGELOG_FILEPATH) .withSource(TOSCA_MANIFEST_FILEPATH).withSource(SAMPLE_SOURCE) @@ -158,17 +155,24 @@ public class SOL004MetaDirectoryValidatorTest { } @Test - public void testGivenTOSCAMeta_withUnsupportedEntry_thenWarningIsReturned() { - metaFileBuilder = new StringBuilder() - .append(ENTRY_EVENTS.getName()) - .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()) - .append(" Definitions/events.log"); + public void testGivenTOSCAMeta_withUnsupportedEntry_thenNoErrorIsReturned() { + metaFileBuilder + .append("a-unknown-entry") + .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ") + .append("Definitions/events.log"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); + handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); + final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder() + .withSource(TOSCA_META_PATH_FILE_NAME) + .withSource(TOSCA_DEFINITION_FILEPATH) + .withSource(TOSCA_CHANGELOG_FILEPATH) + .withSource(TOSCA_MANIFEST_FILEPATH); + + handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8)); final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler); - List<ErrorMessage> errorMessages = errors.get(SdcCommon.UPLOAD_FILE); - assertTrue(errors.size() == 1 && errorMessages.size() == 1); - assertSame(ErrorLevel.ERROR, errorMessages.get(0).getLevel()); + assertThat("Validation should produce no errors", errors, is(anEmptyMap())); } /** @@ -191,8 +195,8 @@ public class SOL004MetaDirectoryValidatorTest { .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_CHANGELOG_FILEPATH); final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); @@ -209,7 +213,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenTOSCAMetaFile_withNonExistentFileReferenced_thenErrorsReturned() { - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler); assertThat("Total of errors should be as expected", errors.size(), is(1)); @@ -222,8 +226,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFile_whenValidImportStatementExist_thenNoErrorsReturned() { final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -250,8 +254,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFile_whenMultipleDefinitionsImportStatementExist_thenNoErrorsReturned() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -285,8 +289,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFile_whenInvalidImportStatementExist_thenErrorIsReturned() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -314,8 +318,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFile_whenReferencedImportDoesNotExist_thenErrorIsReturned() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -344,8 +348,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFile_withInvalidYAML_thenErrorIsReturned() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -368,8 +372,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenManifestFile_withValidSourceAndNonManoSources_thenNoErrorIsReturned() { final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -403,8 +407,8 @@ public class SOL004MetaDirectoryValidatorTest { //non existent reference manifestBuilder.withSource("Artifacts/Deployment/Events/RadioNode_pnf_v1.yaml"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -431,7 +435,7 @@ public class SOL004MetaDirectoryValidatorTest { */ @Test public void testGivenManifestFile_withInvalidData_thenErrorIsReturned() { - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, getResourceBytesOrFail("validation.files/manifest/invalidManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); @@ -445,8 +449,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenManifestAndDefinitionFile_withSameNames_thenNoErrorReturned() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -485,8 +489,8 @@ public class SOL004MetaDirectoryValidatorTest { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -523,8 +527,8 @@ public class SOL004MetaDirectoryValidatorTest { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -547,8 +551,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenManifestFile_withValidVnfMetadata_thenNoErrorsReturned() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); @@ -565,8 +569,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenManifestFile_withValidPnfMetadata_thenNoErrorsReturned() { final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -593,8 +597,8 @@ public class SOL004MetaDirectoryValidatorTest { .withMetaData(PNFD_ARCHIVE_VERSION.getToken(), "1.0") .withMetaData(VNF_RELEASE_DATE_TIME.getToken(), "2019-12-14T11:25:00+00:00"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); @@ -616,8 +620,8 @@ public class SOL004MetaDirectoryValidatorTest { .withMetaData("invalid_package_version", "1.0") .withMetaData("invalid_release_date_time", "2019-12-14T11:25:00+00:00"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -639,8 +643,8 @@ public class SOL004MetaDirectoryValidatorTest { manifestBuilder.withMetaData(PNFD_NAME.getToken(), "RadioNode"); manifestBuilder.withMetaData(PNFD_RELEASE_DATE_TIME.getToken(), "2019-12-14T11:25:00+00:00"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -662,8 +666,8 @@ public class SOL004MetaDirectoryValidatorTest { manifestBuilder.withMetaData(VNF_PRODUCT_NAME.getToken(), "RadioNode"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -690,8 +694,8 @@ public class SOL004MetaDirectoryValidatorTest { .withMetaData(PNFD_ARCHIVE_VERSION.getToken(), "1.0") .withMetaData(PNFD_RELEASE_DATE_TIME.getToken(), "2019-03-11T11:25:00+00:00"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -715,8 +719,8 @@ public class SOL004MetaDirectoryValidatorTest { .append(ETSI_ENTRY_LICENSES.getName()) .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Files/Licenses"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -738,8 +742,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFileWithImportedDescriptor_whenImportedDescriptorImportsMissingFile_thenMissingImportErrorOccur() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -776,8 +780,8 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenDefinitionFileWithImportedDescriptor_whenInvalidImportStatementExistInImportedDescriptor_thenInvalidImportErrorOccur() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH); @@ -811,8 +815,8 @@ public class SOL004MetaDirectoryValidatorTest { public void givenManifestWithNonManoPmAndVesArtifacts_whenNonManoArtifactsAreValid_thenNoErrorsOccur() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); @@ -843,8 +847,8 @@ public class SOL004MetaDirectoryValidatorTest { public void givenManifestWithNonManoPmOrVesArtifacts_whenNonManoArtifactsYamlAreInvalid_thenInvalidYamlErrorOccur() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); @@ -881,8 +885,8 @@ public class SOL004MetaDirectoryValidatorTest { public void givenManifestWithNonManoPmOrVesArtifacts_whenNonManoArtifactsYamlAreEmpty_thenEmptyYamlErrorOccur() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); @@ -919,8 +923,8 @@ public class SOL004MetaDirectoryValidatorTest { public void givenManifestWithNonManoPmOrVesArtifacts_whenNonManoArtifactsHaveNotYamlExtension_thenInvalidYamlExtensionErrorOccur() { final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder(); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); @@ -961,9 +965,9 @@ public class SOL004MetaDirectoryValidatorTest { handler.addFile(nonManoSoftwareInformationPath, getResourceBytesOrFail("validation.files/non-mano/pnf-sw-information-valid.yaml")); manifestBuilder.withNonManoArtifact(ONAP_SW_INFORMATION.getType(), nonManoSoftwareInformationPath); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString() + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString() .getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -985,9 +989,9 @@ public class SOL004MetaDirectoryValidatorTest { handler.addFile(nonManoSoftwareInformationPath, getResourceBytesOrFail("validation.files/invalid.yaml")); manifestBuilder.withNonManoArtifact(ONAP_SW_INFORMATION.getType(), nonManoSoftwareInformationPath); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString() + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString() .getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -1013,9 +1017,9 @@ public class SOL004MetaDirectoryValidatorTest { handler.addFile(nonManoSoftwareInformationPath, getResourceBytesOrFail("validation.files/non-mano/pnf-sw-information-invalid.yaml")); manifestBuilder.withNonManoArtifact(ONAP_SW_INFORMATION.getType(), nonManoSoftwareInformationPath); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString() + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString() .getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -1045,9 +1049,9 @@ public class SOL004MetaDirectoryValidatorTest { handler.addFile(nonManoSoftwareInformation2Path, getResourceBytesOrFail("validation.files/non-mano/pnf-sw-information-valid.yaml")); manifestBuilder.withNonManoArtifact(ONAP_SW_INFORMATION.getType(), nonManoSoftwareInformation2Path); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileBuilder.toString() + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString() .getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH)); manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -1088,9 +1092,9 @@ public class SOL004MetaDirectoryValidatorTest { metaFileBuilder.append(ETSI_ENTRY_CERTIFICATE.getName()) .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(fakeCertificatePath).append("\n"); - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8)); - manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName()); + manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME); manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH); handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8)); 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 822b573886..f2dde27365 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 @@ -29,7 +29,7 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; +import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_CHANGELOG_FILEPATH; 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; @@ -60,7 +60,7 @@ public class ValidatorFactoryTest { @Test(expected = IOException.class) public void testGivenEmptyMetaFile_thenIOExceptionIsThrown() throws IOException{ - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), "".getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -70,7 +70,7 @@ public class ValidatorFactoryTest { @Test public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException { - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), " ".getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, " ".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -83,7 +83,7 @@ public class ValidatorFactoryTest { 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)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); assertEquals(ONAPCsarValidator.class, ValidatorFactory.getValidator(handler).getClass()); } @@ -94,7 +94,7 @@ public class ValidatorFactoryTest { 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)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); assertEquals(SOL004MetaDirectoryValidator.class, ValidatorFactory.getValidator(handler).getClass()); } @@ -102,7 +102,7 @@ public class ValidatorFactoryTest { @Test public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned() throws IOException { - handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), + handler.addFile(TOSCA_META_PATH_FILE_NAME, getResourceBytesOrFail("validation.files/metafile/metaFileWithMultipleBlocks.meta")); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); |