aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-03-22 14:49:33 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-03-22 15:10:23 +0000
commit8c6980a4b3bf7ddcff8cc5757c29961385222606 (patch)
tree29a31ce94503e4a3c7389d413b586d6597648822 /src/test
parent7deeb1fce8a48a5480c800b49dcfb1827d92a475 (diff)
Simplify VNF Vendor Image extraction
Refactoring of the software version extraction routines to reduce complexity. Pass the NodeTemplates directly to the extractSoftwareVersions() method and move the exception handling up the calling stack. Remove the creation/usage of an intermediate Pair object. Query for the Service VF list once only. Use Streams rather than converting from Stream to List and back. This change will simplify future work: either to convert sdc-tosca API methods (that will be deprecated), or to use an alternative parser. Change-Id: I745ced9e6095f389ee1bede37e8480dfaf65716a Issue-ID: AAI-2281 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractorTest.java22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/test/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractorTest.java b/src/test/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractorTest.java
index a6f98b8..7a076c5 100644
--- a/src/test/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractorTest.java
+++ b/src/test/java/org/onap/aai/babel/csar/vnfcatalog/VnfVendorImageExtractorTest.java
@@ -95,24 +95,16 @@ public class VnfVendorImageExtractorTest {
SdcToscaHelper helper = new SdcToscaHelper();
List<String> versions;
- try {
- versions = extractor.extractSoftwareVersions(helper.buildMappings());
- assertThat(versions.size(), is(0));
- } catch (ToscaToCatalogException e) {
- assertThat(e.getMessage(), containsString("No software versions"));
- }
+ versions = extractor.extractSoftwareVersions(helper.buildMappings().getNodeTemplates());
+ assertThat(versions.size(), is(0));
helper.addNodeTemplate();
- try {
- versions = extractor.extractSoftwareVersions(helper.buildMappings());
- assertThat(versions.size(), is(0));
- } catch (ToscaToCatalogException e) {
- assertThat(e.getMessage(), containsString("No software versions"));
- }
+ versions = extractor.extractSoftwareVersions(helper.buildMappings().getNodeTemplates());
+ assertThat(versions.size(), is(0));
helper.addNodeTemplate("string");
try {
- versions = extractor.extractSoftwareVersions(helper.buildMappings());
+ versions = extractor.extractSoftwareVersions(helper.buildMappings().getNodeTemplates());
assertThat(versions.size(), is(0));
} catch (ClassCastException e) {
assertThat(e.getMessage(), containsString("java.lang.String"));
@@ -122,7 +114,7 @@ public class VnfVendorImageExtractorTest {
images.put("image", "string");
helper.addNodeTemplate(images);
try {
- versions = extractor.extractSoftwareVersions(helper.buildMappings());
+ versions = extractor.extractSoftwareVersions(helper.buildMappings().getNodeTemplates());
assertThat(versions.size(), is(1));
} catch (ClassCastException e) {
assertThat(e.getMessage(), containsString("java.lang.String"));
@@ -133,7 +125,7 @@ public class VnfVendorImageExtractorTest {
images.put("image", image);
helper = new SdcToscaHelper();
helper.addNodeTemplate(images);
- versions = extractor.extractSoftwareVersions(helper.buildMappings());
+ versions = extractor.extractSoftwareVersions(helper.buildMappings().getNodeTemplates());
assertThat(versions.size(), is(1));
assertThat(versions.get(0), is("1.2.3"));
}