aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-02-24 11:35:00 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-15 12:50:17 +0000
commit76a64f2171e27ce33b38d693934ad95374194517 (patch)
tree3c6d0dc015567c80ee0462aee1bdefea5b706d66 /openecomp-be
parent09d8789c2439fe12f86d0eb301216faca7d9c6b7 (diff)
Allow other entries for SOL004 Tosca.meta
Besides the mandatory entries, any other entry will be accepted in the TOSCA.meta file, as far as it has a valid format <name>: <value>. Change-Id: I941a62dbb43167e7e0424deae11a2664e61c8a6c Issue-ID: SDC-2781 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java162
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java6
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java20
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetadataFileInfo.java31
10 files changed, 149 insertions, 122 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));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java
index 671c3be0a8..1281d611cb 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java
@@ -27,7 +27,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FI
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_PATH_FILE_NAME;
+import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
import java.io.IOException;
import java.io.InputStream;
@@ -203,7 +203,7 @@ public class ETSIServiceImpl implements ETSIService {
}
private boolean isMetaFilePresent(Map<String, byte[]> handler) {
- return handler.containsKey(TOSCA_META_PATH_FILE_NAME.getName()) || handler.containsKey(TOSCA_META_ORIG_PATH_FILE_NAME);
+ return handler.containsKey(TOSCA_META_PATH_FILE_NAME) || handler.containsKey(TOSCA_META_ORIG_PATH_FILE_NAME);
}
public ResourceTypeEnum getResourceType(FileContentHandler handler) throws IOException {
@@ -245,9 +245,9 @@ public class ETSIServiceImpl implements ETSIService {
private ToscaMetadata getMetadata(FileContentHandler handler) throws IOException {
ToscaMetadata metadata;
- if (handler.containsFile(TOSCA_META_PATH_FILE_NAME.getName())) {
+ if (handler.containsFile(TOSCA_META_PATH_FILE_NAME)) {
metadata = OnboardingToscaMetadata
- .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME.getName()));
+ .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
} else if (handler.containsFile(TOSCA_META_ORIG_PATH_FILE_NAME)) {
metadata = OnboardingToscaMetadata
.parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME));
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
index b7ba56ee5a..6619a4c580 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
@@ -32,7 +32,7 @@ import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_S
import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX_IMPORT_FILE;
import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.ONAP_INDEX_IMPORT_FILE;
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.File;
import java.util.ArrayList;
@@ -68,7 +68,7 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
ServiceTemplateReaderService readerService);
protected void handleMetadataFile(Map<String, byte[]> csarFiles) {
- byte[] bytes = csarFiles.remove(TOSCA_META_PATH_FILE_NAME.getName());
+ byte[] bytes = csarFiles.remove(TOSCA_META_PATH_FILE_NAME);
if (bytes != null) {
csarFiles.put(TOSCA_META_ORIG_PATH_FILE_NAME, bytes);
}
@@ -246,7 +246,7 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
}
protected boolean isMetadataFile(String fileName) {
- return fileName.equals(TOSCA_META_PATH_FILE_NAME.getName());
+ return fileName.equals(TOSCA_META_PATH_FILE_NAME);
}
protected boolean isGlobalServiceTemplate(String fileName) {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
index 4be9379c1e..6349963841 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
@@ -24,7 +24,7 @@ package org.openecomp.core.impl;
import static org.openecomp.core.converter.datatypes.Constants.globalStName;
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.util.HashMap;
@@ -96,7 +96,7 @@ public abstract class AbstractToscaSolConverter extends AbstractToscaConverter {
private String getMainServiceDefinitionFileName(FileContentHandler contentHandler) throws IOException {
try {
ToscaMetadata toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(
- contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME.getName()));
+ contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
return toscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName());
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java
index 56dabc5dc2..c6ae0d1843 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetaEntry.java
@@ -21,31 +21,27 @@ package org.openecomp.sdc.tosca.csar;
import java.util.Arrays;
import java.util.Optional;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+/**
+ * Represents entry keys in a TOSCA.meta file.
+ */
+@AllArgsConstructor
+@Getter
public enum ToscaMetaEntry {
- TOSCA_META_PATH_FILE_NAME("TOSCA-Metadata/TOSCA.meta"),
TOSCA_META_FILE_VERSION_ENTRY("TOSCA-Meta-File-Version"),
CSAR_VERSION_ENTRY("CSAR-Version"),
CREATED_BY_ENTRY("Created-By"),
ENTRY_DEFINITIONS("Entry-Definitions"),
- ENTRY_EVENTS("Entry-Events"),
ETSI_ENTRY_MANIFEST("ETSI-Entry-Manifest"),
ETSI_ENTRY_CHANGE_LOG("ETSI-Entry-Change-Log"),
ETSI_ENTRY_TESTS("ETSI-Entry-Tests"),
ETSI_ENTRY_LICENSES("ETSI-Entry-Licenses"),
- ETSI_ENTRY_CERTIFICATE("ETSI-Entry-Certificate"),
- TOSCA_META_FILE_VERSION("1.0");
+ ETSI_ENTRY_CERTIFICATE("ETSI-Entry-Certificate");
private final String name;
- ToscaMetaEntry(final String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
public static Optional<ToscaMetaEntry> parse(final String name) {
return Arrays.stream(values()).filter(toscaMetaEntry -> toscaMetaEntry.getName().equals(name)).findFirst();
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetadataFileInfo.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetadataFileInfo.java
new file mode 100644
index 0000000000..9d2a95f992
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/ToscaMetadataFileInfo.java
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.tosca.csar;
+
+public class ToscaMetadataFileInfo {
+
+ public static final String TOSCA_META_PATH_FILE_NAME = "TOSCA-Metadata/TOSCA.meta";
+ public static final String TOSCA_META_FILE_VERSION_1_0 = "1.0";
+
+ private ToscaMetadataFileInfo() {
+
+ }
+
+}