diff options
author | GuangrongFu <fu.guangrong@zte.com.cn> | 2018-08-22 08:44:41 +0800 |
---|---|---|
committer | GuangrongFu <fu.guangrong@zte.com.cn> | 2018-08-22 10:09:35 +0800 |
commit | c3b07b59b78275e206011bc069ffd97cc65c5ec1 (patch) | |
tree | 67ed56fd0c749ff8a48dc188fd41217c115800ac /holmes-actions/src | |
parent | aa6978f0ab8e81ad3f5b8de549894b63131fde68 (diff) |
Add some comments to public methods
Change-Id: Id6270f32dc6abfa0b4973aadac7c46301d14d0c3
Issue-ID: HOLMES-160
Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'holmes-actions/src')
-rw-r--r-- | holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java | 38 | ||||
-rw-r--r-- | holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQuery4CcvpnTest.java | 10 |
2 files changed, 37 insertions, 11 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java index 42b7bd7..0e28ff9 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn.java @@ -47,6 +47,17 @@ public class AaiQuery4Ccvpn { headers.add("Accept", "application/json"); } + /** + * Query the logic link information for AAI. This method is based on the API: + * https://<AAI host>:<AAI port>/aai/v14/network/network-resources/network-resource/{networkId}/pnfs/pnf/{pnfName}/p-interfaces?interface-name={ifName}&operational-status={status} + * provided by AAI. + * + * @param networkId + * @param pnfName + * @param ifName + * @param status + * @return the ID of the logic link + */ public String getLogicLink(String networkId, String pnfName, String ifName, String status) { Map<String, String> params = new HashMap<>(); params.put("networkId", networkId); @@ -63,6 +74,19 @@ public class AaiQuery4Ccvpn { return extractValueFromJsonArray(linkInfo.getJSONArray("relationship-data"), "logical-link.link-name"); } + /** + * Query all the instances related to a terminal point. This method is mainly based on the API: + * https://<AAI host>:<AAI port>/aai/v14/network/connectivities?connectivity-id={connectivityId} + * and + * https://<AAI host>:<AAI port>/aai/v14/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type} + * provided by AAI. The path for getting the required instance information is: p-interface → vpn-vpnbinding → connectivity → service instance + * + * @param networkId + * @param pnfName + * @param ifName + * @param status + * @return all related service instances in JSONArray format + */ public JSONArray getServiceInstances(String networkId, String pnfName, String ifName, String status) { try { JSONObject vpnBindingInfo = getVpnBindingInfo(networkId, pnfName, ifName, status); @@ -108,8 +132,8 @@ public class AaiQuery4Ccvpn { } } - public JSONObject getVpnBindingInfo(String networkId, String pnfName, - String ifName, String status) throws CorrelationException { + private JSONObject getVpnBindingInfo(String networkId, String pnfName, + String ifName, String status) throws CorrelationException { Map<String, String> params = new HashMap(); params.put("networkId", networkId); params.put("pnfName", pnfName); @@ -123,7 +147,7 @@ public class AaiQuery4Ccvpn { return getInfo(JSONObject.toJSONString(response.getEntity()), "p-interface", "vpn-binding"); } - public JSONObject getConnectivityInfo(String vpnId) throws CorrelationException { + private JSONObject getConnectivityInfo(String vpnId) throws CorrelationException { Response response = get(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_CONN_ADDR, "vpnId", vpnId)); if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { throw new CorrelationException("Failed to connect to AAI. Cause: " @@ -132,7 +156,7 @@ public class AaiQuery4Ccvpn { return getInfo(JSONObject.toJSONString(response.getEntity()), "vpn-binding", "connectivity"); } - public JSONObject getServiceInstanceByConn(String connectivityId) throws CorrelationException { + private JSONObject getServiceInstanceByConn(String connectivityId) throws CorrelationException { Response response = get(getHostAddr(), getPath(AaiConfig.MsbConsts.AAI_SERVICE_INSTANCE_ADDR_4_CCVPN, "connectivityId", connectivityId)); if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { @@ -142,7 +166,7 @@ public class AaiQuery4Ccvpn { return getInfo(JSONObject.toJSONString(response.getEntity()), "connectivity", "service-instance"); } - public JSONArray getServiceInstances(String globalCustomerId, String serviceType) throws CorrelationException { + private JSONArray getServiceInstances(String globalCustomerId, String serviceType) throws CorrelationException { Map<String, String> params = new HashMap(); params.put("global-customer-id", globalCustomerId); params.put("service-type", serviceType); @@ -177,13 +201,13 @@ public class AaiQuery4Ccvpn { return ret; } - public Response get(String host, String path) { + private Response get(String host, String path) { Client client = ClientBuilder.newClient(); WebTarget target = client.target(host).path(path); return target.request().headers(getAaiHeaders()).get(); } - public Response patch(String host, String path, Map<String, Object> body) { + private Response patch(String host, String path, Map<String, Object> body) { Client client = ClientBuilder.newClient(); WebTarget target = client.target(host).path(path); return target.request().headers(getAaiHeaders()).method("PATCH", Entity.json(body)); 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 51cba1c..c7c32eb 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 @@ -211,14 +211,15 @@ public class AaiQuery4CcvpnTest { } @Test - public void test_getServiceInstances_1() throws CorrelationException { + public void test_getServiceInstances_1() throws Exception { mockGetMethod(); EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instances-by-service-type")); EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK); PowerMock.replayAll(); - JSONArray instances = aai.getServiceInstances("custom-1", "service-type-1"); + JSONArray instances = (JSONArray)Whitebox.invokeMethod(aai, "getServiceInstances", + "custom-1", "service-type-1"); PowerMock.verifyAll(); @@ -228,7 +229,7 @@ public class AaiQuery4CcvpnTest { } @Test - public void test_getServiceInstances_1_exception() throws CorrelationException { + public void test_getServiceInstances_1_exception() throws Exception { mockGetMethod(); EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instances-by-service-type")); EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.NOT_FOUND).times(2); @@ -237,7 +238,8 @@ public class AaiQuery4CcvpnTest { PowerMock.replayAll(); - JSONArray instances = aai.getServiceInstances("custom-1", "service-type-1"); + JSONArray instances = (JSONArray)Whitebox.invokeMethod(aai, "getServiceInstances", + "custom-1", "service-type-1"); PowerMock.verifyAll(); |