summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java68
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidatorTest.java29
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java340
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java57
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-invalid.yaml7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-valid.yaml8
-rw-r--r--openecomp-be/lib/openecomp-common-lib/pom.xml129
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java446
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml7
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaDefinitionImportHandlerTest.java50
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java103
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java3
19 files changed, 739 insertions, 584 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml
index 8fb6a74140..5cafdf57dc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml
@@ -225,6 +225,13 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.be</groupId>
+ <artifactId>common-be</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<properties>
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
index 16f12bb44d..94638a5876 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
@@ -117,7 +117,7 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
originalOnboardPackage.getFileExtension(),
originalOnboardPackage.getFileContent()));
} catch (final Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ logger.error(getErrorWithParameters(Messages.FILE_LOAD_CONTENT_ERROR.getErrorMessage(),
getHandlerType().toString()), exception);
uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
index 056f1a4478..3e54260e8b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
@@ -63,7 +63,7 @@ public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHa
candidateService
.updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), candidateData);
} catch (final Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ logger.error(getErrorWithParameters(Messages.FILE_LOAD_CONTENT_ERROR.getErrorMessage(),
getHandlerType().toString()), exception);
uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
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 b0b8971e71..8a297142b6 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
@@ -22,6 +22,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY;
+import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_SW_INFORMATION;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS;
import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_0;
import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_1;
@@ -56,6 +57,9 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.openecomp.core.impl.ToscaDefinitionImportHandler;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.be.config.NonManoArtifactType;
+import org.openecomp.sdc.be.csar.pnf.PnfSoftwareInformation;
+import org.openecomp.sdc.be.csar.pnf.SoftwareInformationArtifactYamlParser;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.SdcCommon;
@@ -86,11 +90,20 @@ class SOL004MetaDirectoryValidator implements Validator {
private static final String MANIFEST_SOURCE = "Source";
private static final String MANIFEST_NON_MANO_SOURCE = "Non-MANO Source";
private final List<ErrorMessage> errorsByFile = new CopyOnWriteArrayList<>();
- private final SecurityManager securityManager = SecurityManager.getInstance();
+ private final SecurityManager securityManager;
private OnboardingPackageContentHandler contentHandler;
private Set<String> folderList;
private ToscaMetadata toscaMetadata;
+ public SOL004MetaDirectoryValidator() {
+ securityManager = SecurityManager.getInstance();
+ }
+
+ //for tests purpose
+ SOL004MetaDirectoryValidator(final SecurityManager securityManager) {
+ this.securityManager = securityManager;
+ }
+
@Override
public Map<String, List<ErrorMessage>> validateContent(final FileContentHandler fileContentHandler) {
this.contentHandler = (OnboardingPackageContentHandler) fileContentHandler;
@@ -369,8 +382,11 @@ class SOL004MetaDirectoryValidator implements Validator {
nonManoArtifacts.forEach((nonManoType, files) -> {
final List<String> internalNonManoFileList = filterSources(files);
nonManoValidFilePaths.addAll(internalNonManoFileList);
- if (ONAP_PM_DICTIONARY.getType().equals(nonManoType) || ONAP_VES_EVENTS.getType().equals(nonManoType)) {
+ final NonManoArtifactType nonManoArtifactType = NonManoArtifactType.parse(nonManoType).orElse(null);
+ if (nonManoArtifactType == ONAP_PM_DICTIONARY || nonManoArtifactType == ONAP_VES_EVENTS) {
internalNonManoFileList.forEach(this::validateYaml);
+ } else if (nonManoArtifactType == ONAP_SW_INFORMATION) {
+ validateSoftwareInformationNonManoArtifact(files);
}
});
@@ -382,6 +398,35 @@ class SOL004MetaDirectoryValidator implements Validator {
verifyFilesBeingReferred(allReferredFiles, packageFiles);
}
+ private void validateSoftwareInformationNonManoArtifact(final List<String> files) {
+ if (CollectionUtils.isEmpty(files)) {
+ reportError(ErrorLevel.ERROR, Messages.EMPTY_SW_INFORMATION_NON_MANO_ERROR.getErrorMessage());
+ return;
+ }
+ if (files.size() != 1) {
+ final String formattedFileList = files.stream()
+ .map(filePath -> String.format("'%s'", filePath))
+ .collect(Collectors.joining(", "));
+ reportError(ErrorLevel.ERROR,
+ Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(formattedFileList));
+ return;
+ }
+ final String swInformationFilePath = files.get(0);
+ final byte[] swInformationYaml = contentHandler.getFileContent(swInformationFilePath);
+ final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser
+ .parse(swInformationYaml);
+ if(!parsedYaml.isPresent()) {
+ reportError(ErrorLevel.ERROR,
+ Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
+ } else {
+ final PnfSoftwareInformation pnfSoftwareInformation = parsedYaml.get();
+ if (!pnfSoftwareInformation.isValid()) {
+ reportError(ErrorLevel.ERROR,
+ Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
+ }
+ }
+ }
+
/**
* Validates if a YAML file has the correct extension, is not empty and the content is a valid YAML. Reports each
* error found.
@@ -398,15 +443,20 @@ class SOL004MetaDirectoryValidator implements Validator {
return;
}
- final InputStream fileContent = contentHandler.getFileContentAsStream(filePath);
- if (fileContent == null) {
- reportError(ErrorLevel.ERROR, Messages.EMPTY_YAML_FILE_1.formatMessage(filePath));
- return;
- }
- try {
+ try (final InputStream fileContent = contentHandler.getFileContentAsStream(filePath)) {
+ if (fileContent == null) {
+ reportError(ErrorLevel.ERROR, Messages.EMPTY_YAML_FILE_1.formatMessage(filePath));
+ return;
+ }
new Yaml().loadAll(fileContent).iterator().next();
+ } catch (final IOException e) {
+ final String errorMsg = Messages.FILE_LOAD_CONTENT_ERROR.formatMessage(filePath);
+ reportError(ErrorLevel.ERROR, errorMsg);
+ LOGGER.debug(errorMsg, e);
} catch (final Exception e) {
- reportError(ErrorLevel.ERROR, Messages.INVALID_YAML_FORMAT_1.formatMessage(filePath, e.getMessage()));
+ final String message = Messages.INVALID_YAML_FORMAT_1.formatMessage(filePath, e.getMessage());
+ LOGGER.debug(message, e);
+ reportError(ErrorLevel.ERROR, message);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidatorTest.java
index 3ba50afea5..15a7d6c9f9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidatorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidatorTest.java
@@ -20,16 +20,17 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
+import static org.junit.Assert.assertEquals;
+import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
public class ONAPCsarValidatorTest {
@@ -41,9 +42,12 @@ public class ONAPCsarValidatorTest {
public void setUp() throws IOException{
onapCsarValidator = new ONAPCsarValidator();
contentHandler = new FileContentHandler();
- contentHandler.addFile("TOSCA-Metadata/TOSCA.meta", ValidatorUtil.getFileResource("/validation.files/metafile/nonSOL004WithMetaDirectoryCompliantMetaFile.meta"));
- contentHandler.addFile("MainServiceTemplate.mf", ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf"));
- contentHandler.addFile(TestConstants.TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(TestConstants.SAMPLE_DEFINITION_FILE_PATH));
+ contentHandler.addFile("TOSCA-Metadata/TOSCA.meta",
+ getResourceBytesOrFail("validation.files/metafile/nonSOL004WithMetaDirectoryCompliantMetaFile.meta"));
+ contentHandler
+ .addFile("MainServiceTemplate.mf", getResourceBytesOrFail("validation.files/manifest/sampleManifest.mf"));
+ contentHandler.addFile(TestConstants.TOSCA_DEFINITION_FILEPATH,
+ getResourceBytesOrFail(TestConstants.SAMPLE_DEFINITION_FILE_PATH));
}
@Test
@@ -55,9 +59,12 @@ public class ONAPCsarValidatorTest {
@Test
public void testGivenCSARPackage_withInvalidManifestFile_thenErrorsReturned() throws IOException{
contentHandler = new FileContentHandler();
- contentHandler.addFile("TOSCA-Metadata/TOSCA.meta", ValidatorUtil.getFileResource("/validation.files/metafile/nonSOL004WithMetaDirectoryCompliantMetaFile.meta"));
- contentHandler.addFile("MainServiceTemplate.mf", ValidatorUtil.getFileResource("/validation.files/manifest/invalidManifest.mf"));
- contentHandler.addFile(TestConstants.TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(TestConstants.SAMPLE_DEFINITION_FILE_PATH));
+ contentHandler.addFile("TOSCA-Metadata/TOSCA.meta",
+ getResourceBytesOrFail("validation.files/metafile/nonSOL004WithMetaDirectoryCompliantMetaFile.meta"));
+ contentHandler
+ .addFile("MainServiceTemplate.mf", getResourceBytesOrFail("validation.files/manifest/invalidManifest.mf"));
+ contentHandler.addFile(TestConstants.TOSCA_DEFINITION_FILEPATH,
+ getResourceBytesOrFail(TestConstants.SAMPLE_DEFINITION_FILE_PATH));
assertExpectedErrors("CSAR package with invalid manifest file should have errors", onapCsarValidator.validateContent(contentHandler), 1);
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 fc05b5ba7b..8bbf9c0cda 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
@@ -27,9 +27,13 @@ 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.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY;
+import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_SW_INFORMATION;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS;
+import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_ARCHIVE_VERSION;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_NAME;
@@ -42,6 +46,7 @@ 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;
@@ -57,12 +62,13 @@ import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.va
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_DEFINITION_FILEPATH;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_MANIFEST_FILEPATH;
-import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Before;
import org.junit.Test;
@@ -70,16 +76,14 @@ import org.openecomp.sdc.common.errors.Messages;
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.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
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;
public class SOL004MetaDirectoryValidatorTest {
- private static final Logger LOGGER = LoggerFactory.getLogger(SOL004MetaDirectoryValidatorTest.class);
-
private SOL004MetaDirectoryValidator sol004MetaDirectoryValidator;
private OnboardingPackageContentHandler handler;
private StringBuilder metaFileBuilder;
@@ -96,20 +100,20 @@ public class SOL004MetaDirectoryValidatorTest {
.append(CREATED_BY_ENTRY.getName())
.append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Vendor").append("\n")
.append(ENTRY_DEFINITIONS.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.yaml").append("\n")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_DEFINITION_FILEPATH).append("\n")
.append(ETSI_ENTRY_MANIFEST.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.mf").append("\n")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_MANIFEST_FILEPATH).append("\n")
.append(ETSI_ENTRY_CHANGE_LOG.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Artifacts/changeLog.text").append("\n");
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_CHANGELOG_FILEPATH).append("\n");
}
@Test
public void testGivenTOSCAMetaFile_whenEntryHasNoValue_thenErrorIsReturned() {
final String metaFileWithInvalidEntry = "TOSCA-Meta-File-Version: \n" +
- "Entry-Definitions: Definitions/MainServiceTemplate.yaml";
+ "Entry-Definitions: " + TOSCA_DEFINITION_FILEPATH;
handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8));
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler);
assertExpectedErrors("TOSCA Meta file with no entries", errors, 1);
@@ -130,7 +134,7 @@ public class SOL004MetaDirectoryValidatorTest {
.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_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(SAMPLE_SOURCE, "".getBytes());
@@ -180,17 +184,17 @@ public class SOL004MetaDirectoryValidatorTest {
.append(CREATED_BY_ENTRY.getName())
.append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Vendor").append("\n")
.append(ENTRY_DEFINITIONS.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.yaml").append("\n")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_DEFINITION_FILEPATH).append("\n")
.append(ETSI_ENTRY_MANIFEST.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.mf").append("\n")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_MANIFEST_FILEPATH).append("\n")
.append(ETSI_ENTRY_CHANGE_LOG.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Artifacts/changeLog.text");
+ .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_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
@@ -227,11 +231,12 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(SAMPLE_SOURCE, "".getBytes());
manifestBuilder.withSource(SAMPLE_SOURCE);
- handler.addFile("Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml", getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile("Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml",
+ getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource("Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml");
- final String definitionFileWithValidImports = "/validation.files/definition/definitionFileWithValidImports.yaml";
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(definitionFileWithValidImports));
+ final String definitionFileWithValidImports = "validation.files/definition/definitionFileWithValidImports.yaml";
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(definitionFileWithValidImports));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -254,15 +259,18 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(SAMPLE_SOURCE, "".getBytes());
manifestBuilder.withSource(SAMPLE_SOURCE);
- final byte [] sampleDefinitionFile1 = getResourceBytes("/validation.files/definition/sampleDefinitionFile1.yaml");
+ final byte [] sampleDefinitionFile1 =
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile1.yaml");
handler.addFile(TOSCA_DEFINITION_FILEPATH, sampleDefinitionFile1);
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
- final byte [] sampleDefinitionFile2 = getResourceBytes("/validation.files/definition/sampleDefinitionFile2.yaml");
+ final byte [] sampleDefinitionFile2 =
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml");
handler.addFile("Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml", sampleDefinitionFile2);
manifestBuilder.withSource("Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml");
- final byte [] sampleDefinitionFile3 = getResourceBytes("/validation.files/definition/sampleDefinitionFile1.yaml");
+ final byte [] sampleDefinitionFile3 =
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile1.yaml");
handler.addFile("Definitions/etsi_nfv_sol001_pnfd_2_5_2_types.yaml", sampleDefinitionFile3);
manifestBuilder.withSource("Definitions/etsi_nfv_sol001_pnfd_2_5_2_types.yaml");
@@ -286,8 +294,9 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(SAMPLE_SOURCE, "".getBytes());
manifestBuilder.withSource(SAMPLE_SOURCE);
- final String definitionFileWithInvalidImports = "/validation.files/definition/definitionFileWithInvalidImport.yaml";
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(definitionFileWithInvalidImports));
+ final String definitionFileWithInvalidImports =
+ "validation.files/definition/definitionFileWithInvalidImport.yaml";
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(definitionFileWithInvalidImports));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -318,7 +327,8 @@ public class SOL004MetaDirectoryValidatorTest {
manifestBuilder.withSource("Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml");
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes("/validation.files/definition/sampleDefinitionFile2.yaml"));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH,
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml"));
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
@@ -343,8 +353,8 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(SAMPLE_SOURCE, "".getBytes());
manifestBuilder.withSource(SAMPLE_SOURCE);
- final String definitionFileWithInvalidYAML = "/validation.files/definition/invalidDefinitionFile.yaml";
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(definitionFileWithInvalidYAML));
+ final String definitionFileWithInvalidYAML = "validation.files/definition/invalidDefinitionFile.yaml";
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(definitionFileWithInvalidYAML));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -364,17 +374,17 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(SAMPLE_SOURCE, "".getBytes());
manifestBuilder.withSource(SAMPLE_SOURCE);
- handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(SAMPLE_DEFINITION_IMPORT_FILE_PATH);
final String nonManoSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(nonManoSource, getResourceBytes("/validation.files/measurements/pmEvents-valid.yaml"));
+ handler.addFile(nonManoSource, getResourceBytesOrFail("validation.files/measurements/pmEvents-valid.yaml"));
manifestBuilder.withNonManoArtifact(ONAP_PM_DICTIONARY.getType(), nonManoSource);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -399,14 +409,14 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, "".getBytes());
manifestBuilder.withSource(SAMPLE_DEFINITION_IMPORT_FILE_PATH);
String nonManoSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(nonManoSource, getResourceBytes("/validation.files/measurements/pmEvents-valid.yaml"));
+ handler.addFile(nonManoSource, getResourceBytesOrFail("validation.files/measurements/pmEvents-valid.yaml"));
manifestBuilder.withNonManoArtifact(ONAP_PM_DICTIONARY.getType(), nonManoSource);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -422,9 +432,9 @@ 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_MANIFEST_FILEPATH, getResourceBytes("/validation.files/manifest/invalidManifest.mf"));
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, getResourceBytesOrFail("validation.files/manifest/invalidManifest.mf"));
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, "".getBytes());
final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler);
@@ -441,7 +451,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, "".getBytes());
@@ -467,11 +477,11 @@ public class SOL004MetaDirectoryValidatorTest {
.append(CREATED_BY_ENTRY.getName())
.append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Vendor").append("\n")
.append(ENTRY_DEFINITIONS.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.yaml\n")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_DEFINITION_FILEPATH).append("\n")
.append(ETSI_ENTRY_MANIFEST.getName())
.append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate2.mf\n")
.append(ETSI_ENTRY_CHANGE_LOG.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Artifacts/changeLog.text\n");
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_CHANGELOG_FILEPATH).append("\n");
final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder();
@@ -481,7 +491,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, "".getBytes());
@@ -505,11 +515,11 @@ public class SOL004MetaDirectoryValidatorTest {
.append(CREATED_BY_ENTRY.getName())
.append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Vendor").append("\n")
.append(ENTRY_DEFINITIONS.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.yaml\n")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_DEFINITION_FILEPATH).append("\n")
.append(ETSI_ENTRY_MANIFEST.getName())
.append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Definitions/MainServiceTemplate.txt\n")
.append(ETSI_ENTRY_CHANGE_LOG.getName())
- .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Artifacts/changeLog.text\n");
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(TOSCA_CHANGELOG_FILEPATH).append("\n");
final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder();
@@ -519,7 +529,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(SAMPLE_DEFINITION_IMPORT_FILE_PATH, "".getBytes());
@@ -541,7 +551,7 @@ public class SOL004MetaDirectoryValidatorTest {
manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -563,7 +573,7 @@ public class SOL004MetaDirectoryValidatorTest {
manifestBuilder.withSignedSource(TOSCA_DEFINITION_FILEPATH
, "SHA-abc", "09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943");
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
@@ -587,7 +597,7 @@ public class SOL004MetaDirectoryValidatorTest {
manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -612,7 +622,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -635,7 +645,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -658,7 +668,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -686,7 +696,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -711,7 +721,7 @@ public class SOL004MetaDirectoryValidatorTest {
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes());
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -738,11 +748,12 @@ public class SOL004MetaDirectoryValidatorTest {
manifestBuilder.withSource(SAMPLE_SOURCE);
final String definitionImportOne = "Definitions/importOne.yaml";
- handler.addFile(definitionImportOne, getResourceBytes("/validation.files/definition/sampleDefinitionFile2.yaml"));
+ handler.addFile(definitionImportOne,
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml"));
manifestBuilder.withSource(definitionImportOne);
- final String definitionFileWithValidImports = "/validation.files/definition/definitionFileWithOneImport.yaml";
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(definitionFileWithValidImports));
+ final String definitionFileWithValidImports = "validation.files/definition/definitionFileWithOneImport.yaml";
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(definitionFileWithValidImports));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -775,11 +786,12 @@ public class SOL004MetaDirectoryValidatorTest {
manifestBuilder.withSource(SAMPLE_SOURCE);
final String definitionImportOne = "Definitions/importOne.yaml";
- handler.addFile(definitionImportOne, getResourceBytes("/validation.files/definition/definitionFileWithInvalidImport.yaml"));
+ handler.addFile(definitionImportOne,
+ getResourceBytesOrFail("validation.files/definition/definitionFileWithInvalidImport.yaml"));
manifestBuilder.withSource(definitionImportOne);
- final String definitionFileWithValidImports = "/validation.files/definition/definitionFileWithOneImport.yaml";
- handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytes(definitionFileWithValidImports));
+ final String definitionFileWithValidImports = "validation.files/definition/definitionFileWithOneImport.yaml";
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(definitionFileWithValidImports));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -802,18 +814,20 @@ public class SOL004MetaDirectoryValidatorTest {
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_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
final String nonManoPmEventsSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(nonManoPmEventsSource, getResourceBytes("/validation.files/measurements/pmEvents-valid.yaml"));
+ handler.addFile(nonManoPmEventsSource,
+ getResourceBytesOrFail("validation.files/measurements/pmEvents-valid.yaml"));
manifestBuilder.withNonManoArtifact(ONAP_PM_DICTIONARY.getType(), nonManoPmEventsSource);
final String nonManoVesEventsSource = "Artifacts/Deployment/Events/ves_events.yaml";
- handler.addFile(nonManoVesEventsSource, getResourceBytes("/validation.files/events/vesEvents-valid.yaml"));
+ handler.addFile(nonManoVesEventsSource,
+ getResourceBytesOrFail("validation.files/events/vesEvents-valid.yaml"));
manifestBuilder.withNonManoArtifact(ONAP_VES_EVENTS.getType(), nonManoVesEventsSource);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -832,14 +846,14 @@ public class SOL004MetaDirectoryValidatorTest {
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_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
final String nonManoPmEventsSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(nonManoPmEventsSource, getResourceBytes(INVALID_YAML_FILE_PATH));
+ handler.addFile(nonManoPmEventsSource, getResourceBytesOrFail(INVALID_YAML_FILE_PATH));
manifestBuilder.withNonManoArtifact(ONAP_PM_DICTIONARY.getType(), nonManoPmEventsSource);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -870,18 +884,18 @@ public class SOL004MetaDirectoryValidatorTest {
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_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
final String nonManoPmEventsSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml";
- handler.addFile(nonManoPmEventsSource, getResourceBytes(EMPTY_YAML_FILE_PATH));
+ handler.addFile(nonManoPmEventsSource, getResourceBytesOrFail(EMPTY_YAML_FILE_PATH));
manifestBuilder.withNonManoArtifact(ONAP_PM_DICTIONARY.getType(), nonManoPmEventsSource);
final String nonManoVesEventsSource = "Artifacts/Deployment/Events/ves_events.yaml";
- handler.addFile(nonManoVesEventsSource, getResourceBytes(EMPTY_YAML_FILE_PATH));
+ handler.addFile(nonManoVesEventsSource, getResourceBytesOrFail(EMPTY_YAML_FILE_PATH));
manifestBuilder.withNonManoArtifact(ONAP_VES_EVENTS.getType(), nonManoVesEventsSource);
manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
@@ -908,7 +922,7 @@ public class SOL004MetaDirectoryValidatorTest {
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_DEFINITION_FILEPATH, getResourceBytes(SAMPLE_DEFINITION_FILE_PATH));
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
@@ -939,6 +953,192 @@ public class SOL004MetaDirectoryValidatorTest {
assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList);
}
+ @Test
+ public void givenPackageWithValidSoftwareInformationNonMano_whenThePackageIsValidated_thenNoErrorsAreReturned() {
+ //given a package with software information non-mano artifact
+ final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder();
+ final String nonManoSoftwareInformationPath = "Artifacts/software-information/pnf-sw-information-valid.yaml";
+ 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()
+ .getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+
+ manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+ //when package is validated
+ final Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+ //then no errors
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), Collections.emptyList());
+ }
+
+ @Test
+ public void givenPackageWithUnparsableSwInformationNonMano_whenThePackageIsValidated_thenInvalidErrorIsReturned() {
+ //given a package with unparsable software information non-mano artifact
+ final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder();
+ final String nonManoSoftwareInformationPath = "Artifacts/software-information/pnf-sw-information-valid.yaml";
+ 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()
+ .getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+
+ manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+ //when package is validated
+ final Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+ //then invalid error returned
+ final List<ErrorMessage> expectedErrorList = new ArrayList<>();
+ expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR
+ , Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(nonManoSoftwareInformationPath))
+ );
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList);
+ }
+
+ @Test
+ public void givenPackageWithIncorrectSwInformationNonMano_whenThePackageIsValidated_thenInvalidErrorIsReturned() {
+ //given a package with incorrect software information non-mano artifact
+ final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder();
+ final String nonManoSoftwareInformationPath = "Artifacts/software-information/pnf-sw-information-invalid.yaml";
+ 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()
+ .getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+
+ manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+ //when package is validated
+ final Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+ //then incorrect error returned
+ final List<ErrorMessage> expectedErrorList = new ArrayList<>();
+ expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR
+ , Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(nonManoSoftwareInformationPath))
+ );
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList);
+ }
+
+ @Test
+ public void givenPackageWithTwoSoftwareInformationNonMano_whenThePackageIsValidated_thenUniqueErrorIsReturned() {
+ //given a package with two software information non-mano artifacts
+ final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder();
+ final String nonManoSoftwareInformation1Path = "Artifacts/software-information/pnf-sw-information-valid1.yaml";
+ handler.addFile(nonManoSoftwareInformation1Path,
+ getResourceBytesOrFail("validation.files/non-mano/pnf-sw-information-valid.yaml"));
+ manifestBuilder.withNonManoArtifact(ONAP_SW_INFORMATION.getType(), nonManoSoftwareInformation1Path);
+ final String nonManoSoftwareInformation2Path = "Artifacts/software-information/pnf-sw-information-valid2.yaml";
+ 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()
+ .getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+
+ manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+ //when package is validated
+ final Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+ //then unique error returned
+ final List<ErrorMessage> expectedErrorList = new ArrayList<>();
+ final String errorFiles = Stream.of(nonManoSoftwareInformation1Path, nonManoSoftwareInformation2Path)
+ .map(s -> String.format("'%s'", s))
+ .collect(Collectors.joining(", "));
+ expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR
+ , Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(errorFiles))
+ );
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList);
+ }
+
+ @Test
+ public void signedPackage() throws SecurityManagerException {
+ //given
+ final ManifestBuilder manifestBuilder = getPnfManifestSampleBuilder();
+ final String fakeArtifactPath = "Artifacts/aArtifact.yaml";
+ final String fakeArtifactCmsPath = "Artifacts/aArtifact.cms";
+ final String fakeCertificatePath = "certificate.cert";
+ handler.addFile(fakeArtifactPath, new byte[0]);
+ manifestBuilder.withSource(fakeArtifactPath);
+ handler.addFile(fakeArtifactCmsPath, new byte[0]);
+ manifestBuilder.withSource(fakeArtifactCmsPath);
+ handler.addFile(fakeCertificatePath, new byte[0]);
+ manifestBuilder.withSource(fakeCertificatePath);
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+ handler.addFile(TOSCA_DEFINITION_FILEPATH, getResourceBytesOrFail(SAMPLE_DEFINITION_FILE_PATH));
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+
+ metaFileBuilder.append(ETSI_ENTRY_CERTIFICATE.getName())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" ").append(fakeCertificatePath).append("\n");
+ handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(),
+ metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME.getName());
+
+ manifestBuilder.withSource(TOSCA_MANIFEST_FILEPATH);
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+
+ final SecurityManager securityManagerMock = mock(SecurityManager.class);
+ when(securityManagerMock.verifySignedData(any(), any(), any())).thenReturn(true);
+ sol004MetaDirectoryValidator = new SOL004MetaDirectoryValidator(securityManagerMock);
+
+ //when
+ Map<String, List<ErrorMessage>> actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+ //then
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), Collections.emptyList());
+
+ //given
+ sol004MetaDirectoryValidator = new SOL004MetaDirectoryValidator(securityManagerMock);
+ when(securityManagerMock.verifySignedData(any(), any(), any())).thenReturn(false);
+
+ //when
+ actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+
+ //then
+ List<ErrorMessage> expectedErrorList = new ArrayList<>();
+ expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR
+ , Messages.ARTIFACT_INVALID_SIGNATURE.formatMessage(fakeArtifactCmsPath, fakeArtifactPath))
+ );
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList);
+
+ //given
+ sol004MetaDirectoryValidator = new SOL004MetaDirectoryValidator(securityManagerMock);
+ when(securityManagerMock.verifySignedData(any(), any(), any()))
+ .thenThrow(new SecurityManagerException("SecurityManagerException"));
+ //when
+ actualErrorMap = sol004MetaDirectoryValidator.validateContent(handler);
+
+ //then
+ expectedErrorList = new ArrayList<>();
+ expectedErrorList.add(
+ new ErrorMessage(ErrorLevel.ERROR,
+ Messages.ARTIFACT_SIGNATURE_VALIDATION_ERROR.formatMessage(fakeArtifactCmsPath,
+ fakeArtifactPath, fakeCertificatePath, "SecurityManagerException")
+ )
+ );
+ assertExpectedErrors(actualErrorMap.get(SdcCommon.UPLOAD_FILE), expectedErrorList);
+ }
+
+
+
+
private void assertExpectedErrors(final String testCase, final Map<String, List<ErrorMessage>> errors, final int expectedErrors){
final List<ErrorMessage> errorMessages = errors.get(SdcCommon.UPLOAD_FILE);
printErrorMessages(errorMessages);
@@ -957,18 +1157,6 @@ public class SOL004MetaDirectoryValidatorTest {
}
}
- private byte[] getResourceBytes(final String resourcePath) {
- try {
- return ValidatorUtil.getFileResource(resourcePath);
- } catch (final IOException e) {
- final String errorMsg = String.format("Could not load resource '%s'", resourcePath);
- LOGGER.error(errorMsg, e);
- fail(errorMsg);
- }
-
- return null;
- }
-
private ManifestBuilder getPnfManifestSampleBuilder() {
return new ManifestBuilder()
.withMetaData(PNFD_NAME.getToken(), "myPnf")
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java
index 42022fc90b..e4ff23ba91 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java
@@ -20,20 +20,22 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
-class TestConstants {
+import java.nio.file.Path;
+import java.nio.file.Paths;
+class TestConstants {
public static final String SAMPLE_DEFINITION_IMPORT_FILE_PATH = "Definitions/etsi_nfv_sol001_pnfd_2_5_1_types.yaml";
public static final String SAMPLE_SOURCE = "Artifacts/Deployment/Events/RadioNode_pnf_v1.yaml";
- public static final String SAMPLE_DEFINITION_FILE_PATH = "/validation.files/definition/sampleDefinitionFile.yaml";
- public static final String SAMPLE_MANIFEST_FILE_PATH = "/validation.files/manifest/sampleManifest.mf";
+ public static final Path SAMPLE_DEFINITION_FILE_PATH =
+ Paths.get("validation.files/definition/sampleDefinitionFile.yaml");
public static final String TOSCA_DEFINITION_FILEPATH = "Definitions/MainServiceTemplate.yaml";
public static final String TOSCA_MANIFEST_FILEPATH = "Definitions/MainServiceTemplate.mf";
public static final String TOSCA_CHANGELOG_FILEPATH = "Artifacts/changeLog.text";
- public static final String EMPTY_YAML_FILE_PATH = "/validation.files/empty.yaml";
- public static final String INVALID_YAML_FILE_PATH = "/validation.files/invalid.yaml";
+ public static final Path EMPTY_YAML_FILE_PATH = Paths.get("validation.files/empty.yaml");
+ public static final Path INVALID_YAML_FILE_PATH = Paths.get("validation.files/invalid.yaml");
- private TestConstants(){
+ private TestConstants() {
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java
index c8ca1a554b..822b573886 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java
@@ -20,13 +20,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-
import static org.junit.Assert.assertEquals;
+import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CREATED_BY_ENTRY;
import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY;
@@ -39,6 +34,12 @@ import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.va
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_DEFINITION_FILEPATH;
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_MANIFEST_FILEPATH;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.core.utilities.file.FileContentHandler;
+
public class ValidatorFactoryTest {
private String metaFile;
@@ -68,7 +69,7 @@ public class ValidatorFactoryTest {
}
@Test
- public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException{
+ public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException {
handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), " ".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
@@ -79,7 +80,7 @@ public class ValidatorFactoryTest {
@Test
- public void testGivenNonSOL004MetaDirectoryCompliantMetaFile_thenONAPCSARValidatorIsReturned() throws IOException{
+ public void testGivenNonSOL004MetaDirectoryCompliantMetaFile_thenONAPCSARValidatorIsReturned() throws IOException {
metaFile = metaFile +
ENTRY_DEFINITIONS.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_DEFINITION_FILEPATH;
handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFile.getBytes(StandardCharsets.UTF_8));
@@ -88,21 +89,21 @@ public class ValidatorFactoryTest {
}
@Test
- public void testGivenSOL004MetaDirectoryCompliantMetafile_thenONAPCsarValidatorIsReturned() throws IOException{
-
+ public void testGivenSOL004MetaDirectoryCompliantMetafile_thenONAPCsarValidatorIsReturned() throws IOException {
metaFile = metaFile +
- ENTRY_DEFINITIONS.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_DEFINITION_FILEPATH + "\n"
- + ETSI_ENTRY_MANIFEST.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_MANIFEST_FILEPATH + "\n"
- + ETSI_ENTRY_CHANGE_LOG.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_CHANGELOG_FILEPATH + "\n";
+ ENTRY_DEFINITIONS.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_DEFINITION_FILEPATH + "\n"
+ + ETSI_ENTRY_MANIFEST.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_MANIFEST_FILEPATH + "\n"
+ + ETSI_ENTRY_CHANGE_LOG.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + TOSCA_CHANGELOG_FILEPATH + "\n";
handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), metaFile.getBytes(StandardCharsets.UTF_8));
assertEquals(SOL004MetaDirectoryValidator.class, ValidatorFactory.getValidator(handler).getClass());
}
@Test
- public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned() throws IOException {
-
- handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(), ValidatorUtil.getFileResource("/validation.files/metafile/metaFileWithMultipleBlocks.meta"));
+ public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned()
+ throws IOException {
+ handler.addFile(TOSCA_META_PATH_FILE_NAME.getName(),
+ getResourceBytesOrFail("validation.files/metafile/metaFileWithMultipleBlocks.meta"));
handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes());
handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java
deleted file mode 100644
index a441868191..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
-
-import org.apache.commons.io.IOUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Provides util methods for Validation Test classes.
- */
-
-class ValidatorUtil {
-
- private ValidatorUtil() {
-
- }
-
- /**
- * Reads a file and coverts it to a byte array.
- *
- * @param filePath The file path
- * @return
- * The file byte array
- * @throws IOException
- * When the file was not found or the input stream could not be opened
- */
- public static byte[] getFileResource(final String filePath) throws IOException {
- try(final InputStream inputStream = ClassLoader.class.getResourceAsStream(filePath)) {
- if (inputStream == null) {
- throw new IOException(String.format("Could not find the resource on path \"%s\"", filePath));
- }
- return IOUtils.toByteArray(inputStream);
- } catch (final IOException ex) {
- throw new IOException(String.format("Could not open the input stream for resource on path \"%s\"", filePath), ex);
- }
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-invalid.yaml b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-invalid.yaml
new file mode 100644
index 0000000000..8b07abd897
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-invalid.yaml
@@ -0,0 +1,7 @@
+description: "pnf software information"
+provider: "Ericsson"
+version: "1.0"
+pnf_software_information:
+ - description: "first software version of PNF"
+ pnf_software_version: "5gDUv18.05.201"
+ - description: "second software version of PNF"
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-valid.yaml b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-valid.yaml
new file mode 100644
index 0000000000..60ab140843
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/non-mano/pnf-sw-information-valid.yaml
@@ -0,0 +1,8 @@
+description: "pnf software information"
+provider: "Ericsson"
+version: "1.0"
+pnf_software_information:
+ - description: "first software version of PNF"
+ pnf_software_version: "5gDUv18.05.201"
+ - description: "second software version of PNF"
+ pnf_software_version: "5gDUv18.06.205"
diff --git a/openecomp-be/lib/openecomp-common-lib/pom.xml b/openecomp-be/lib/openecomp-common-lib/pom.xml
index 71e41425fa..794796cd4b 100644
--- a/openecomp-be/lib/openecomp-common-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-common-lib/pom.xml
@@ -1,68 +1,73 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc.core</groupId>
- <name>openecomp-common-lib</name>
- <artifactId>openecomp-common-lib</artifactId>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <name>openecomp-common-lib</name>
+ <artifactId>openecomp-common-lib</artifactId>
- <parent>
- <artifactId>openecomp-sdc-lib</artifactId>
- <groupId>org.openecomp.sdc</groupId>
- <version>1.6.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <version>1.6.0-SNAPSHOT</version>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-utilities-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-datatypes-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-text</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.amdocs.zusammen</groupId>
- <artifactId>zusammen-datatypes</artifactId>
- <version>${zusammen.version}</version>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-datatypes</artifactId>
+ <version>${zusammen.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index 5e5f82862e..ea507f54e2 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -16,228 +16,232 @@
package org.openecomp.sdc.common.errors;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
public enum Messages {
- CANT_LOAD_HEALING_CLASS("Can't load healing class %s."),
-
- VERSION_UPGRADE("Item %s is of old version. A check out was made in order to get new " +
- "functionalities"),
-
- PACKAGE_PROCESS_ERROR("Could not process package '%s'"),
- PACKAGE_INVALID_EXTENSION("Invalid package '%s' extension. Expecting %s."),
- PACKAGE_EMPTY_ERROR("The given package is empty '%s'"),
- PACKAGE_PROCESS_INTERNAL_PACKAGE_ERROR("Could not process internal package '%s'"),
- PACKAGE_INVALID_ERROR("Invalid package content '%s'"),
- PACKAGE_MISSING_INTERNAL_PACKAGE("Missing expected internal package"),
- INVALID_ZIP_FILE("Invalid zip file"),
- INVALID_CSAR_FILE("Invalid csar file"),
- CSAR_FILE_NOT_FOUND("Each CSAR file must contain %s file."),
- CSAR_DIRECTORIES_NOT_ALLOWED("Directory : %s , is not allowed."),
- CSAR_FILES_NOT_ALLOWED("File : %s , are not allowed."),
- MANIFEST_INVALID_LINE("Manifest contains invalid line: %s: %s"),
- MANIFEST_START_METADATA("Manifest must starts with 'metadata:'"),
- MANIFEST_NO_METADATA("Manifest must contain metadata"),
- MANIFEST_NO_SOURCES("Manifest must contain Source"),
- MANIFEST_METADATA_MISSING_ENTRY("Manifest metadata missing entry %s"),
- MANIFEST_INVALID_NAME("Manifest file %s and TOSCA definitions file %s must have the same name"),
- MANIFEST_INVALID_EXT("Manifest file must have extension \".mf\" "),
- MANIFEST_METADATA_INVALID_ENTRY("Manifest metadata should only have pnf or vnf entries"),
- MANIFEST_METADATA_INVALID_ENTRY1("Invalid Manifest metadata entry: '%s'."),
- MANIFEST_METADATA_DUPLICATED_ENTRY("Duplicated Manifest metadata entry: '%s'."),
- MANIFEST_METADATA_UNEXPECTED_ENTRY_TYPE("Manifest metadata should have either pnf or vnf entries, not both together"),
- MANIFEST_INVALID_PNF_METADATA("%s TOSCA.meta file is applicable for VF only"),
- MANIFEST_INVALID_NON_MANO_KEY("Invalid non mano key '%s'"),
- MANIFEST_EMPTY_NON_MANO_KEY("Expecting a 'Source' entry for the non mano key '%s'"),
- MANIFEST_EMPTY_NON_MANO_SOURCE("Empty non mano source"),
- MANIFEST_EXPECTED_HASH_ENTRY("Expected Hash entry"),
- MANIFEST_EXPECTED_HASH_VALUE("Expected Hash entry value"),
- MANIFEST_EXPECTED_SOURCE_PATH("Expected Source entry path"),
- MANIFEST_EXPECTED_ALGORITHM_VALUE("Expected Algorithm entry value"),
- MANIFEST_EXPECTED_ALGORITHM_BEFORE_HASH("Expected 'Algorithm' entry before 'Hash' entry"),
- MANIFEST_SIGNATURE_DUPLICATED("Duplicated manifest signature"),
- MANIFEST_SIGNATURE_LAST_ENTRY("The manifest signature must be the last entry of the manifest."),
- MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT("Manifest metadata must only have the required number [%s] of entries"),
- MANIFEST_EMPTY("The manifest is empty"),
- MANIFEST_ERROR_WITH_LINE("%s;%nAt line %s: '%s'."),
- MANIFEST_PARSER_INTERNAL("Invalid manifest file"),
- MANIFEST_UNEXPECTED_ERROR("An unexpected error occurred while validating manifest '%s': %s"),
- METADATA_PARSER_INTERNAL("Invalid Metadata file"),
- METADATA_MISSING_OPTIONAL_FOLDERS("Missing folder %s in package"),
- METADATA_UNSUPPORTED_ENTRY("Following entry not supported in TOSCA.meta %s"),
- METADATA_INVALID_VERSION("Invalid entry %s value %s"),
- METADATA_INVALID_VALUE("Invalid value %s in TOSCA.meta file"),
- METADATA_MISSING_ENTRY("TOSCA.meta file in TOSCA-metadata directory missing entry %s"),
- METADATA_NO_ENTRY_DEFINITIONS("TOSCA.meta must contain Entry Definitions"),
- METADATA_INVALID_ENTRY_DEFINITIONS("TOSCA.meta must contain key:value entries"),
- FAILED_TO_VALIDATE_METADATA("Failed to validate metadata file"),
- ARTIFACT_INVALID_SIGNATURE("Invalid signature '%s' provided for artifact '%s'"),
- ARTIFACT_SIGNATURE_VALIDATION_ERROR(
+ CANT_LOAD_HEALING_CLASS("Can't load healing class %s."),
+
+ VERSION_UPGRADE("Item %s is of old version. A check out was made in order to get new " +
+ "functionalities"),
+
+ PACKAGE_PROCESS_ERROR("Could not process package '%s'"),
+ PACKAGE_INVALID_EXTENSION("Invalid package '%s' extension. Expecting %s."),
+ PACKAGE_EMPTY_ERROR("The given package is empty '%s'"),
+ PACKAGE_PROCESS_INTERNAL_PACKAGE_ERROR("Could not process internal package '%s'"),
+ PACKAGE_INVALID_ERROR("Invalid package content '%s'"),
+ PACKAGE_MISSING_INTERNAL_PACKAGE("Missing expected internal package"),
+ INVALID_ZIP_FILE("Invalid zip file"),
+ INVALID_CSAR_FILE("Invalid csar file"),
+ CSAR_FILE_NOT_FOUND("Each CSAR file must contain %s file."),
+ CSAR_DIRECTORIES_NOT_ALLOWED("Directory : %s , is not allowed."),
+ CSAR_FILES_NOT_ALLOWED("File : %s , are not allowed."),
+ MANIFEST_INVALID_LINE("Manifest contains invalid line: %s: %s"),
+ MANIFEST_START_METADATA("Manifest must starts with 'metadata:'"),
+ MANIFEST_NO_METADATA("Manifest must contain metadata"),
+ MANIFEST_NO_SOURCES("Manifest must contain Source"),
+ MANIFEST_METADATA_MISSING_ENTRY("Manifest metadata missing entry %s"),
+ MANIFEST_INVALID_NAME("Manifest file %s and TOSCA definitions file %s must have the same name"),
+ MANIFEST_INVALID_EXT("Manifest file must have extension \".mf\" "),
+ MANIFEST_METADATA_INVALID_ENTRY("Manifest metadata should only have pnf or vnf entries"),
+ MANIFEST_METADATA_INVALID_ENTRY1("Invalid Manifest metadata entry: '%s'."),
+ MANIFEST_METADATA_DUPLICATED_ENTRY("Duplicated Manifest metadata entry: '%s'."),
+ MANIFEST_METADATA_UNEXPECTED_ENTRY_TYPE(
+ "Manifest metadata should have either pnf or vnf entries, not both together"),
+ MANIFEST_INVALID_PNF_METADATA("%s TOSCA.meta file is applicable for VF only"),
+ MANIFEST_INVALID_NON_MANO_KEY("Invalid non mano key '%s'"),
+ MANIFEST_EMPTY_NON_MANO_KEY("Expecting a 'Source' entry for the non mano key '%s'"),
+ MANIFEST_EMPTY_NON_MANO_SOURCE("Empty non mano source"),
+ MANIFEST_EXPECTED_HASH_ENTRY("Expected Hash entry"),
+ MANIFEST_EXPECTED_HASH_VALUE("Expected Hash entry value"),
+ MANIFEST_EXPECTED_SOURCE_PATH("Expected Source entry path"),
+ MANIFEST_EXPECTED_ALGORITHM_VALUE("Expected Algorithm entry value"),
+ MANIFEST_EXPECTED_ALGORITHM_BEFORE_HASH("Expected 'Algorithm' entry before 'Hash' entry"),
+ MANIFEST_DUPLICATED_CMS_SIGNATURE("Duplicated CMS signature"),
+ MANIFEST_SIGNATURE_DUPLICATED("Duplicated manifest signature"),
+ MANIFEST_SIGNATURE_LAST_ENTRY("The manifest signature must be the last entry of the manifest."),
+ MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT("Manifest metadata must only have the required number [%s] of "
+ + "entries"),
+ MANIFEST_EMPTY("The manifest is empty"),
+ MANIFEST_ERROR_WITH_LINE("%s;%nAt line %s: '%s'."),
+ MANIFEST_PARSER_INTERNAL("Invalid manifest file"),
+ MANIFEST_UNEXPECTED_ERROR("An unexpected error occurred while validating manifest '%s': %s"),
+ METADATA_PARSER_INTERNAL("Invalid Metadata file"),
+ METADATA_MISSING_OPTIONAL_FOLDERS("Missing folder %s in package"),
+ METADATA_UNSUPPORTED_ENTRY("Following entry not supported in TOSCA.meta %s"),
+ METADATA_INVALID_VERSION("Invalid entry %s value %s"),
+ METADATA_INVALID_VALUE("Invalid value %s in TOSCA.meta file"),
+ METADATA_MISSING_ENTRY("TOSCA.meta file in TOSCA-metadata directory missing entry %s"),
+ METADATA_NO_ENTRY_DEFINITIONS("TOSCA.meta must contain Entry Definitions"),
+ METADATA_INVALID_ENTRY_DEFINITIONS("TOSCA.meta must contain key:value entries"),
+
+ EMPTY_SW_INFORMATION_NON_MANO_ERROR(
+ "Non-mano Software Information artifact was declared in the manifest, but not provided"),
+ UNIQUE_SW_INFORMATION_NON_MANO_ERROR("Only one software information non-mano artifact is allowed. "
+ + "Found %s."),
+ INVALID_SW_INFORMATION_NON_MANO_ERROR("Invalid software information non-mano artifact: '%s'"),
+ INCORRECT_SW_INFORMATION_NON_MANO_ERROR(
+ "Incorrect software information non-mano artifact. The software version information is missing "
+ + "or it has one or more incorrect software version entries: '%s'"),
+ FAILED_TO_VALIDATE_METADATA("Failed to validate metadata file"),
+ ARTIFACT_INVALID_SIGNATURE("Invalid signature '%s' provided for artifact '%s'"),
+ ARTIFACT_SIGNATURE_VALIDATION_ERROR(
"Could not validate signature '%s' provided for artifact '%s' with certificate '%s': %s"),
- FAILED_TO_TRANSLATE_ZIP_FILE("Failed to translate zip file"),
- ZIP_NOT_EXIST("Zip file doesn't exist"),
-
- PERMISSIONS_ERROR("Permissions Error. The user does not have permission to perform this action."),
- PERMISSIONS_OWNER_ERROR("Permissions Error. Only one owner is allowed."),
-
- ENTITY_NOT_FOUND("Incorrect item/version details provided."),
- SUB_ENTITY_NOT_FOUND("Incorrect sub entity details provided."),
- FAILED_TO_SYNC("Non existing version cannot be synced."),
- FAILED_TO_PUBLISH_OUT_OF_SYNC("Publish is not allowed since the version status is Out of sync"),
-
- DELETE_VSP_ERROR("VSP has been certified and cannot be deleted."),
- DELETE_VLM_ERROR("VLM has been certified and cannot be deleted."),
-
-
- ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"),
- VES_ZIP_SHOULD_CONTAIN_YML_ONLY(
- "Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" +
- " (using .yaml/.yml extensions)"),
- MANIFEST_NOT_EXIST("Manifest doesn't exist"),
- MANIFEST_NOT_FOUND("Manifest file %s referenced in TOSCA.meta does not exist"),
- FILE_TYPE_NOT_LEGAL("File type not legal as data for other file"),
- MODULE_IN_MANIFEST_NO_YAML("Module '%s', has no yaml file reference"),
- NO_MODULES_IN_MANIFEST("At least one Base/Module must be defined \n"),
- MODULE_IN_MANIFEST_VOL_ENV_NO_VOL("Module '%s', has volume Env. reference with no Volume " +
- "reference"),
- ILLEGAL_MANIFEST("Illegal Manifest"),
- NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST("no %s file was uploaded or file doesn't exist"),
- MAPPING_OBJECTS_FAILURE("Failed to map object %s to %s. Exception message: %s"),
- MORE_THEN_ONE_VOL_FOR_HEAT("heat contains more then one vol. selecting only first vol"),
- FILE_CONTENT_MAP("failed to load %s content"),
- CREATE_MANIFEST_FROM_ZIP("cannot create manifest from the attached zip file"),
- CANDIDATE_PROCESS_FAILED("Candidate zip file process failed"),
- FOUND_UNASSIGNED_FILES("cannot process zip since it has unassigned files"),
- GENERATED_ARTIFACT_IN_USE("Artifact with file name %s is generated by SDC. "
- + "Please remove this artifact from manifest and zip files"),
-
- /* Monitor uploads related errors*/
- ILLEGAL_MONITORING_ARTIFACT_TYPE("Illegal monitoring artifact type for component id %s, vsp id " +
- "%s"),
-
-
- /* manifest errors*/
- MISSING_FILE_IN_ZIP("Missing file in zip"),
- MISSING_FILE_IN_MANIFEST("Missing file in manifest"),
- MISSING_FILE_NAME_IN_MANIFEST("Missing file name in manifest"),
- MISSING_NESTED_FILE("Missing nested file - %s"),
- MISSING_ARTIFACT("Missing artifact - %s"),
- MISSING_MANIFEST_SOURCE("%s artifact %s referenced in manifest file does not exist"),
- MISSING_MANIFEST_REFERENCE("'%s' artifact is not being referenced in manifest file"),
- MISSING_METADATA_FILES("%s file referenced in TOSCA.meta does not exist"),
- WRONG_HEAT_FILE_EXTENSION("Wrong HEAT file extension - %s"),
- WRONG_ENV_FILE_EXTENSION("Wrong ENV file extension - %s"),
- INVALID_MANIFEST_FILE("invalid manifest file"),
- INVALID_FILE_TYPE("Missing or Unknown file type in Manifest"),
- ENV_NOT_ASSOCIATED_TO_HEAT("ENV file must be associated to a HEAT file"),
- CSAR_MANIFEST_FILE_NOT_EXIST("CSAR manifest file does not exist"),
- CSAR_FAILED_TO_READ("CSAR file is not readable"),
- TOSCA_PARSING_FAILURE("Invalid tosca file. Error code : %s, Error message : %s/"),
-
- /*definition errors*/
- MISSING_DEFINITION_FILE("Definition file %s referenced in TOSCA.meta does not exist"),
- MISSING_IMPORT_FILE("Package must contain the referenced import file '%s'"),
- INVALID_IMPORT_STATEMENT("Definition file '%s' contains an invalid import statement: '%s'"),
- INVALID_YAML_EXTENSION("Expecting yaml or yml extension for file: %s"),
-
-
- /* content errors*/
- INVALID_YAML_FORMAT("Invalid YAML format: %s"),
- INVALID_YAML_FORMAT_1("Invalid YAML format in file '%s'. Format error:%n%s"),
- INVALID_YAML_FORMAT_REASON("Invalid YAML format Problem - [%s]"),
- EMPTY_YAML_FILE("empty yaml"),
- EMPTY_YAML_FILE_1("The yaml file '%s' is empty"),
- GENERAL_YAML_PARSER_ERROR("general parser error"),
- GENERAL_HEAT_PARSER_ERROR("general parser error"),
- INVALID_HEAT_FORMAT_REASON("Invalid HEAT format problem - [%s]"),
- MISSING_RESOURCE_IN_DEPENDS_ON("a Missing resource in depend On, Missing Resource ID [%s]"),
- REFERENCED_PARAMETER_NOT_FOUND("Referenced parameter - %s - not found, used in resource [%s]"),
- GET_ATTR_NOT_FOUND("get_attr attribute not found, Attribute name [%s], Resource ID [%s]"),
- MISSING_PARAMETER_IN_NESTED(
- "Referenced parameter not found in nested file - %s, parameter name [%s], Resource ID [%s]"),
- NESTED_LOOP("Nested files loop - %s"),
- MORE_THAN_ONE_BIND_FROM_NOVA_TO_PORT("Resource Port %s exceed allowed relations from NovaServer"),
- SERVER_NOT_DEFINED_FROM_NOVA("Missing server group definition - %s, %s"),
- WRONG_POLICY_IN_SERVER_GROUP("Wrong policy in server group - %s"),
- MISSING_IMAGE_AND_FLAVOR("Missing both Image and Flavor in NOVA Server, Resource ID [%s]"),
- ENV_INCLUDES_PARAMETER_NOT_IN_HEAT("Env file %s includes a parameter not in HEAT - %s"),
- PARAMETER_ENV_VALUE_NOT_ALIGN_WITH_TYPE("Parameter env value %s not align with type"),
- PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE(
- "Parameter - %s default value not align with type %s"),
- INVALID_RESOURCE_TYPE("A resource has an invalid or unsupported type - %s, Resource ID [%s]"),
- ARTIFACT_FILE_NOT_REFERENCED("Artifact file is not referenced."),
- RESOURCE_NOT_IN_USE("%s not in use, Resource Id [%s]"),
- PORT_NO_BIND_TO_ANY_NOVA_SERVER("Port not bind to any NOVA Server, Resource Id [%s]"),
- INVALID_GET_RESOURCE_SYNTAX(
- "invalid get_resource syntax is in use - %s , get_resource"
- + " function should get the resource id of the referenced resource"),
- INVALID_RESOURCE_GROUP_TYPE(
- "OS::Heat::ResourceGroup resource with resource_def which is not pointing to "
- + "nested heat file is not supported, Resource ID [%s], resource_def type [%s]"),
- WRONG_VALUE_TYPE_ASSIGNED_NESTED_INPUT(
- "Wrong value type assigned to a nested input parameter, nested resource [%s],"
- + " property name [%s], nested file [%s]"),
- NOVA_NAME_IMAGE_FLAVOR_NOT_CONSISTENT(
- "Nova Server naming convention in image, flavor and name properties is not "
- + "consistent, Resource ID [%s]"),
- RESOURCE_GROUP_INVALID_INDEX_VAR(
- "Wrong value assigned to a ResourceGroup index_var property (functions are not allowed"
- + " but only strings), Resource ID [%s]"),
- CONTRAIL_2_IN_USE("Contrail 2.x deprecated resource is in use, Resource ID [%s]"),
-
- /* warnings */
- REFERENCED_RESOURCE_NOT_FOUND("Referenced resource - %s not found"),
- MISSING_GET_PARAM("Missing get_param in %s, Resource Id [%s]"),
-
- /*OPENECOMP Guide lines*/
- MISSING_NOVA_SERVER_METADATA("Missing Nova Server Metadata property, Resource ID [%s]"),
- MISSING_NOVA_SERVER_VNF_ID("Missing VNF_ID in Metadata property, Resource ID [%s]"),
- MISSING_NOVA_SERVER_VF_MODULE_ID("Missing VF_MODULE_ID in Metadata property, Resource id [%s]"),
- NETWORK_PARAM_NOT_ALIGNED_WITH_GUIDE_LINE(
- "Network Parameter Name not aligned with Guidelines, Parameter Name [%s] Resource ID [%s]"),
- MISSIN_BASE_HEAT_FILE(
- "Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources"),
- MULTI_BASE_HEAT_FILE("Multi Base HEAT. Expected only one. Files %s."),
- RESOURCE_NOT_DEFINED_IN_OUTPUT(
- "Resource is not defined as output and thus cannot be Shared, Resource ID [%s]"),
- RESOURCE_CONNECTED_TO_TWO_EXTERNAL_NETWORKS_WITH_SAME_ROLE(
- "A resource is connected twice to the same network role, Network Role [%s],"
- + " Resource ID [%s]"),
- VOLUME_HEAT_NOT_EXPOSED("Volume is not defined as output and thus cannot be attached %s"),
- FORBIDDEN_RESOURCE_IN_USE("%s is in use, Resource ID [%s]"),
- PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES(
- "%s '%s' Parameter Name not aligned with Guidelines, Parameter Name [%s], Resource ID [%s]."
- + " As a result, VF/VFC Profile may miss this information"),
- /* Contrail validator messages*/
- MERGE_OF_CONTRAIL2_AND_CONTRAIL3_RESOURCES(
- "HEAT Package includes both Contrail 2 and Contrail 3 resources. "
- + "Contrail 2 resources can be found in %s. Contrail 3 resources can be found in %s"),
- CONTRAIL_VM_TYPE_NAME_NOT_ALIGNED_WITH_NAMING_CONVENSION(
- "Service Template naming convention in Image and Flavor "
- + "properties is not consistent in Resource, Resource ID %s"),
-
- /* Notifications */
- FAILED_TO_MARK_NOTIFICATION_AS_READ("Failed to mark notifications as read"),
- FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION("Failed to update last seen notification for user %s"),
- FAILED_TO_VERIFY_SIGNATURE("Could not verify signature of signed package.");
-
- private String errorMessage;
-
- Messages(final String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * Formats the message with the given parameters.
- *
- * @param params The message string parameters to apply
- * @return
- * The formatted message.
- */
- public String formatMessage(final Object... params) {
- return String.format(errorMessage, params);
- }
+ FAILED_TO_TRANSLATE_ZIP_FILE("Failed to translate zip file"),
+ ZIP_NOT_EXIST("Zip file doesn't exist"),
+
+ PERMISSIONS_ERROR("Permissions Error. The user does not have permission to perform this action."),
+ PERMISSIONS_OWNER_ERROR("Permissions Error. Only one owner is allowed."),
+
+ ENTITY_NOT_FOUND("Incorrect item/version details provided."),
+ SUB_ENTITY_NOT_FOUND("Incorrect sub entity details provided."),
+ FAILED_TO_SYNC("Non existing version cannot be synced."),
+ FAILED_TO_PUBLISH_OUT_OF_SYNC("Publish is not allowed since the version status is Out of sync"),
+
+ DELETE_VSP_ERROR("VSP has been certified and cannot be deleted."),
+ DELETE_VLM_ERROR("VLM has been certified and cannot be deleted."),
+
+ ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"),
+ VES_ZIP_SHOULD_CONTAIN_YML_ONLY(
+ "Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" +
+ " (using .yaml/.yml extensions)"),
+ MANIFEST_NOT_EXIST("Manifest doesn't exist"),
+ MANIFEST_NOT_FOUND("Manifest file %s referenced in TOSCA.meta does not exist"),
+ FILE_TYPE_NOT_LEGAL("File type not legal as data for other file"),
+ MODULE_IN_MANIFEST_NO_YAML("Module '%s', has no yaml file reference"),
+ NO_MODULES_IN_MANIFEST("At least one Base/Module must be defined \n"),
+ MODULE_IN_MANIFEST_VOL_ENV_NO_VOL("Module '%s', has volume Env. reference with no Volume " +
+ "reference"),
+ ILLEGAL_MANIFEST("Illegal Manifest"),
+ NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST("no %s file was uploaded or file doesn't exist"),
+ MAPPING_OBJECTS_FAILURE("Failed to map object %s to %s. Exception message: %s"),
+ MORE_THEN_ONE_VOL_FOR_HEAT("heat contains more then one vol. selecting only first vol"),
+ FILE_LOAD_CONTENT_ERROR("Failed to load file '%s' content"),
+ CREATE_MANIFEST_FROM_ZIP("cannot create manifest from the attached zip file"),
+ CANDIDATE_PROCESS_FAILED("Candidate zip file process failed"),
+ FOUND_UNASSIGNED_FILES("cannot process zip since it has unassigned files"),
+ GENERATED_ARTIFACT_IN_USE("Artifact with file name %s is generated by SDC. "
+ + "Please remove this artifact from manifest and zip files"),
+
+ /* Monitor uploads related errors*/
+ ILLEGAL_MONITORING_ARTIFACT_TYPE("Illegal monitoring artifact type for component id %s, vsp id " +
+ "%s"),
+ /* manifest errors*/
+ MISSING_FILE_IN_ZIP("Missing file in zip"),
+ MISSING_FILE_IN_MANIFEST("Missing file in manifest"),
+ MISSING_FILE_NAME_IN_MANIFEST("Missing file name in manifest"),
+ MISSING_NESTED_FILE("Missing nested file - %s"),
+ MISSING_ARTIFACT("Missing artifact - %s"),
+ MISSING_MANIFEST_SOURCE("%s artifact %s referenced in manifest file does not exist"),
+ MISSING_MANIFEST_REFERENCE("'%s' artifact is not being referenced in manifest file"),
+ MISSING_METADATA_FILES("%s file referenced in TOSCA.meta does not exist"),
+ WRONG_HEAT_FILE_EXTENSION("Wrong HEAT file extension - %s"),
+ WRONG_ENV_FILE_EXTENSION("Wrong ENV file extension - %s"),
+ INVALID_MANIFEST_FILE("invalid manifest file"),
+ INVALID_FILE_TYPE("Missing or Unknown file type in Manifest"),
+ ENV_NOT_ASSOCIATED_TO_HEAT("ENV file must be associated to a HEAT file"),
+ CSAR_MANIFEST_FILE_NOT_EXIST("CSAR manifest file does not exist"),
+ CSAR_FAILED_TO_READ("CSAR file is not readable"),
+ TOSCA_PARSING_FAILURE("Invalid tosca file. Error code : %s, Error message : %s/"),
+
+ /*definition errors*/
+ MISSING_DEFINITION_FILE("Definition file %s referenced in TOSCA.meta does not exist"),
+ MISSING_IMPORT_FILE("Package must contain the referenced import file '%s'"),
+ INVALID_IMPORT_STATEMENT("Definition file '%s' contains an invalid import statement: '%s'"),
+ INVALID_YAML_EXTENSION("Expecting yaml or yml extension for file: %s"),
+
+ /* content errors*/
+ INVALID_YAML_FORMAT("Invalid YAML format: %s"),
+ INVALID_YAML_FORMAT_1("Invalid YAML format in file '%s'. Format error:%n%s"),
+ INVALID_YAML_FORMAT_REASON("Invalid YAML format Problem - [%s]"),
+ EMPTY_YAML_FILE("empty yaml"),
+ EMPTY_YAML_FILE_1("The yaml file '%s' is empty"),
+ GENERAL_YAML_PARSER_ERROR("general parser error"),
+ GENERAL_HEAT_PARSER_ERROR("general parser error"),
+ INVALID_HEAT_FORMAT_REASON("Invalid HEAT format problem - [%s]"),
+ MISSING_RESOURCE_IN_DEPENDS_ON("a Missing resource in depend On, Missing Resource ID [%s]"),
+ REFERENCED_PARAMETER_NOT_FOUND("Referenced parameter - %s - not found, used in resource [%s]"),
+ GET_ATTR_NOT_FOUND("get_attr attribute not found, Attribute name [%s], Resource ID [%s]"),
+ MISSING_PARAMETER_IN_NESTED(
+ "Referenced parameter not found in nested file - %s, parameter name [%s], Resource ID [%s]"),
+ NESTED_LOOP("Nested files loop - %s"),
+ MORE_THAN_ONE_BIND_FROM_NOVA_TO_PORT("Resource Port %s exceed allowed relations from NovaServer"),
+ SERVER_NOT_DEFINED_FROM_NOVA("Missing server group definition - %s, %s"),
+ WRONG_POLICY_IN_SERVER_GROUP("Wrong policy in server group - %s"),
+ MISSING_IMAGE_AND_FLAVOR("Missing both Image and Flavor in NOVA Server, Resource ID [%s]"),
+ ENV_INCLUDES_PARAMETER_NOT_IN_HEAT("Env file %s includes a parameter not in HEAT - %s"),
+ PARAMETER_ENV_VALUE_NOT_ALIGN_WITH_TYPE("Parameter env value %s not align with type"),
+ PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE(
+ "Parameter - %s default value not align with type %s"),
+ INVALID_RESOURCE_TYPE("A resource has an invalid or unsupported type - %s, Resource ID [%s]"),
+ ARTIFACT_FILE_NOT_REFERENCED("Artifact file is not referenced."),
+ RESOURCE_NOT_IN_USE("%s not in use, Resource Id [%s]"),
+ PORT_NO_BIND_TO_ANY_NOVA_SERVER("Port not bind to any NOVA Server, Resource Id [%s]"),
+ INVALID_GET_RESOURCE_SYNTAX(
+ "invalid get_resource syntax is in use - %s , get_resource"
+ + " function should get the resource id of the referenced resource"),
+ INVALID_RESOURCE_GROUP_TYPE(
+ "OS::Heat::ResourceGroup resource with resource_def which is not pointing to "
+ + "nested heat file is not supported, Resource ID [%s], resource_def type [%s]"),
+ WRONG_VALUE_TYPE_ASSIGNED_NESTED_INPUT(
+ "Wrong value type assigned to a nested input parameter, nested resource [%s],"
+ + " property name [%s], nested file [%s]"),
+ NOVA_NAME_IMAGE_FLAVOR_NOT_CONSISTENT(
+ "Nova Server naming convention in image, flavor and name properties is not "
+ + "consistent, Resource ID [%s]"),
+ RESOURCE_GROUP_INVALID_INDEX_VAR(
+ "Wrong value assigned to a ResourceGroup index_var property (functions are not allowed"
+ + " but only strings), Resource ID [%s]"),
+ CONTRAIL_2_IN_USE("Contrail 2.x deprecated resource is in use, Resource ID [%s]"),
+
+ /* warnings */
+ REFERENCED_RESOURCE_NOT_FOUND("Referenced resource - %s not found"),
+ MISSING_GET_PARAM("Missing get_param in %s, Resource Id [%s]"),
+
+ /*OPENECOMP Guide lines*/
+ MISSING_NOVA_SERVER_METADATA("Missing Nova Server Metadata property, Resource ID [%s]"),
+ MISSING_NOVA_SERVER_VNF_ID("Missing VNF_ID in Metadata property, Resource ID [%s]"),
+ MISSING_NOVA_SERVER_VF_MODULE_ID("Missing VF_MODULE_ID in Metadata property, Resource id [%s]"),
+ NETWORK_PARAM_NOT_ALIGNED_WITH_GUIDE_LINE(
+ "Network Parameter Name not aligned with Guidelines, Parameter Name [%s] Resource ID [%s]"),
+ MISSIN_BASE_HEAT_FILE(
+ "Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources"),
+ MULTI_BASE_HEAT_FILE("Multi Base HEAT. Expected only one. Files %s."),
+ RESOURCE_NOT_DEFINED_IN_OUTPUT(
+ "Resource is not defined as output and thus cannot be Shared, Resource ID [%s]"),
+ RESOURCE_CONNECTED_TO_TWO_EXTERNAL_NETWORKS_WITH_SAME_ROLE(
+ "A resource is connected twice to the same network role, Network Role [%s],"
+ + " Resource ID [%s]"),
+ VOLUME_HEAT_NOT_EXPOSED("Volume is not defined as output and thus cannot be attached %s"),
+ FORBIDDEN_RESOURCE_IN_USE("%s is in use, Resource ID [%s]"),
+ PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES(
+ "%s '%s' Parameter Name not aligned with Guidelines, Parameter Name [%s], Resource ID [%s]."
+ + " As a result, VF/VFC Profile may miss this information"),
+ /* Contrail validator messages*/
+ MERGE_OF_CONTRAIL2_AND_CONTRAIL3_RESOURCES(
+ "HEAT Package includes both Contrail 2 and Contrail 3 resources. "
+ + "Contrail 2 resources can be found in %s. Contrail 3 resources can be found in %s"),
+ CONTRAIL_VM_TYPE_NAME_NOT_ALIGNED_WITH_NAMING_CONVENSION(
+ "Service Template naming convention in Image and Flavor "
+ + "properties is not consistent in Resource, Resource ID %s"),
+
+ /* Notifications */
+ FAILED_TO_MARK_NOTIFICATION_AS_READ("Failed to mark notifications as read"),
+ FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION("Failed to update last seen notification for user %s"),
+ FAILED_TO_VERIFY_SIGNATURE("Could not verify signature of signed package.");
+
+ private String errorMessage;
+
+ /**
+ * Formats the message with the given parameters.
+ *
+ * @param params The message string parameters to apply
+ * @return The formatted message.
+ */
+ public String formatMessage(final Object... params) {
+ return String.format(errorMessage, params);
+ }
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
index f1e0ae5b4c..5067c4a7c8 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/pom.xml
@@ -25,6 +25,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.openecomp.sdc.be</groupId>
+ <artifactId>common-be</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
index cb901b6f3c..b57bf74571 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParserTest.java
@@ -29,22 +29,25 @@ import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.TO_
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.openecomp.core.converter.pnfd.model.ConversionDefinition;
import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
-import org.openecomp.core.util.TestResourcesUtil;
import org.openecomp.core.util.YamlTestUtil;
+import org.openecomp.sdc.be.test.util.TestResourcesHandler;
public class ConversionDefinitionYamlParserTest {
@Test
public void shouldBuildDefinition() {
final Map<String, Object> definitionYaml;
- final String definitionYamlFilePath = "transformation/conversionDefinition/conversionDefinitionWithReplaceStrategy.yaml";
- try (final InputStream resourceInputStream = TestResourcesUtil.getFileResourceAsStream(definitionYamlFilePath)) {
+ final Path definitionYamlFilePath =
+ Paths.get("transformation", "conversionDefinition", "conversionDefinitionWithReplaceStrategy.yaml");
+ try (final InputStream resourceInputStream = TestResourcesHandler.getResourceAsStream(definitionYamlFilePath)) {
definitionYaml = (Map<String, Object>) YamlTestUtil.read(resourceInputStream);
} catch (final IOException e) {
fail(String.format("Could not load %s", definitionYamlFilePath));
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java
index 1eab214980..18d10436be 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParserTest.java
@@ -25,20 +25,23 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
-import org.openecomp.core.util.TestResourcesUtil;
import org.openecomp.core.util.YamlTestUtil;
+import org.openecomp.sdc.be.test.util.TestResourcesHandler;
public class PnfdConversionStrategyYamlParserTest {
@Test
public void parseInvalidYamlObject() {
final Object replaceStrategyYaml;
- final String strategyYamlFilePath = "transformation/strategy/strategyMissingStrategyAttribute.yaml";
- try (final InputStream resourceInputStream = TestResourcesUtil.getFileResourceAsStream(strategyYamlFilePath)) {
+ final Path strategyYamlFilePath =
+ Paths.get("transformation", "strategy", "strategyMissingStrategyAttribute.yaml");
+ try (final InputStream resourceInputStream = TestResourcesHandler.getResourceAsStream(strategyYamlFilePath)) {
replaceStrategyYaml = YamlTestUtil.read(resourceInputStream);
} catch (final IOException e) {
fail(String.format("Could not load %s", strategyYamlFilePath));
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaDefinitionImportHandlerTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaDefinitionImportHandlerTest.java
index 30cba677f2..fe0d5a8620 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaDefinitionImportHandlerTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaDefinitionImportHandlerTest.java
@@ -22,8 +22,10 @@ package org.openecomp.core.impl;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
-import static org.openecomp.core.util.TestResourcesUtil.getResourceBytesOrFail;
+import static org.openecomp.sdc.be.test.util.TestResourcesHandler.getResourceBytesOrFail;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -39,7 +41,7 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage;
public class ToscaDefinitionImportHandlerTest {
- private static final String RESOURCES_FILE_PATH = "/toscaDefinitionImportHandler/";
+ private static final Path RESOURCES_FILE_PATH = Paths.get("toscaDefinitionImportHandler");
private Map<String, byte[]> descriptorFileMap;
@Before
@@ -56,7 +58,9 @@ public class ToscaDefinitionImportHandlerTest {
"Definitions/descriptorWithRelativePaths.yaml", "Artifacts/descriptorWithAbsolutePaths.yaml",
"Artifacts/descriptorCyclicReference.yaml");
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final ToscaDefinitionImportHandler toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(
descriptorFileMap,
@@ -108,7 +112,9 @@ public class ToscaDefinitionImportHandlerTest {
final List<String> filesToHandleList = Arrays.asList("Definitions/Main.yaml",
"Definitions/descriptorBasicImport.yaml", "Definitions/descriptorWithRelativePaths.yaml",
"Artifacts/descriptorWithAbsolutePaths.yaml");
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final List<ErrorMessage> expectedErrorList = new ArrayList<>();
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR,
@@ -140,7 +146,9 @@ public class ToscaDefinitionImportHandlerTest {
final List<String> filesToHandleList = Arrays.asList(mainDefinitionFile,
"Definitions/descriptorInvalidImportStatement.yaml");
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final List<ErrorMessage> expectedErrorList = new ArrayList<>();
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR,
@@ -172,7 +180,9 @@ public class ToscaDefinitionImportHandlerTest {
final String invalidMainDefinitionFilePath = "../Definitions/InvalidMainDefinitionFile.yaml";
final List<String> filesToHandleList = Arrays.asList(mainDefinitionFilePath);
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final List<ErrorMessage> expectedErrorList = new ArrayList<>();
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR, Messages.MISSING_IMPORT_FILE.formatMessage(invalidMainDefinitionFilePath)));
@@ -200,7 +210,9 @@ public class ToscaDefinitionImportHandlerTest {
final String mainDefinitionFile = "Definitions/descriptorInvalid.yaml";
final List<String> filesToHandleList = Arrays.asList(mainDefinitionFile);
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final List<ErrorMessage> expectedErrorList = new ArrayList<>();
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.INVALID_YAML_FORMAT.getErrorMessage()
@@ -236,7 +248,9 @@ public class ToscaDefinitionImportHandlerTest {
final String mainDefinitionFile = "Definitions/descriptorFileWithValidImportStatements.yaml";
final List<String> filesToHandleList = Arrays.asList(mainDefinitionFile, "Artifacts/descriptorCyclicReference.yaml");
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final ToscaDefinitionImportHandler toscaDefinitionImportHandler =
new ToscaDefinitionImportHandler(descriptorFileMap, mainDefinitionFile);
@@ -258,17 +272,25 @@ public class ToscaDefinitionImportHandlerTest {
public void testGivenDescriptorFileWithNonexistentRelativeImport_whenIncorrectMainDescriptorIsHandled_aMissingFileErrorIsReported() {
final String mainDefinitionFile = "Definitions/MainWithNonexistentReferences.yaml";
- final List<String> filesToHandleList = Arrays.asList(mainDefinitionFile, "Definitions/descriptorNonexistentImport.yaml",
- "Artifacts/descriptorCyclicReference.yaml");
- filesToHandleList.forEach(file -> descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH + file)));
+ final List<String> filesToHandleList = Arrays.asList(mainDefinitionFile,
+ "Definitions/descriptorNonexistentImport.yaml", "Artifacts/descriptorCyclicReference.yaml");
+ filesToHandleList.forEach(file ->
+ descriptorFileMap.put(file, getResourceBytesOrFail(RESOURCES_FILE_PATH.resolve(file)))
+ );
final List<ErrorMessage> expectedErrorList = new ArrayList<>();
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR,
- String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), "Definitions/descriptorCyclicReference.yaml")));
+ String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(),
+ "Definitions/descriptorCyclicReference.yaml"))
+ );
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR,
- String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), "Definitions/descriptorCyclicReference.yaml")));
+ String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(),
+ "Definitions/descriptorCyclicReference.yaml"))
+ );
expectedErrorList.add(new ErrorMessage(ErrorLevel.ERROR,
- String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), "Definitions/descriptorCyclicReference.yaml")));
+ String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(),
+ "Definitions/descriptorCyclicReference.yaml"))
+ );
final ToscaDefinitionImportHandler toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(
descriptorFileMap,
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java
deleted file mode 100644
index 7d89bb3eab..0000000000
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/TestResourcesUtil.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 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.core.util;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import org.apache.commons.io.IOUtils;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-/**
- * Test resources utility class.
- */
-public class TestResourcesUtil {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(TestResourcesUtil.class);
-
- private TestResourcesUtil() {
-
- }
-
- /**
- * Reads a file and coverts it to a byte array.
- *
- * @param resourcePath The resource file path
- * @return
- * The resource file byte array
- * @throws IOException
- * When the file was not found or the input stream could not be opened
- */
- public static byte[] getFileResourceBytes(final String resourcePath) throws IOException {
- try(final InputStream inputStream = ClassLoader.class.getResourceAsStream(resourcePath)) {
- if (inputStream == null) {
- throw new IOException(String.format("Could not find the resource on path \"%s\"", resourcePath));
- }
- return IOUtils.toByteArray(inputStream);
- } catch (final IOException ex) {
- throw new IOException(String.format("Could not open the input stream for resource on path \"%s\"", resourcePath), ex);
- }
- }
-
- /**
- * Reads a file in the given path.
- * The method forces an assertion fail if the resource could not be loaded.
- * @param resourcePath The resource file path
- * @return
- * The resource file byte array
- */
- public static byte[] getResourceBytesOrFail(final String resourcePath) {
- try {
- return getFileResourceBytes(resourcePath);
- } catch (final IOException e) {
- final String errorMsg = String.format("Could not load resource '%s'", resourcePath);
- LOGGER.error(errorMsg, e);
- fail(errorMsg);
- }
-
- return null;
- }
-
- /**
- * Gets the input stream of a resource file
- *
- * @param resourcePath The resource file path
- * @return
- * The resource input stream
- */
- public static InputStream getFileResourceAsStream(final String resourcePath) {
- return Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath);
- }
-
- /**
- * Gets the input stream of a resource file
- *
- * @param resourcePath The resource file path
- * @return
- * The resource input stream
- */
- public static URL getFileUrl(final String resourcePath) {
- return Thread.currentThread().getContextClassLoader().getResource(resourcePath);
- }
-
-}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java
index b095d13ed7..3229c1ce46 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/util/YamlTestUtil.java
@@ -26,6 +26,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.be.test.util.TestResourcesHandler;
public class YamlTestUtil {
@@ -45,7 +46,7 @@ public class YamlTestUtil {
}
public static Object read(final String yamlFilePath) throws IOException {
- try (final InputStream resourceInputStream = TestResourcesUtil.getFileResourceAsStream(yamlFilePath)) {
+ try (final InputStream resourceInputStream = TestResourcesHandler.getResourceAsStream(yamlFilePath)) {
return read(resourceInputStream);
}
}