From 5728f2d081afbf4c89d2128ba952200877155f7d Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Wed, 12 Sep 2018 17:44:19 +0530 Subject: Fixed CCVPN closed loop integration issue 1.Service instance will be single instance not list of instances 2.URL for AAI query has to be modified. Issue-ID: HOLMES-166 Change-Id: I205917531f15ece9a32c61bd5bf0e26f1b089c12 Signed-off-by: Vidyashree Rama --- .../onap/holmes/common/aai/AaiQuery4CcvpnTest.java | 50 +++++++------------ holmes-actions/src/test/resources/ccvpn.data.json | 57 ++++------------------ 2 files changed, 27 insertions(+), 80 deletions(-) (limited to 'holmes-actions/src/test') diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQuery4CcvpnTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQuery4CcvpnTest.java index c094e4f..b75e61d 100644 --- a/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQuery4CcvpnTest.java +++ b/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQuery4CcvpnTest.java @@ -14,7 +14,6 @@ package org.onap.holmes.common.aai; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.easymock.EasyMock; import org.glassfish.jersey.client.HttpUrlConnectorProvider; @@ -194,16 +193,16 @@ public class AaiQuery4CcvpnTest { PowerMock.replayAll(); - JSONArray instances = aai.getServiceInstances("network-1", "pnf-1", "interface-1", "DOWN"); + JSONObject instance = aai.getServiceInstance("network-1", "pnf-1", "interface-1", "DOWN"); PowerMock.verifyAll(); - assertThat(instances, equalTo("logic-link-1")); + assertThat(instance, equalTo("logic-link-1")); } @Test - public void test_getServiceInstances() { + public void test_getServiceInstance() { mockGetMethod(); EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("vpn-binding").toJSONString()); EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK); @@ -222,32 +221,19 @@ public class AaiQuery4CcvpnTest { .andReturn(data.getJSONObject("service-instances-by-service-type").toJSONString()); EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK); - mockGetMethod(); - EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("service-instance").toString()); - EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK); - mockGetMethod(); - EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("service-instance").toString()); - EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK); - mockGetMethod(); - EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("service-instance").toString()); - EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK); - PowerMock.replayAll(); - JSONArray instances = aai.getServiceInstances("network-1", "pnf-1", "interface-1", "DOWN"); + JSONObject instance = aai.getServiceInstance("network-1", "pnf-1", "interface-1", "DOWN"); PowerMock.verifyAll(); - assertThat(instances.getJSONObject(0).getString("service-instance-id"), equalTo("some id 1")); - assertThat(instances.getJSONObject(1).getString("service-instance-id"), equalTo("some id 2")); - assertThat(instances.getJSONObject(2).getString("service-instance-id"), equalTo("some id 3")); - assertThat(instances.getJSONObject(0).getString("input-parameters"), equalTo("This is the service instance recreation input looked up by CL.")); - assertThat(instances.getJSONObject(0).getString("globalSubscriberId"), equalTo("e151059a-d924-4629-845f-264db19e50b4")); - assertThat(instances.getJSONObject(0).getString("serviceType"), equalTo("volte")); + assertThat(instance.getString("service-instance-id"), equalTo("some id 1")); + assertThat(instance.getString("globalSubscriberId"), equalTo("e151059a-d924-4629-845f-264db19e50b4")); + assertThat(instance.getString("serviceType"), equalTo("volte")); } @Test - public void test_getServiceInstances_1() throws Exception { + public void test_getServiceInstance_1() throws Exception { mockGetMethod(); EasyMock.expect(response.readEntity(String.class)) .andReturn(data.getJSONObject("service-instances-by-service-type").toJSONString()); @@ -255,18 +241,16 @@ public class AaiQuery4CcvpnTest { PowerMock.replayAll(); - JSONArray instances = (JSONArray) Whitebox.invokeMethod(aai, "getServiceInstances", - "custom-1", "service-type-1"); + JSONObject instance = Whitebox.invokeMethod(aai, "getServiceInstance", + "custom-1", "service-type-1"); PowerMock.verifyAll(); - assertThat(instances.getJSONObject(0).getString("service-instance-id"), equalTo("some id 1")); - assertThat(instances.getJSONObject(1).getString("service-instance-id"), equalTo("some id 2")); - assertThat(instances.getJSONObject(2).getString("service-instance-id"), equalTo("some id 3")); + assertThat(instance.getString("service-instance-id"), equalTo("some id 1")); } @Test - public void test_getServiceInstances_1_exception() throws Exception { + public void test_getServiceInstance_1_exception() throws Exception { mockGetMethod(); EasyMock.expect(response.readEntity(String.class)).andReturn("Failed to get the service instance by type."); EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.NOT_FOUND).times(2); @@ -275,14 +259,14 @@ public class AaiQuery4CcvpnTest { PowerMock.replayAll(); - JSONArray instances = (JSONArray) Whitebox.invokeMethod(aai, "getServiceInstances", - "custom-1", "service-type-1"); + JSONObject instance = Whitebox.invokeMethod(aai, "getServiceInstance", + "custom-1", "service-type-1"); PowerMock.verifyAll(); - assertThat(instances.getJSONObject(0).getString("service-instance-id"), equalTo("some id 1")); - assertThat(instances.getJSONObject(1).getString("service-instance-id"), equalTo("some id 2")); - assertThat(instances.getJSONObject(2).getString("service-instance-id"), equalTo("some id 3")); + assertThat(instance.getString("service-instance-id"), equalTo("some id 1")); + assertThat(instance.getString("service-instance-id"), equalTo("some id 2")); + assertThat(instance.getString("service-instance-id"), equalTo("some id 3")); } @Test diff --git a/holmes-actions/src/test/resources/ccvpn.data.json b/holmes-actions/src/test/resources/ccvpn.data.json index 773b91b..5f47cd1 100644 --- a/holmes-actions/src/test/resources/ccvpn.data.json +++ b/holmes-actions/src/test/resources/ccvpn.data.json @@ -1,5 +1,6 @@ { "resource-version": "1536316872154", + "link-type": "VL", "logic-link": { "p-interface": { "interface-name": "{ifName}", @@ -98,7 +99,7 @@ "relationship": [ { "related-to": "service-instance", - "related-link": "/aai/v14/business/customers/customer/e151059a-d924-4629-845f-264db19e50b4/service-subscriptions/service-subscription/volte/service-instances?service-instance-id=service-1", + "related-link": "/aai/v14/business/customers/customer/e151059a-d924-4629-845f-264db19e50b4/service-subscriptions/service-subscription/volte/service-instances/service-instance/service-1", "relationship-data": [ { "relationship-key": "service-instance.service-instance-id", @@ -111,52 +112,14 @@ } }, "service-instances-by-service-type": { - "results": [ - { - "service-subscription": { - "service-type": "volte", - "temp-ub-sub-account-id": "some sub account", - "service-instances": { - "service-instance": [ - { - "service-instance-id": "some id 1", - "service-instance-name": "some name 1", - "environment-context": "some context 1", - "workload-context": "some workload 1", - "relationship-list": { - "relationship": [ - ] - } - }, - { - "service-instance-id": "some id 2", - "service-instance-name": "some name 2", - "environment-context": "some context 2", - "workload-context": "some workload 2", - "relationship-list": { - "relationship": [ - ] - } - }, - { - "service-instance-id": "some id 3", - "service-instance-name": "some name 3", - "environment-context": "some context 3", - "workload-context": "some workload 3", - "relationship-list": { - "relationship": [ - ] - } - } - ] - }, - "relationship-list": { - "relationship": [ - ] - } - } - } - ] + "service-instance-id": "some id 1", + "service-instance-name": "some name 1", + "environment-context": "some context 1", + "workload-context": "some workload 1", + "relationship-list": { + "relationship": [ + ] + } }, "service-instance": { "service-instance-id": "176d9eba-1662-4289-8396-0097b50fd485", -- cgit 1.2.3-korg