summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-08-09 13:54:44 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-08-09 13:54:44 +0200
commit870a89675528664aa5c0aca57f50c584b76a8b8f (patch)
tree79bfd9766166c7d5d8e6177bbbf43386ea9c70f3
parente66d2541cf7ee1836784681331b6909421a86d63 (diff)
Improve code quality
Change-Id: I60090d9da403bf8e6c3e5ba77ef4acfd6f41ec2b Issue-ID: VNFSDK-449 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java185
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java49
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/VnfManifestParser.java7
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java2
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java26
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/VTPValidateCSARTest.java56
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplateDifferentSectionOrder.mf68
23 files changed, 286 insertions, 139 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
index 2b84997..180dadd 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
@@ -49,60 +49,54 @@ public class CSARArchive implements AutoCloseable {
public static final String TEMP_DIR = "/tmp";
- public static final String TOSCA_Metadata = "TOSCA-Metadata";
+ public static final String TOSCA_METADATA = "TOSCA-Metadata";
- public static final String TOSCA_Metadata__TOSCA_Meta = "TOSCA.meta";
+ public static final String TOSCA_METADATA_TOSCA_META = "TOSCA.meta";
- public static final String TOSCA_Metadata__TOSCA_Meta__TOSCA_Meta_File_Version = "TOSCA-Meta-File-Version";
+ public static final String TOSCA_METADATA_TOSCA_META_TOSCA_META_FILE_VERSION = "TOSCA-Meta-File-Version";
- public static final String TOSCA_Metadata__TOSCA_Meta__CSAR_Version = "CSAR-Version";
+ public static final String TOSCA_METADATA_TOSCA_META_CSAR_VERSION = "CSAR-Version";
- public static final String TOSCA_Metadata__TOSCA_Meta__Created_by = "Created-by";
+ public static final String TOSCA_METADATA_TOSCA_META_CREATED_BY = "Created-by";
- public static final String TOSCA_Metadata__TOSCA_Meta__Entry_Definitions = "Entry-Definitions";
+ public static final String TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS = "Entry-Definitions";
- public static final String TOSCA_Metadata__TOSCA_Meta__Entry_Manifest = "Entry-Manifest";
+ public static final String TOSCA_METADATA_TOSCA_META_ENTRY_MANIFEST = "Entry-Manifest";
- public static final String TOSCA_Metadata__TOSCA_Meta__Entry_Change_Log = "Entry-Change-Log";
+ public static final String TOSCA_METADATA_TOSCA_META_ENTRY_CHANGE_LOG = "Entry-Change-Log";
- public static final String Change_Logs_Txt = "Change-Logs.txt";
+ public static final String CHANGE_LOGS_TXT = "Change-Logs.txt";
- public static final String TOSCA_Metadata__TOSCA_Meta__Entry_Tests = "Entry-Tests";
+ public static final String TOSCA_METADATA_TOSCA_META_ENTRY_TESTS = "Entry-Tests";
- public static final String Tests = "Tests";
+ public static final String TESTS = "Tests";
- public static final String TOSCA_Metadata__TOSCA_Meta__Entry_Licenses = "Entry-Licenses";
+ public static final String TOSCA_METADATA_TOSCA_META_ENTRY_LICENSES = "Entry-Licenses";
- public static final String Licenses = "Licenses";
+ public static final String LICENSES = "Licenses";
- public static final String TOSCA_Metadata__TOSCA_Meta__Entry_Certificate = "Entry-Certificate";
+ public static final String TOSCA_METADATA_TOSCA_META_ENTRY_CERTIFICATE = "Entry-Certificate";
- public static final String Certificate = "Certificate";
+ public static final String ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION = "tosca_definitions_version";
- public static final String TOSCA_Metadata__TOSCA_Meta__Name = "Name";
-
- public static final String TOSCA_Metadata__TOSCA_Meta__Content_Type = "Content-Type";
-
- public static final String Entry_Definition__tosca_definitions_version = "tosca_definitions_version";
-
- public static final String Entry_Definition__tosca_definitions_version__simple_1_0 = "tosca_simple_yaml_1_0";
- public static final String Entry_Definition__tosca_definitions_version__simple_1_1 = "tosca_simple_yaml_1_1";
- public static final String Entry_Definition__tosca_definitions_version__simple_1_2 = "tosca_simple_yaml_1_2";
+ public static final String ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_0 = "tosca_simple_yaml_1_0";
+ public static final String ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_1 = "tosca_simple_yaml_1_1";
+ public static final String ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_2 = "tosca_simple_yaml_1_2";
protected static final String[] Entry_Definition__tosca_definitions_versions = new String[] {
- Entry_Definition__tosca_definitions_version__simple_1_0,
- Entry_Definition__tosca_definitions_version__simple_1_1,
- Entry_Definition__tosca_definitions_version__simple_1_2
+ ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_0,
+ ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_1,
+ ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_2
};
- public static final String Entry_Definition__metadata = "metadata";
+ public static final String ENTRY_DEFINITION_METADATA = "metadata";
- public static final String Entry_Definition__template_name = "template_name";
+ public static final String ENTRY_DEFINITION_TEMPLATE_NAME = "template_name";
- public static final String Entry_Definition__template_author = "template_author";
+ public static final String ENTRY_DEFINITION_TEMPLATE_AUTHOR = "template_author";
- public static final String Entry_Definition__template_version = "template_version";
+ public static final String ENTRY_DEFINITION_TEMPLATE_VERSION = "template_version";
- public static final String CSAR_Archive = "CSAR Archive";
+ public static final String CSAR_ARCHIVE = "CSAR Archive";
public enum Mode {
WITH_TOSCA_META_DIR,
@@ -111,10 +105,6 @@ public class CSARArchive implements AutoCloseable {
public static class CSARError{
- public CSARError(String code) {
- this.code = code;
- }
-
private String vnfreqNo;
private String code;
@@ -125,6 +115,10 @@ public class CSARArchive implements AutoCloseable {
protected int lineNumber = -1;
+ public CSARError(String code) {
+ this.code = code;
+ }
+
public String getCode() {
return code;
}
@@ -293,7 +287,7 @@ public class CSARArchive implements AutoCloseable {
//Specific errors
public static class CSARErrorEntryMissingToscaDefinitionVersion extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaDefinitionVersion(String definitionYaml) {
- super(Entry_Definition__tosca_definitions_version,
+ super(ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION,
definitionYaml,
-1,
null);
@@ -303,11 +297,11 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueToscaDefinitionVersion extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueToscaDefinitionVersion(String definitionYaml) {
- super(Entry_Definition__tosca_definitions_version,
+ super(ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION,
definitionYaml,
-1,
null,
- Entry_Definition__tosca_definitions_version__simple_1_1);
+ ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_1);
this.setCode("0x0002");
}
@@ -316,7 +310,7 @@ public class CSARArchive implements AutoCloseable {
//In non TOSCA-Meta mode, this is mandatory
public static class CSARErrorEntryMissingToscaDefinitionMetadataTemplateAuthor extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaDefinitionMetadataTemplateAuthor(String definitionYaml) {
- super(Entry_Definition__template_author,
+ super(ENTRY_DEFINITION_TEMPLATE_AUTHOR,
definitionYaml,
-1,
null);
@@ -328,7 +322,7 @@ public class CSARArchive implements AutoCloseable {
//In non TOSCA-Meta mode, this is mandatory
public static class CSARErrorEntryMissingToscaDefinitionMetadataTemplateName extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaDefinitionMetadataTemplateName(String definitionYaml) {
- super(Entry_Definition__template_name,
+ super(ENTRY_DEFINITION_TEMPLATE_NAME,
definitionYaml,
-1,
null);
@@ -340,7 +334,7 @@ public class CSARArchive implements AutoCloseable {
//In non TOSCA-Meta mode, this is mandatory
public static class CSARErrorEntryMissingToscaDefinitionMetadataTemplateVersion extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaDefinitionMetadataTemplateVersion(String definitionYaml) {
- super(Entry_Definition__template_version,
+ super(ENTRY_DEFINITION_TEMPLATE_VERSION,
definitionYaml,
-1,
null);
@@ -351,8 +345,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueToscaDefinitionNotFound extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueToscaDefinitionNotFound(String definitionYaml, int lineNo) {
- super(TOSCA_Metadata__TOSCA_Meta__Entry_Definitions,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
definitionYaml + " does not exist",
null);
@@ -364,7 +358,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueManifestNotFound extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueManifestNotFound(String manifest, int lineNo, String entryManifestArgumentName) {
super(entryManifestArgumentName,
- TOSCA_Metadata__TOSCA_Meta,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
manifest + " does not exist",
null);
@@ -376,7 +370,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueLogsNotFound extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueLogsNotFound(String logs, int lineNo, String entryChangeLogArgumentName) {
super(entryChangeLogArgumentName,
- TOSCA_Metadata__TOSCA_Meta,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
logs + " does not exist",
null);
@@ -387,8 +381,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueTestsNotFound extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueTestsNotFound(String tests, int lineNo) {
- super(TOSCA_Metadata__TOSCA_Meta__Entry_Tests,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_ENTRY_TESTS,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
tests + " folder does not exist",
null);
@@ -399,8 +393,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueLicenseNotFound extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueLicenseNotFound(String license, int lineNo) {
- super(TOSCA_Metadata__TOSCA_Meta__Entry_Licenses,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_ENTRY_LICENSES,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
license + " does not exist",
null);
@@ -411,8 +405,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorInvalidEntryValueCertificatesNotFound extends CSARErrorInvalidEntryValue {
public CSARErrorInvalidEntryValueCertificatesNotFound(String certificate, int lineNo) {
- super(TOSCA_Metadata__TOSCA_Meta__Entry_Certificate,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_ENTRY_CERTIFICATE,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
certificate + " does not exist",
null);
@@ -423,8 +417,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorEntryMissingToscaMetaFileVersion extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaMetaFileVersion() {
- super(TOSCA_Metadata__TOSCA_Meta__TOSCA_Meta_File_Version,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_TOSCA_META_FILE_VERSION,
+ TOSCA_METADATA_TOSCA_META,
-1,
null);
@@ -434,8 +428,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorEntryMissingToscaMetaDefinition extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaMetaDefinition() {
- super(TOSCA_Metadata__TOSCA_Meta__Entry_Definitions,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS,
+ TOSCA_METADATA_TOSCA_META,
-1,
null);
@@ -445,8 +439,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorEntryMissingToscaMetaCSARVersion extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaMetaCSARVersion() {
- super(TOSCA_Metadata__TOSCA_Meta__CSAR_Version,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_CSAR_VERSION,
+ TOSCA_METADATA_TOSCA_META,
-1,
null);
@@ -456,8 +450,8 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorEntryMissingToscaMetaCreatedBy extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaMetaCreatedBy() {
- super(TOSCA_Metadata__TOSCA_Meta__Created_by,
- TOSCA_Metadata__TOSCA_Meta,
+ super(TOSCA_METADATA_TOSCA_META_CREATED_BY,
+ TOSCA_METADATA_TOSCA_META,
-1,
null);
@@ -468,7 +462,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorEntryMissingToscaDefinitionNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingToscaDefinitionNotFound() {
super("Definition YAML",
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
null);
@@ -479,7 +473,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorConflictsMultipleDefinitionYamls extends CSARErrorConflicts {
public CSARErrorConflictsMultipleDefinitionYamls(String fileNames) {
super("Definition YAML",
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
"Only one definition YAML should be provided at the root of the archive",
fileNames);
@@ -492,7 +486,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorConflictsMultipleManifests extends CSARErrorConflicts {
public CSARErrorConflictsMultipleManifests(String fileNames) {
super("Manifest MF",
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
"Only one manifest MF file should be provided at the root of the archive",
fileNames);
@@ -504,7 +498,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorMismatchDefinitionYamlVsManifestMf extends CSARErrorMismatch {
public CSARErrorMismatchDefinitionYamlVsManifestMf(String definitionYaml, String manifest) {
super("Manifest MF",
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
"Manifest file name should match the definition YAML name",
definitionYaml + ".mf", //fix the name part
@@ -517,7 +511,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorConflictsMultipleCertificates extends CSARErrorConflicts {
public CSARErrorConflictsMultipleCertificates(String fileNames) {
super("Certificate CERT",
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
"Only one certificates file should be provided at the root of the archive",
fileNames);
@@ -529,7 +523,7 @@ public class CSARArchive implements AutoCloseable {
public static class CSARErrorMismatchDefinitionYamlVsCertificateCert extends CSARErrorMismatch {
public CSARErrorMismatchDefinitionYamlVsCertificateCert(String definitionYaml, String certificate) {
super("Certificate CERT",
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
"certificate file name should match the definition YAML name",
definitionYaml + ".cert", //fix the name part
@@ -929,7 +923,7 @@ public class CSARArchive implements AutoCloseable {
private boolean isToscaMetaFileExist() {
return new File(this.tempDir.toFile().getAbsolutePath() + File.separator +
- TOSCA_Metadata + File.separator + TOSCA_Metadata__TOSCA_Meta).exists();
+ TOSCA_METADATA + File.separator + TOSCA_METADATA_TOSCA_META).exists();
}
void parseManifest() throws IOException {
@@ -942,14 +936,13 @@ public class CSARArchive implements AutoCloseable {
Pair<List<SourcesParser.Source>, List<CSARError>> sourcesSectionData = vnfManifestParser.fetchSourcesSection();
Pair<String, List<CSARError>> cmsSectionData = vnfManifestParser.fetchCMS();
- CSARArchive.Manifest manifest = this.getManifest();
- manifest.setMetadata(metadataData.getKey());
+ this.manifest.setMetadata(metadataData.getKey());
this.getErrors().addAll(metadataData.getValue());
- manifest.setSources(sourcesSectionData.getKey());
+ this.manifest.setSources(sourcesSectionData.getKey());
this.getErrors().addAll(sourcesSectionData.getValue());
- manifest.setCms(cmsSectionData.getKey());
+ this.manifest.setCms(cmsSectionData.getKey());
this.getErrors().addAll(cmsSectionData.getValue());
}
@@ -959,37 +952,37 @@ public class CSARArchive implements AutoCloseable {
Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream);
//yaml is empty or version string missing
- if (yaml == null || !yaml.keySet().contains(Entry_Definition__tosca_definitions_version)) {
+ if (yaml == null || !yaml.keySet().contains(ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION)) {
errors.add(
new CSARErrorEntryMissingToscaDefinitionVersion(
this.definitionYamlFile.getName()));
} else {
- String version = (String) yaml.get(Entry_Definition__tosca_definitions_version);
+ String version = (String) yaml.get(ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION);
if (!Arrays.asList(Entry_Definition__tosca_definitions_versions).contains(version)) {
- errors.add(new CSARErrorInvalidEntry(Entry_Definition__tosca_definitions_version,
- this.definitionYamlFile.getName(), -1, "Should be " + Entry_Definition__tosca_definitions_version__simple_1_1));
+ errors.add(new CSARErrorInvalidEntry(ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION,
+ this.definitionYamlFile.getName(), -1, "Should be " + ENTRY_DEFINITION_TOSCA_DEFINITIONS_VERSION_SIMPLE_1_1));
} else {
this.definition.setToscaDefinitionVersion(version);
if (this.toscaMeta.getMode().equals(Mode.WITHOUT_TOSCA_META_DIR)) {
//metadata section should be there
- if (!yaml.keySet().contains(Entry_Definition__metadata)) {
+ if (!yaml.keySet().contains(ENTRY_DEFINITION_METADATA)) {
errors.add(
new CSARErrorInvalidEntryValueToscaDefinitionVersion(
this.definitionYamlFile.getName()));
} else {
- Map<String, String> metadata = (Map<String, String>) yaml.get(Entry_Definition__metadata);
+ Map<String, String> metadata = (Map<String, String>) yaml.get(ENTRY_DEFINITION_METADATA);
for(Map.Entry<String, String> entry: metadata.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
//continue till it reaches the metadata section
- if (key.equalsIgnoreCase(Entry_Definition__template_author)) {
+ if (key.equalsIgnoreCase(ENTRY_DEFINITION_TEMPLATE_AUTHOR)) {
this.definition.getMetadata().setTemplateAuthor(value);
- } else if (key.equalsIgnoreCase(Entry_Definition__template_name)) {
+ } else if (key.equalsIgnoreCase(ENTRY_DEFINITION_TEMPLATE_NAME)) {
this.definition.getMetadata().setTempalteName(value);
- } else if (key.equalsIgnoreCase(Entry_Definition__template_version)) {
+ } else if (key.equalsIgnoreCase(ENTRY_DEFINITION_TEMPLATE_VERSION)) {
this.definition.getMetadata().setTemplateVersion(value);
} else {
errors.add(
@@ -1024,7 +1017,7 @@ public class CSARArchive implements AutoCloseable {
private void parseMeta() throws IOException {
if (this.toscaMeta.getMode().equals(Mode.WITH_TOSCA_META_DIR)) {
- this.toscaMetaFile = this.tempDir.resolve(TOSCA_Metadata+ File.separator + TOSCA_Metadata__TOSCA_Meta).toFile();
+ this.toscaMetaFile = this.tempDir.resolve(TOSCA_METADATA + File.separator + TOSCA_METADATA_TOSCA_META).toFile();
int lineNo =0;
for (String line: FileUtils.readLines(this.toscaMetaFile)) {
@@ -1043,7 +1036,7 @@ public class CSARArchive implements AutoCloseable {
errors.add(
new CSARErrorIgnored(
line,
- TOSCA_Metadata__TOSCA_Meta,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
null));
continue;
@@ -1052,13 +1045,13 @@ public class CSARArchive implements AutoCloseable {
String key = lineTokens[0].trim();
String value = lineTokens[1].trim();
- if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__TOSCA_Meta_File_Version)) {
+ if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_TOSCA_META_FILE_VERSION)) {
this.toscaMeta.setMetaDataFileVersion(value);
- } else if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__CSAR_Version)){
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_CSAR_VERSION)){
this.toscaMeta.setCsarVersion(value);
- } else if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__Created_by)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_CREATED_BY)) {
this.toscaMeta.setCompanyName(value);
- } else if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__Entry_Definitions)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS)) {
this.toscaMeta.setEntryDefinitionYaml(value);
this.definitionYamlFile = new File(this.tempDir.toFile().getAbsolutePath() + File.separator + (this.toscaMeta.getEntryDefinitionYaml()));
@@ -1084,7 +1077,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.getEntryChangeLog(),
lineNo, getEntryChangeLogParamName()));
}
- } else if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__Entry_Tests)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_TESTS)) {
this.toscaMeta.setEntryTest(value);
this.testsFolder= this.tempDir.resolve(this.toscaMeta.getEntryTest()).toFile();
if (!this.testsFolder.exists() || !this.testsFolder.isDirectory()) {
@@ -1092,7 +1085,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.getEntryTest(),
lineNo));
}
- } else if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__Entry_Licenses)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_LICENSES)) {
this.toscaMeta.setEntryLicense(value);
this.licensesFolder= this.tempDir.resolve(this.toscaMeta.getEntryLicense()).toFile();
if (!this.licensesFolder.exists() || !this.licensesFolder.isDirectory()) {
@@ -1100,7 +1093,7 @@ public class CSARArchive implements AutoCloseable {
this.toscaMeta.getEntryLicense(),
lineNo));
}
- } else if(key.equalsIgnoreCase(TOSCA_Metadata__TOSCA_Meta__Entry_Certificate)) {
+ } else if(key.equalsIgnoreCase(TOSCA_METADATA_TOSCA_META_ENTRY_CERTIFICATE)) {
this.toscaMeta.setEntryCertificate(value);
this.certificatesFile= this.tempDir.resolve(this.toscaMeta.getEntryCertificate()).toFile();
if (!this.certificatesFile.exists()) {
@@ -1112,7 +1105,7 @@ public class CSARArchive implements AutoCloseable {
errors.add(
new CSARErrorIgnored(
key,
- TOSCA_Metadata__TOSCA_Meta,
+ TOSCA_METADATA_TOSCA_META,
lineNo,
null));
}
@@ -1230,15 +1223,15 @@ public class CSARArchive implements AutoCloseable {
for (File file: this.tempDir.toFile().listFiles()) {
- if (file.getName().equalsIgnoreCase(Change_Logs_Txt)) {
+ if (file.getName().equalsIgnoreCase(CHANGE_LOGS_TXT)) {
this.changeLogTxtFile = file;
}
- else if (file.getName().equalsIgnoreCase(Tests)) {
+ else if (file.getName().equalsIgnoreCase(TESTS)) {
this.testsFolder = file;
}
- else if (file.getName().equalsIgnoreCase(Licenses)) {
+ else if (file.getName().equalsIgnoreCase(LICENSES)) {
this.licensesFolder = file;
}
@@ -1246,7 +1239,7 @@ public class CSARArchive implements AutoCloseable {
errors.add(
new CSARErrorIgnored(
file.getName(),
- CSAR_Archive,
+ CSAR_ARCHIVE,
-1,
null));
}
@@ -1255,11 +1248,11 @@ public class CSARArchive implements AutoCloseable {
}
String getEntryManifestParamName(){
- return TOSCA_Metadata__TOSCA_Meta__Entry_Manifest;
+ return TOSCA_METADATA_TOSCA_META_ENTRY_MANIFEST;
}
String getEntryChangeLogParamName(){
- return TOSCA_Metadata__TOSCA_Meta__Entry_Change_Log;
+ return TOSCA_METADATA_TOSCA_META_ENTRY_CHANGE_LOG;
}
public void init(String csarPath) throws IOException {
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
index 5f7091b..a852d78 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
@@ -21,6 +21,7 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionFailed;
@@ -174,10 +175,10 @@ public class VTPValidateCSAR extends OnapCommand {
}
}
- private static Properties prp = new Properties();
+ private static Properties properties = new Properties();
static {
try {
- prp.load(VTPValidateCSAR.class.getClass().getResourceAsStream("/vnfreqs.properties"));
+ properties.load(VTPValidateCSAR.class.getClass().getResourceAsStream("/vnfreqs.properties"));
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
@@ -194,14 +195,7 @@ public class VTPValidateCSAR extends OnapCommand {
csar.init(path);
csar.parse();
-
- //Fill up the basic details
- CSARValidation validation = new CSARValidation();
- validation.getVnf().setName(csar.getProductName());
- validation.getVnf().setVendor(csar.getVendorName());
- validation.getVnf().setVersion(csar.getVersion());
- validation.getVnf().setType("TOSCA");
- validation.getVnf().setMode(csar.getToscaMeta().getMode().name());
+ CSARValidation validation = createCsarValidationFor(csar);
String keyErrors = isPnf ? "pnferrors.ignored" : "vnferrors.ignored";
List <String> ignoreCodes = this.getPropertiesList(keyErrors);
@@ -256,21 +250,36 @@ public class VTPValidateCSAR extends OnapCommand {
validation.setDate(new Date().toString());
validation.setCriteria(overallPass ? "PASS" : "FAILED");
- this.getResult().getRecordsMap().get("vnf").getValues().add(
- new ObjectMapper().writeValueAsString(validation.getVnf()));
- this.getResult().getRecordsMap().get("date").getValues().add(validation.getDate());
- this.getResult().getRecordsMap().get("criteria").getValues().add(validation.getCriteria());
- this.getResult().getRecordsMap().get("results").getValues().add(
- new ObjectMapper().writeValueAsString(validation.getResults()));
-
- this.getResult().setOutput(new ObjectMapper().writeValueAsString(validation));
- this.getResult().setType(OnapCommandResultType.TEXT);
+ setOperationResult(validation);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new OnapCommandExecutionFailed(e.getMessage());
}
}
+ static CSARValidation createCsarValidationFor(CSARArchive csar) {
+ //Fill up the basic details
+ CSARValidation validation = new CSARValidation();
+ validation.getVnf().setName(csar.getProductName());
+ validation.getVnf().setVendor(csar.getVendorName());
+ validation.getVnf().setVersion(csar.getVersion());
+ validation.getVnf().setType("TOSCA");
+ validation.getVnf().setMode(csar.getToscaMeta().getMode().name());
+ return validation;
+ }
+
+ private void setOperationResult(CSARValidation validation) throws JsonProcessingException {
+ this.getResult().getRecordsMap().get("vnf").getValues().add(
+ new ObjectMapper().writeValueAsString(validation.getVnf()));
+ this.getResult().getRecordsMap().get("date").getValues().add(validation.getDate());
+ this.getResult().getRecordsMap().get("criteria").getValues().add(validation.getCriteria());
+ this.getResult().getRecordsMap().get("results").getValues().add(
+ new ObjectMapper().writeValueAsString(validation.getResults()));
+
+ this.getResult().setOutput(new ObjectMapper().writeValueAsString(validation));
+ this.getResult().setType(OnapCommandResultType.TEXT);
+ }
+
private void setPnfValueIfAvailable(boolean isPnf, OnapCommand cmd) throws OnapCommandInvalidParameterValue {
final OnapCommandParameter pnf = cmd.getParametersMap().get(PNF_ATTRIBUTE_NAME);
if(pnf!=null) {
@@ -279,7 +288,7 @@ public class VTPValidateCSAR extends OnapCommand {
}
private List<String> getPropertiesList(String key) {
- String[] enabledReqs = prp.getProperty(key, "").split(",");
+ String[] enabledReqs = properties.getProperty(key, "").split(",");
List<String> list = new ArrayList<>();
for(String req: enabledReqs) {
if (!req.isEmpty()) list.add(req);
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/VnfManifestParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/VnfManifestParser.java
index d122fed..000f046 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/VnfManifestParser.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VnfManifestParser.java
@@ -135,10 +135,7 @@ class VnfManifestParser {
}
private boolean skipLine(String line) {
- return line.startsWith("#")
- || line.isEmpty()
- || line.toLowerCase().startsWith("source")
- || line.toLowerCase().startsWith("algorithm")
- || line.toLowerCase().startsWith("hash");
+ return line.isEmpty()
+ || line.toLowerCase().matches("^(#|source|algorithm|hash).*$");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java
index a34196e..5afc1d9 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java
@@ -27,7 +27,7 @@ public class VTPValidateCSARR01123 extends VTPValidateCSARBase {
public static class CSARErrorEntryVNFProviderDetailsNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryVNFProviderDetailsNotFound() {
super("VNF Vendor details",
- CSARArchive.TOSCA_Metadata + " or " + CSARArchive.TOSCA_Metadata__TOSCA_Meta__Entry_Definitions + " file");
+ CSARArchive.TOSCA_METADATA + " or " + CSARArchive.TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS + " file");
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java
index 1be9814..2c4924a 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR04298 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingTestFolderNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingTestFolderNotFound() {
- super("Tests", CSARArchive.CSAR_Archive);
+ super("Tests", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java
index ad46620..a79f07b 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR07879 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingAnsiblePlaybookNotFound() {
- super("playbooks", CSARArchive.CSAR_Archive);
+ super("playbooks", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java
index d33ed3f..8ddd1a4 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR13390 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingAnsiblePlaybookNotFound() {
- super("playbooks", CSARArchive.CSAR_Archive);
+ super("playbooks", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java
index 9c0a791..8b5a4e8 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR21322 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingTestFolderNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingTestFolderNotFound() {
- super("Tests", CSARArchive.CSAR_Archive);
+ super("Tests", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java
index 6919f28..62a533e 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR23823 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingCertificatesNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingCertificatesNotFound() {
- super("Certificates", CSARArchive.CSAR_Archive);
+ super("Certificates", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java
index f06b84a..16314a3 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR26881 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingArtifactsNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingArtifactsNotFound() {
- super("Artifacts", CSARArchive.CSAR_Archive);
+ super("Artifacts", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java
index 97f2d3c..d71e814 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR26885 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingArtifactImage extends CSARErrorEntryMissing {
public CSARErrorEntryMissingArtifactImage() {
- super("Artifacts/VNF_Image.bin", CSARArchive.CSAR_Archive);
+ super("Artifacts/VNF_Image.bin", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java
index 4c2210a..189624b 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR27310 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingChefArtifactsNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingChefArtifactsNotFound() {
- super("cookbooks", CSARArchive.CSAR_Archive);
+ super("cookbooks", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java
index a832b4d..345cec6 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java
@@ -43,7 +43,7 @@ public class VTPValidateCSARR293901 extends VTPValidateCSARBase {
if (Objects.isNull(entryManifestMf)) {
this.errors.add(new PnfCSARErrorEntryMissing(
toscaMetaAttributeName,
- CSARArchive.TOSCA_Metadata__TOSCA_Meta,
+ CSARArchive.TOSCA_METADATA_TOSCA_META,
UNKNOWN_LINE_NUMBER)
);
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java
index 7173156..d67eaf3 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR40293 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingAnsiblePlaybookNotFound() {
- super("playbooks", CSARArchive.CSAR_Archive);
+ super("playbooks", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java
index 99f180b..20dbd5e 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR40820 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingLicenseTerm extends CSARErrorEntryMissing {
public CSARErrorEntryMissingLicenseTerm() {
- super("Licenses/License_term.txt", CSARArchive.CSAR_Archive);
+ super("Licenses/License_term.txt", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java
index 0d42628..b9c093c 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java
@@ -26,7 +26,7 @@ public class VTPValidateCSARR43958 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingTestReportNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingTestReportNotFound() {
- super("Tests/report.txt", CSARArchive.CSAR_Archive);
+ super("Tests/report.txt", CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java
index 1d5c3c5..eac0b93 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java
@@ -27,7 +27,7 @@ public class VTPValidateCSARR66070 extends VTPValidateCSARBase {
public static class CSARErrorEntryVNFProviderDetailsNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryVNFProviderDetailsNotFound() {
super("VNF Vendor details",
- CSARArchive.TOSCA_Metadata + " or " + CSARArchive.TOSCA_Metadata__TOSCA_Meta__Entry_Definitions + " file");
+ CSARArchive.TOSCA_METADATA + " or " + CSARArchive.TOSCA_METADATA_TOSCA_META_ENTRY_DEFINITIONS + " file");
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java
index 13ac502..fc6fa11 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java
@@ -27,7 +27,7 @@ public class VTPValidateCSARR77707 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingDefinitionNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingDefinitionNotFound() {
super("TOSCA definition or Tosca.Meata",
- CSARArchive.CSAR_Archive);
+ CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java
index bf55530..3ca882c 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java
@@ -27,7 +27,7 @@ public class VTPValidateCSARR77786 extends VTPValidateCSARBase {
public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing {
public CSARErrorEntryMissingAnsiblePlaybookNotFound() {
super("playbooks",
- CSARArchive.CSAR_Archive);
+ CSARArchive.CSAR_ARCHIVE);
this.setCode("0x1000");
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java
index ef233f8..a3ab865 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java
@@ -85,7 +85,7 @@ public class VTPValidateCSARR787965 extends VTPValidateCSARBase {
}
- private void verifyZipStructure(FileArchive.Workspace workspace) throws Exception {
+ private void verifyZipStructure(FileArchive.Workspace workspace) throws IOException, CmsSignatureValidatorException {
final Optional<Path> pathToCsarFile = workspace.getPathToCsarFile();
final Optional<Path> pathToCertFile = workspace.getPathToCertFile();
final Optional<Path> pathToCmsFile = workspace.getPathToCmsFile();
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
index 3ba37aa..6e56959 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
@@ -162,4 +162,28 @@ public class PnfManifestParserTest {
assertThat(errors.size()).isEqualTo(1);
assertThat(errors.get(0).getMessage()).isEqualTo("Invalid. Entry [CMS section is not at the end of file!]");
}
-} \ No newline at end of file
+
+ @Test
+ public void shouldFetchSourcesSectionFromFileWithChangedSectionOrder() throws IOException {
+
+ pnfManifestParser = PnfManifestParser.getInstance(new File("./src/test/resources/pnf/MainServiceTemplateDifferentSectionOrder.mf"));
+ Pair<List<SourcesParser.Source>, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchSourcesSection();
+ List<SourcesParser.Source> sources = sourcesPair.getKey();
+ List<CSARArchive.CSARError> errors = sourcesPair.getValue();
+
+ assertThat(sources).contains(
+ new SourcesParser.Source("MRF.yaml", "SHA-256", "09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943"),
+ new SourcesParser.Source("scripts/install.sh", "SHA-256", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
+ new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/Events/VES_registration.yml", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/Measurements/PM_Dictionary.yaml", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/Yang_module/Yang_module.yaml", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/scripts/install.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/Informational/user_guide.txt", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/Other/installation_guide.txt", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165"),
+ new SourcesParser.Source("Artifacts/Other/review_log.txt", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165")
+
+ );
+ assertThat(errors.size()).isEqualTo(0);
+ }
+}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/VTPValidateCSARTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/VTPValidateCSARTest.java
new file mode 100644
index 0000000..69b92f6
--- /dev/null
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/VTPValidateCSARTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2019 Nokia
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ *
+ */
+
+package org.onap.cvc.csar;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class VTPValidateCSARTest {
+
+ @Test
+ public void shouldConfigureCsarValidatorBasedOnCsarArchive(){
+ // given
+ final CSARArchive csarArchive = givenCsarArchive();
+
+ // when
+ final VTPValidateCSAR.CSARValidation csarValidation = VTPValidateCSAR.createCsarValidationFor(csarArchive);
+
+ // then
+ final VTPValidateCSAR.CSARValidation.VNF vnf = csarValidation.getVnf();
+ assertThat(vnf.getName()).isEqualTo("productName");
+ assertThat(vnf.getVendor()).isEqualTo("vendorName");
+ assertThat(vnf.getVersion()).isEqualTo("version");
+ assertThat(vnf.getType()).isEqualTo("TOSCA");
+ assertThat(vnf.getMode()).isEqualTo(CSARArchive.Mode.WITH_TOSCA_META_DIR.toString());
+ }
+
+ private CSARArchive givenCsarArchive() {
+ final CSARArchive csarArchive = new CSARArchive();
+ csarArchive.getToscaMeta().setMode(CSARArchive.Mode.WITH_TOSCA_META_DIR);
+ csarArchive.getToscaMeta().setCompanyName("vendorName");
+
+ final CSARArchive.Manifest.Metadata metadata = new CSARArchive.Manifest.Metadata();
+ metadata.setProductName("productName");
+ metadata.setPackageVersion("version");
+ csarArchive.getManifest().setMetadata(metadata);
+ return csarArchive;
+ }
+
+}
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplateDifferentSectionOrder.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplateDifferentSectionOrder.mf
new file mode 100644
index 0000000..4bff664
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplateDifferentSectionOrder.mf
@@ -0,0 +1,68 @@
+metadata:
+ pnfd_name: RadioNode
+ pnfd_provider: Ericsson
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-01-14T11:25:00+00:00
+
+non_mano_artifact_sets:
+
+ onap_ves_events:
+ source: Artifacts/Events/VES_registration.yml
+
+ onap_pm_dictionary:
+ source: Artifacts/Measurements/PM_Dictionary.yaml
+
+ onap_yang_module:
+ source: Artifacts/Yang_module/Yang_module.yaml
+
+ onap_others:
+ source: Artifacts/scripts/install.sh
+ source: Artifacts/Informational/user_guide.txt
+ source: Artifacts/Other/installation_guide.txt
+ source: Artifacts/Other/review_log.txt
+
+Source: MRF.yaml
+Algorithm: SHA-256
+Hash: 09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943
+
+Source: scripts/install.sh
+Algorithm: SHA-256
+Hash: d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b
+
+Source: https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/Events/VES_registration.yml
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/Measurements/PM_Dictionary.yaml
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/Yang_module/Yang_module.yaml
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/scripts/install.sh
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/Informational/user_guide.txt
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/Other/installation_guide.txt
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+Source: Artifacts/Other/review_log.txt
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+-----BEGIN CMS-----
+MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN
+AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM
+dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=
+-----END CMS-----