summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-05-27 14:24:13 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-05-30 11:08:38 +0200
commit84eb0c707c621e4855bf27e49be0cc69ded1f321 (patch)
tree3e4a04a9ed0754640da04f7713437d42dea43cd6
parent2b293e3d6c9c2ff693ccebf8ee757980cf6e2499 (diff)
Specification change
Change-Id: I7810f0310d6c2ae178c6d865494fff88c8751634 Issue-ID: VNFSDK-410 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java7
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java14
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java7
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java10
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java15
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java11
7 files changed, 36 insertions, 30 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 0924de7..f1aff70 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
@@ -738,6 +738,8 @@ public class CSARArchive implements AutoCloseable {
}
public static class Manifest{
+ private boolean isNonManoAvailable;
+
public static class Metadata {
private String providerId;
@@ -792,12 +794,17 @@ public class CSARArchive implements AutoCloseable {
this.metadata = metadata;
}
+ public boolean isNonManoAvailable(){
+ return isNonManoAvailable;
+ }
+
public Map<String, Map<String, List<String>>> getNonMano() {
return nonMano;
}
public void setNonMano(Map<String, Map<String, List<String>>> nonMano) {
this.nonMano = nonMano;
+ this.isNonManoAvailable = true;
}
}
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java
index 5ac67cd..6438306 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfCSARArchive.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
public class PnfCSARArchive extends CSARArchive {
@@ -37,15 +38,20 @@ public class PnfCSARArchive extends CSARArchive {
Pair<Manifest.Metadata, List<CSARError>> metadataData = pnfManifestParser.fetchMetadata();
Pair<List<String>, List<CSARError>> sourcesSectionData = pnfManifestParser.fetchSourcesSection();
- Pair<Map<String, Map<String, List<String>>>, List<CSARError>> nonManoArtifactsData = pnfManifestParser.fetchNonManoArtifacts();
+ Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARError>>> nonManoArtifactsData = pnfManifestParser.fetchNonManoArtifacts();
PnfManifest manifest = (PnfManifest) this.getManifest();
manifest.setMetadata(metadataData.getKey());
- manifest.setSources(sourcesSectionData.getKey());
- manifest.setNonMano(nonManoArtifactsData.getKey());
this.getErrors().addAll(metadataData.getValue());
- this.getErrors().addAll(nonManoArtifactsData.getValue());
+
+ manifest.setSources(sourcesSectionData.getKey());
this.getErrors().addAll(sourcesSectionData.getValue());
+
+ if(nonManoArtifactsData.isPresent()){
+ manifest.setNonMano(nonManoArtifactsData.get().getKey());
+ this.getErrors().addAll(nonManoArtifactsData.get().getValue());
+ }
+
}
@Override
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java
index 5ef74fd..8831082 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -118,7 +119,7 @@ class PnfManifestParser {
return Pair.of(sources, errors);
}
- Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> fetchNonManoArtifacts() {
+ Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>>> fetchNonManoArtifacts() {
Map<String, Map<String, List<String>>> nonManoArtifacts = new HashMap<>();
List<CSARArchive.CSARError> errors = new ArrayList<>();
@@ -143,10 +144,10 @@ class PnfManifestParser {
}
if (!isNonManoArtifactsSectionAvailable) {
- errors.add(new PnfCSARErrorEntryMissing(NON_MANO_ARTIFACT_SETS_TAG_SECTION, this.fileName, -1));
+ return Optional.empty();
}
- return Pair.of(nonManoArtifacts, errors);
+ return Optional.of(Pair.of(nonManoArtifacts, errors));
}
private boolean isLineExcluded(String line) {
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java
index 95b35bf..6150a04 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java
@@ -59,10 +59,12 @@ public class VTPValidateCSARR146092 extends VTPValidateCSARBase {
@Override
protected void validateCSAR(CSARArchive csar) {
- Optional<ValidateNonManoSection> validateNonManoSection = ValidateNonManoSection.getInstance(csar);
- if(validateNonManoSection.isPresent()) {
- List<CSARArchive.CSARError> csarErrors = validateNonManoSection.get().validate();
- this.errors.addAll(csarErrors);
+ if(csar.getManifest().isNonManoAvailable()) {
+ Optional<ValidateNonManoSection> validateNonManoSection = ValidateNonManoSection.getInstance(csar);
+ if(validateNonManoSection.isPresent()) {
+ List<CSARArchive.CSARError> csarErrors = validateNonManoSection.get().validate();
+ this.errors.addAll(csarErrors);
+ }
}
}
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 2f3a050..09a2706 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
@@ -67,7 +67,7 @@ public class PnfManifestParserTest {
@Test
public void shouldFetchNonManoArtifactsFromFile() {
- Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> mapListPair = pnfManifestParser.fetchNonManoArtifacts();
+ Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> mapListPair = pnfManifestParser.fetchNonManoArtifacts().get();
Map<String, Map<String, List<String>>> nonManoArtifacts = mapListPair.getKey();
List<CSARArchive.CSARError> errors= mapListPair.getValue();
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
index 91d2648..92733bb 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
@@ -21,14 +21,14 @@ import org.junit.Test;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
+import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
public class PnfNonManoArtifactsParserTest {
@Test
- public void shouldReportAnErrorWhenNonManoArtifactSectionIsNotAvailable() {
+ public void shouldDoNotReportAnErrorWhenNonManoArtifactSectionIsNotAvailable() {
// given
List<String> lines = Lists.newArrayList(
"someSection:",
@@ -40,14 +40,11 @@ public class PnfNonManoArtifactsParserTest {
// when
PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
- Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchNonManoArtifacts();
+ Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>>> nonManoArtifacts =
+ pnfManifestParser.fetchNonManoArtifacts();
//then
- List<CSARArchive.CSARError> errors = data.getRight();
- assertThat(errors.size()).isEqualTo(1);
- assertThat(errors.stream().map(CSARArchive.CSARError::getMessage).collect(Collectors.toList())).contains(
- "Missing. Entry [non_mano_artifact_sets]"
- );
+ assertThat(nonManoArtifacts.isPresent()).isFalse();
}
@Test
@@ -69,7 +66,7 @@ public class PnfNonManoArtifactsParserTest {
// when
PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
- Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchNonManoArtifacts();
+ Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchNonManoArtifacts().get();
//then
List<CSARArchive.CSARError> errors = data.getRight();
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java
index a59282c..ba51882 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java
@@ -43,7 +43,7 @@ public class VTPValidateCSARR146092IntegrationTest {
}
@Test
- public void shouldReportThatMandatoryNonManoArtifactsAreNotAvailable() throws Exception {
+ public void shouldDoNotReportErrorWhenNonManoArtifactIsNotAvailable() throws Exception {
// given
configureTestCase(testCase, "pnf/r146092/missingNonManoArtifactInManifest.csar");
@@ -52,14 +52,7 @@ public class VTPValidateCSARR146092IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(5);
- assertThat(convertToMessagesList(errors)).contains(
- "Missing. Entry [non_mano_artifact_sets]",
- "Missing. Entry [onap_ves_events]",
- "Missing. Entry [onap_pm_dictionary]",
- "Missing. Entry [onap_yang_module]",
- "Missing. Entry [onap_others]"
- );
+ assertThat(errors.size()).isEqualTo(0);
}
@Test