summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorNorm Traxler <normant@amdocs.com>2019-03-08 17:05:05 +0000
committerNorm Traxler <normant@amdocs.com>2019-03-08 17:05:22 +0000
commit716a57bba582e045986de3bdd354baefcf567b21 (patch)
tree9bfc050a58b1d7248003a2d81997f7cbb438faa6 /src/test
parent6e2b5a9df11eb5a1ae455ff3c7a17ff1ad855b2e (diff)
Use direct GET to get service instance
Issue-ID: LOG-999 Change-Id: I2530de89628465055c9464e912cfe4764cb10f3a Signed-off-by: Norm Traxler <normant@amdocs.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java153
-rw-r--r--src/test/resources/junit/customerData.json6
-rw-r--r--src/test/resources/junit/customerDataCustomerIdNotFound.json6
-rw-r--r--src/test/resources/junit/queryNodeDataNullResourceLink.json8
-rw-r--r--src/test/resources/junit/queryNodeDataVcpe.json9
-rw-r--r--src/test/resources/junit/queryNodeDataVfw.json8
-rw-r--r--src/test/resources/junit/serviceInstancevfw.json67
7 files changed, 109 insertions, 148 deletions
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java
index f0c0210..b7fbd33 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdnc/unittest/service/SdncContextBuilderTest.java
@@ -30,8 +30,8 @@ import com.github.jknack.handlebars.internal.Files;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.io.File;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.Collections;
-import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedHashMap;
@@ -43,9 +43,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.aai.restclient.client.RestClient;
import org.onap.pomba.contextbuilder.sdnc.Application;
-import org.onap.pomba.contextbuilder.sdnc.model.ServiceEntity;
import org.onap.pomba.contextbuilder.sdnc.service.rs.RestService;
import org.onap.pomba.contextbuilder.sdnc.util.RestUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -70,15 +68,12 @@ import org.springframework.test.context.web.WebAppConfiguration;
public class SdncContextBuilderTest {
private String testRestHeaders = "testRestHeaders";
- private String servicePath = "/service-subscriptions/service-subscription/vFW/service-instances/service-instance/";
- private String genericVnfPath = "/aai/v11/network/generic-vnfs/generic-vnf/";
+ private String aaiGenericVnfPath = "/aai/v11/network/generic-vnfs/generic-vnf/";
private String genericResourcePath = "/restconf/config/GENERIC-RESOURCE-API:services/service/";
private String portMirrorConfigurationsResourcePath = "/restconf/config/GENERIC-RESOURCE-API:port-mirror-configurations/port-mirror-configuration/3c368d8d-efda-49d4-bbb5-a6465330a230/configuration-data/configuration-operation-information/port-mirror-configuration-request-input";
private String vnfPath = "/restconf/config/VNF-API:vnfs/vnf-list/";
private String serviceInstanceIdVfw = "7d518257-49bd-40ac-8d17-017a726ec12a"; // customerData.json
private String serviceInstanceIdVcpe = "68352304-7bba-4609-8551-0d0b819376c3"; // queryNodeDataVcpe.json
- private String customerIdVfw = "DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2"; // customerData.json
- private String customerIdVcpe = "SDN-ETHERNET-INTERNET";
private String genericVnfId = "d94daff6-7d5b-4d2e-bc99-c9af0754b59d";
private String moduleId = "2c3f8902-f278-4ee3-93cf-9d2364cbafca";
@@ -90,15 +85,7 @@ public class SdncContextBuilderTest {
private String sdncCtxBuilderBasicAuthorization;
//AAI related
@Autowired
- private String aaiBasicAuthorization;
- @Autowired
- private RestClient aaiClient;
- @Autowired
- private String aaiBaseUrl;
- @Autowired
- private String aaiPathToSearchNodeQuery;
- @Autowired
- private String aaiPathToCustomerQuery;
+ private String aaiPathToServiceInstanceQuery;
@Rule
public WireMockRule aaiEnricherRule = new WireMockRule(wireMockConfig().port(9808));
@@ -115,7 +102,7 @@ public class SdncContextBuilderTest {
@Test
public void testRestHeaders() throws Exception {
- HttpHeaders mockHttpHeaders = mock( HttpHeaders.class);
+ HttpHeaders mockHttpHeaders = mock(HttpHeaders.class);
// Test with No Partner Name
final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
@@ -144,7 +131,7 @@ public class SdncContextBuilderTest {
@Test
public void testRestParameterServiceInstanceId() throws Exception {
- HttpHeaders mockHttpHeaders = mock( HttpHeaders.class);
+ HttpHeaders mockHttpHeaders = mock(HttpHeaders.class);
final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
"testRestParameterServiceInstanceId", "test1", sdncCtxBuilderBasicAuthorization);
@@ -157,126 +144,70 @@ public class SdncContextBuilderTest {
}
@Test
- public void testVerifySdncContextBuilder() throws Exception {
-
+ public void testVerifySdncContextBuilderVnfApi() throws Exception {
- HttpHeaders mockHttpHeaders = mock( HttpHeaders.class);
+ HttpHeaders mockHttpHeaders = mock(HttpHeaders.class);
final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
"testVerifyServiceDecomposition", "test1", sdncCtxBuilderBasicAuthorization);
when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl);
- // First try a vFW service instance
-
- String queryNodeVfwUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw;
- addResponse(queryNodeVfwUrl, "junit/queryNodeDataVfw.json", aaiEnricherRule);
-
- String customerVfwUrl = aaiPathToCustomerQuery + customerIdVfw;
- addResponse(customerVfwUrl, "junit/customerData.json", aaiEnricherRule);
-
- String serviceInstanceUrl = aaiPathToCustomerQuery
- + customerIdVfw
- + servicePath
- + serviceInstanceIdVfw;
- addResponse(serviceInstanceUrl, "junit/serviceInstance.json", aaiEnricherRule);
+ String serviceInstanceUrl = MessageFormat.format(aaiPathToServiceInstanceQuery, serviceInstanceIdVfw);
+ addResponse(serviceInstanceUrl, "junit/serviceInstancevfw.json", aaiEnricherRule);
String vnfApiUrl = vnfPath + moduleId;
addResponse(vnfApiUrl, "junit/vnfApiResponse.json", sdncRule);
- String genericVnfUrl = genericVnfPath + genericVnfId + "?depth=all";
+ String genericVnfUrl = aaiGenericVnfPath + genericVnfId + "?depth=all";
addResponse(genericVnfUrl, "junit/genericVnf.json", aaiEnricherRule);
+
Response response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVfw);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ }
- // Now try a vCPE service instance
-
- String queryNodeUrlVcpe = aaiPathToSearchNodeQuery + serviceInstanceIdVcpe;
- addResponse(queryNodeUrlVcpe, "junit/queryNodeDataVcpe.json", aaiEnricherRule);
-
- String customerVcpeUrl = aaiPathToCustomerQuery + customerIdVcpe;
- addResponse(customerVcpeUrl, "junit/customerData.json", aaiEnricherRule);
+ @Test
+ public void testVerifySdncContextBuilderGenericVnf() throws Exception {
+ HttpHeaders mockHttpHeaders = mock(HttpHeaders.class);
+ final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
+ "testVerifyServiceDecomposition", "test1", sdncCtxBuilderBasicAuthorization);
+ when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl);
+
+ String serviceInstanceUrl = MessageFormat.format(aaiPathToServiceInstanceQuery, serviceInstanceIdVcpe);
+ addResponse(serviceInstanceUrl, "junit/serviceInstance.json", aaiEnricherRule);
+ String genericVnfUrl = aaiGenericVnfPath + genericVnfId + "?depth=all";
+ addResponse(genericVnfUrl, "junit/genericVnf.json", aaiEnricherRule);
+
String urlStr = genericResourcePath + serviceInstanceIdVcpe;
addResponse(urlStr, "junit/sdncGenericResponse.json", sdncRule);
addResponse(portMirrorConfigurationsResourcePath, "junit/portMirrorConfigurationsResponse.json", sdncRule);
- response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVcpe);
- assertEquals(Status.OK.getStatusCode(), response.getStatus());
-
- // Try again with no transcactionId
- final MultivaluedMap<String, String> multivaluedMapImpl1 = buildHeaders(
- "testVerifyServiceDecomposition", null, sdncCtxBuilderBasicAuthorization);
- when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl1);
- response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVcpe);
+ Response response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVcpe);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
}
+ @Test
+ public void testVerifySdncContextBuilderNoTransactionId() throws Exception {
- //AAI related
+ HttpHeaders mockHttpHeaders = mock(HttpHeaders.class);
+ final MultivaluedMap<String, String> multivaluedMapImpl = buildHeaders(
+ "testVerifyServiceDecomposition", null, sdncCtxBuilderBasicAuthorization);
+ when(mockHttpHeaders.getRequestHeaders()).thenReturn(multivaluedMapImpl);
+
+ String serviceInstanceUrl = MessageFormat.format(aaiPathToServiceInstanceQuery, serviceInstanceIdVcpe);
+ addResponse(serviceInstanceUrl, "junit/serviceInstance.json", aaiEnricherRule);
- @Test
- public void testObtainResouceLinkBasedOnServiceInstanceFromAai() throws Exception {
- String transactionId = UUID.randomUUID().toString();
- String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw;
- addResponse(queryNodeUrl, "junit/queryNodeDataVfw.json", aaiEnricherRule);
- String customerUrl = aaiPathToCustomerQuery + customerIdVfw;
- addResponse(customerUrl, "junit/customerData.json", aaiEnricherRule);
-
- ServiceEntity serviceEntity = RestUtil.getServiceEntity(aaiClient,
- aaiBaseUrl,
- aaiBasicAuthorization,
- aaiPathToSearchNodeQuery,
- aaiPathToCustomerQuery,
- serviceInstanceIdVfw,
- transactionId);
-
- assertEquals(serviceInstanceIdVfw, serviceEntity.getServiceInstanceId());
- assertEquals("vFW", serviceEntity.getServiceType()); // customerData.json
- assertEquals(customerIdVfw, serviceEntity.getCustomerId()); // queryNodeData-1.json
- assertEquals("DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2",
- serviceEntity.getCustomerName()); // customerData.json
- assertEquals("CUST", serviceEntity.getCustomerType()); // customerData.json
- }
+ String genericVnfUrl = aaiGenericVnfPath + genericVnfId + "?depth=all";
+ addResponse(genericVnfUrl, "junit/genericVnf.json", aaiEnricherRule);
+
+ String urlStr = genericResourcePath + serviceInstanceIdVcpe;
+ addResponse(urlStr, "junit/sdncGenericResponse.json", sdncRule);
- @Test
- public void testObtainResouceLinkBasedOnServiceInstanceFromAaiNullResourceLink() throws Exception {
- String transactionId = UUID.randomUUID().toString();
- String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw;
- addResponse(queryNodeUrl, "junit/queryNodeDataNullResourceLink.json", aaiEnricherRule);
-
- try {
- RestUtil.getServiceEntity(aaiClient,
- aaiBaseUrl,
- aaiBasicAuthorization,
- aaiPathToSearchNodeQuery,
- aaiPathToCustomerQuery,
- serviceInstanceIdVfw,
- transactionId);
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("JSONObject[\"resource-link\"] not found"));
- }
- }
+ addResponse(portMirrorConfigurationsResourcePath, "junit/portMirrorConfigurationsResponse.json", sdncRule);
- @Test
- public void testObtainResouceLinkBasedOnServiceInstanceFromAaiNullCustomerType() throws Exception {
- String transactionId = UUID.randomUUID().toString();
- String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceIdVfw;
- addResponse(queryNodeUrl, "junit/queryNodeDataVfw.json", aaiEnricherRule);
- String customerUrl = aaiPathToCustomerQuery + customerIdVfw;
- addResponse(customerUrl, "junit/customerDataCustomerIdNotFound.json", aaiEnricherRule);
-
- try {
- RestUtil.getServiceEntity(aaiClient,
- aaiBaseUrl,
- aaiBasicAuthorization,
- aaiPathToSearchNodeQuery,
- aaiPathToCustomerQuery,
- serviceInstanceIdVfw,
- transactionId);
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("Customer ID cannot be found from AAI"));
- }
+ Response response = this.service.getContext(httpServletRequest, mockHttpHeaders, serviceInstanceIdVcpe);
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
}
private void addResponse(String url, String responseFile, WireMockRule thisMock) throws IOException {
diff --git a/src/test/resources/junit/customerData.json b/src/test/resources/junit/customerData.json
deleted file mode 100644
index 31e6baa..0000000
--- a/src/test/resources/junit/customerData.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "global-customer-id": "DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2",
- "subscriber-name": "DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2",
- "subscriber-type": "CUST",
- "resource-version": "1526324315029"
-} \ No newline at end of file
diff --git a/src/test/resources/junit/customerDataCustomerIdNotFound.json b/src/test/resources/junit/customerDataCustomerIdNotFound.json
deleted file mode 100644
index e2f71c6..0000000
--- a/src/test/resources/junit/customerDataCustomerIdNotFound.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "global-customer-id": "dummy",
- "subscriber-name": "dummy",
- "subscriber-type": "CUST",
- "resource-version": "1526324315029"
-} \ No newline at end of file
diff --git a/src/test/resources/junit/queryNodeDataNullResourceLink.json b/src/test/resources/junit/queryNodeDataNullResourceLink.json
deleted file mode 100644
index 36eb667..0000000
--- a/src/test/resources/junit/queryNodeDataNullResourceLink.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "result-data": [
- {
- "resource-type": "service-instance",
- "related-link": "/aai/v11/network/vnfcs/vnfc/zrdm5aepdg01vmg003"
- }
- ]
-}
diff --git a/src/test/resources/junit/queryNodeDataVcpe.json b/src/test/resources/junit/queryNodeDataVcpe.json
deleted file mode 100644
index 593ba09..0000000
--- a/src/test/resources/junit/queryNodeDataVcpe.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "result-data": [
- {
- "resource-type": "service-instance",
- "resource-link": "/aai/v11/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/68352304-7bba-4609-8551-0d0b819376c3"
- }
- ]
-}
-
diff --git a/src/test/resources/junit/queryNodeDataVfw.json b/src/test/resources/junit/queryNodeDataVfw.json
deleted file mode 100644
index e827391..0000000
--- a/src/test/resources/junit/queryNodeDataVfw.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "result-data": [
- {
- "resource-type": "service-instance",
- "resource-link": "/aai/v11/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/7d518257-49bd-40ac-8d17-017a726ec12a"
- }
- ]
-} \ No newline at end of file
diff --git a/src/test/resources/junit/serviceInstancevfw.json b/src/test/resources/junit/serviceInstancevfw.json
new file mode 100644
index 0000000..85afe08
--- /dev/null
+++ b/src/test/resources/junit/serviceInstancevfw.json
@@ -0,0 +1,67 @@
+{
+ "service-instance-id": "68352304-7bba-4609-8551-0d0b819376c3",
+ "service-instance-name": "vcpe_svc_vcpesvc_vgmux_201809061919",
+ "service-type": "vFW",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "58f20afd-6ed1-4451-a19d-4fbee4aefa08",
+ "model-version-id": "7b4beec3-04a6-4513-8341-959589d2bd01",
+ "resource-version": "1536261835931",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "project",
+ "related-link": "/aai/v11/business/projects/project/Project-Demonstration",
+ "relationship-data": [
+ {
+ "relationship-key": "project.project-name",
+ "relationship-value": "Project-Demonstration"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/d94daff6-7d5b-4d2e-bc99-c9af0754b59d",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "d94daff6-7d5b-4d2e-bc99-c9af0754b59d"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "vcpe_vnf_vcpevsp_vgmux_0830_201809061919"
+ }
+ ]
+ },
+ {
+ "related-to": "l3-network",
+ "related-link": "/aai/v11/network/l3-networks/l3-network/ca6f5cdc-cf66-4d03-b5c0-3604da0709a6",
+ "relationship-data": [
+ {
+ "relationship-key": "l3-network.network-id",
+ "relationship-value": "ca6f5cdc-cf66-4d03-b5c0-3604da0709a6"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "l3-network.network-name",
+ "property-value": "vcpe_net_mux_gw_201809061919"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/520cc603-a3c4-4ec2-9ef4-ca70facd79c0",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "520cc603-a3c4-4ec2-9ef4-ca70facd79c0"
+ }
+ ]
+ }
+ ]
+ }
+}