summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test/java/org
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 /csarvalidation/src/test/java/org
parente66d2541cf7ee1836784681331b6909421a86d63 (diff)
Improve code quality
Change-Id: I60090d9da403bf8e6c3e5ba77ef4acfd6f41ec2b Issue-ID: VNFSDK-449 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'csarvalidation/src/test/java/org')
-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
2 files changed, 81 insertions, 1 deletions
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;
+ }
+
+}