aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorPolavarapu, Chaitanya (cp8128) <cp8128@att.com>2019-04-09 17:02:50 -0400
committerTian Lee <TianL@amdocs.com>2019-04-11 16:05:25 +0000
commit0e93cb3b54e7868cfe5b8a85902adc100391da9c (patch)
tree108793d1b7a1e196917ff268d6d056ab6ee7fdd1 /src/test
parente3de90587ada88dcb3cb0a87fbfe283b2ae9f08b (diff)
Updated to use dublin schema version
Using 1.0.2 schema-service version Fixed the junit test failure for default service version Issue-ID: AAI-2338 Change-Id: Ie0ddda41f6895ff0ce8e97ad065fb935462e643a Signed-off-by: Polavarapu, Chaitanya (cp8128) <cp8128@att.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java50
-rw-r--r--src/test/java/org/onap/aai/babel/testdata/CsarTest.java25
-rw-r--r--src/test/resources/response/responseWithVersionLessThan1.json1
3 files changed, 74 insertions, 2 deletions
diff --git a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
index d011ba6..45eadb0 100644
--- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
+++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
@@ -103,6 +103,56 @@ public class TestGenerateArtifactsServiceImpl {
assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
assertThat(response.getEntity(), is(getResponseJson("response.json")));
}
+
+ /**
+ * Test with a valid request without Minor Artifact version.
+ *
+ * @throws URISyntaxException
+ * if the URI cannot be created
+ * @throws IOException
+ * if the resource cannot be loaded
+ */
+ @Test
+ public void testGenerateArtifactsWithoutMinorArtifactVersion() throws URISyntaxException, IOException {
+ Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("1"),
+ Optional.of("transaction-id"), auth);
+ assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+ assertThat(response.getEntity(), is(getResponseJson("response.json")));
+ }
+
+ /**
+ * Test with a valid request without Minor Artifact version.
+ *
+ * @throws URISyntaxException
+ * if the URI cannot be created
+ * @throws IOException
+ * if the resource cannot be loaded
+ */
+ @Test
+ public void testGenerateArtifactsWithInvalidArtifactVersion() throws URISyntaxException, IOException {
+ Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("a"),
+ Optional.of("transaction-id"), auth);
+ assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+ assertThat(response.getEntity(), is(getResponseJson("response.json")));
+ }
+
+
+ /**
+ * Test with a valid request with Artifact version less than 1.
+ *
+ * @throws URISyntaxException
+ * if the URI cannot be created
+ * @throws IOException
+ * if the resource cannot be loaded
+ */
+ @Test
+ public void testGenerateArtifactsWithArtifactVerLessThan1() throws URISyntaxException, IOException {
+ Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("0.1"),
+ Optional.of("transaction-id"), auth);
+ assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+ assertThat(response.getEntity(), is(getResponseJson("responseWithVersionLessThan1.json")));
+ }
+
/**
* Test with a valid request, using a CSAR file that has no VNF configuration present.
diff --git a/src/test/java/org/onap/aai/babel/testdata/CsarTest.java b/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
index 8b28551..1885555 100644
--- a/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
+++ b/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
@@ -2,8 +2,8 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,12 +39,18 @@ public enum CsarTest {
VNF_VENDOR_CSAR("catalog_csar.csar"),
NO_VNF_CONFIG_CSAR("noVnfConfiguration.csar"),
SD_WAN_CSAR_FILE("service-SdWanServiceTest-csar.csar"),
+ COS_AVPN_CSAR_FILE("service_CosAvpn_csar.csar"),
MISSING_METADATA_CSAR("service-MissingMetadataTest.csar"),
NO_YAML_FILES("noYmlFilesArchive.zip"),
PORT_MIRROR_CSAR("service_PortMirror.csar"),
MULTIPLE_VNF_CSAR("catalog_csar_too_many_vnfConfigurations.csar"),
NETWORK_COLLECTION_CSAR_FILE("service_NetworkCollection.csar"),
+ RG_COLLECTOR_615_CSAR_FILE("service-RgCollector615-csar.csar"),
+ VDBE_SERVICE_CSAR_FILE("service-VdbeSrv-csar.csar"),
+ VNFOD_SERVICE("service-Dev2devnfodservice17July-csar.csar"),
+ CHILD_RESOURCE_CSAR_FILE("service-NetworkCloudVnfServiceMock-csar.csar"),
SERVICE_PROXY_CSAR_FILE("service-S1-csar.csar");
+
// @formatter:on
private String filename;
@@ -102,4 +108,19 @@ public enum CsarTest {
request.setCsar(new String(GeneratorUtil.encode(getContent())));
return new Gson().toJson(request);
}
+
+ /**
+ * Create a BabelRequest containing the encoded CSAR content by passing in the artifact version.
+ *
+ * @return a new Babel request for this CSAR
+ * @throws IOException
+ * if an I/O exception occurs
+ */
+ public String getJsonRequestWithArtifactVersion(String artifactVersion) throws IOException {
+ BabelRequest request = new BabelRequest();
+ request.setArtifactName(getName());
+ request.setArtifactVersion(artifactVersion);
+ request.setCsar(new String(GeneratorUtil.encode(getContent())));
+ return new Gson().toJson(request);
+ }
}
diff --git a/src/test/resources/response/responseWithVersionLessThan1.json b/src/test/resources/response/responseWithVersionLessThan1.json
new file mode 100644
index 0000000..2ffeff6
--- /dev/null
+++ b/src/test/resources/response/responseWithVersionLessThan1.json
@@ -0,0 +1 @@
+[{"name":"AAI-29NFOD_S-service-0.1.xml","type":"MODEL","payload":"<model xmlns=\"http://org.onap.aai.inventory/v16\">\n <model-invariant-id>29NFOD_S-invariant-id</model-invariant-id>\n <model-type>service</model-type>\n <model-vers>\n <model-ver>\n <model-version-id>29NFOD_S-version-id</model-version-id>\n <model-name>29NFOD_S</model-name>\n <model-version>0.1</model-version>\n <model-description>29NFOD</model-description>\n <model-elements>\n <model-element>\n <new-data-del-flag>T</new-data-del-flag>\n <cardinality>unbounded</cardinality>\n <model-elements>\n <model-element>\n <new-data-del-flag>T</new-data-del-flag>\n <cardinality>unbounded</cardinality>\n <model-elements/>\n <relationship-list>\n <relationship>\n <related-to>model-ver</related-to>\n <relationship-data>\n <relationship-key>model-ver.model-version-id</relationship-key>\n <relationship-value>29NFOD 0-version-id</relationship-value>\n </relationship-data>\n <relationship-data>\n <relationship-key>model.model-invariant-id</relationship-key>\n <relationship-value>29NFOD 0-invariant-id</relationship-value>\n </relationship-data>\n </relationship>\n </relationship-list>\n </model-element>\n </model-elements>\n <relationship-list>\n <relationship>\n <related-to>model-ver</related-to>\n <relationship-data>\n <relationship-key>model-ver.model-version-id</relationship-key>\n <relationship-value>service-instance-version-id</relationship-value>\n </relationship-data>\n <relationship-data>\n <relationship-key>model.model-invariant-id</relationship-key>\n <relationship-value>service-instance-invariant-id</relationship-value>\n </relationship-data>\n </relationship>\n </relationship-list>\n </model-element>\n </model-elements>\n </model-ver>\n </model-vers>\n</model>"},{"name":"AAI-29NFOD-resource-1.0.xml","type":"MODEL","payload":"<model xmlns=\"http://org.onap.aai.inventory/v16\">\n <model-invariant-id>29NFOD 0-invariant-id</model-invariant-id>\n <model-type>resource</model-type>\n <model-vers>\n <model-ver>\n <model-version-id>29NFOD 0-version-id</model-version-id>\n <model-name>29NFOD</model-name>\n <model-version>1.0</model-version>\n <model-description>29NFOD</model-description>\n <model-elements>\n <model-element>\n <new-data-del-flag>T</new-data-del-flag>\n <cardinality>unbounded</cardinality>\n <model-elements/>\n <relationship-list>\n <relationship>\n <related-to>model-ver</related-to>\n <relationship-data>\n <relationship-key>model-ver.model-version-id</relationship-key>\n <relationship-value>generic-vnf-version-id</relationship-value>\n </relationship-data>\n <relationship-data>\n <relationship-key>model.model-invariant-id</relationship-key>\n <relationship-value>generic-vnf-invariant-id</relationship-value>\n </relationship-data>\n </relationship>\n </relationship-list>\n </model-element>\n </model-elements>\n </model-ver>\n </model-vers>\n</model>"},{"name":"vnfVendorImageConfigurations","type":"VNFCATALOG","payload":"[{\"application\":\"VM00\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.1\"},{\"application\":\"VM00\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.9\"},{\"application\":\"VM01\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.1\"},{\"application\":\"VM01\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.9\"}]"}]