summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/test
diff options
context:
space:
mode:
authorGuangrongFu <fu.guangrong@zte.com.cn>2018-08-31 13:57:43 +0800
committerGuangrongFu <fu.guangrong@zte.com.cn>2018-08-31 14:33:25 +0800
commitc7fd788a1cfc030e54047701b1c1f27e42a91d1c (patch)
treeb66ad43ad00660c284eaffc57d8fb971bec44cfe /holmes-actions/src/test
parent67ef2af341cbe8530437f67bbffdc7721f4e5587 (diff)
Add some logs to AAI queries
Change-Id: I20c78f7fafe23f1fdcb0161e05d19c6c8c9ec1cd Issue-ID: HOLMES-160 Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/test')
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQuery4CcvpnTest.java36
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQueryTest.java6
2 files changed, 25 insertions, 17 deletions
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 43cb517..51c3444 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
@@ -121,11 +121,12 @@ public class AaiQuery4CcvpnTest {
}
@Test
- public void test_getLogicLink_exception() {
+ public void test_getLogicLink_exception() throws CorrelationException {
mockGetMethod();
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.NOT_FOUND).times(2);
+ EasyMock.expect(response.readEntity(String.class)).andReturn("Error!");
- thrown.expect(RuntimeException.class);
+ thrown.expect(CorrelationException.class);
PowerMock.replayAll();
@@ -138,9 +139,9 @@ public class AaiQuery4CcvpnTest {
}
@Test
- public void test_getLogicLink() {
+ public void test_getLogicLink() throws CorrelationException {
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("logic-link"));
+ EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("logic-link").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
PowerMock.replayAll();
@@ -156,19 +157,21 @@ public class AaiQuery4CcvpnTest {
@Test
public void test_getServiceInstances_exception() {
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("vpn-binding"));
+ EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("vpn-binding").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("connectivity"));
+ EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("connectivity").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instance-by-connectivity"));
+ EasyMock.expect(response.readEntity(String.class))
+ .andReturn(data.getJSONObject("service-instance-by-connectivity").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instances-by-service-type"));
+ EasyMock.expect(response.readEntity(String.class))
+ .andReturn(data.getJSONObject("service-instances-by-service-type").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.NOT_FOUND).times(2);
mockGetMethod();
@@ -190,19 +193,21 @@ public class AaiQuery4CcvpnTest {
@Test
public void test_getServiceInstances() {
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("vpn-binding"));
+ EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("vpn-binding").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("connectivity"));
+ EasyMock.expect(response.readEntity(String.class)).andReturn(data.getJSONObject("connectivity").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instance-by-connectivity"));
+ EasyMock.expect(response.readEntity(String.class))
+ .andReturn(data.getJSONObject("service-instance-by-connectivity").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instances-by-service-type"));
+ EasyMock.expect(response.readEntity(String.class))
+ .andReturn(data.getJSONObject("service-instances-by-service-type").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
mockGetMethod();
@@ -232,7 +237,8 @@ public class AaiQuery4CcvpnTest {
@Test
public void test_getServiceInstances_1() throws Exception {
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instances-by-service-type"));
+ EasyMock.expect(response.readEntity(String.class))
+ .andReturn(data.getJSONObject("service-instances-by-service-type").toJSONString());
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.OK);
PowerMock.replayAll();
@@ -250,7 +256,7 @@ public class AaiQuery4CcvpnTest {
@Test
public void test_getServiceInstances_1_exception() throws Exception {
mockGetMethod();
- EasyMock.expect(response.getEntity()).andReturn(data.getJSONObject("service-instances-by-service-type"));
+ 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);
thrown.expect(CorrelationException.class);
@@ -283,6 +289,7 @@ public class AaiQuery4CcvpnTest {
public void test_updateTerminalPointStatus_exception() throws CorrelationException {
mockPatchMethod();
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.NOT_FOUND).times(2);
+ EasyMock.expect(response.readEntity(String.class)).andReturn("Failed to update the TP information.");
thrown.expect(CorrelationException.class);
@@ -309,6 +316,7 @@ public class AaiQuery4CcvpnTest {
public void test_updateLogicLinkStatus_exception() throws CorrelationException {
mockPatchMethod();
EasyMock.expect(response.getStatusInfo()).andReturn(Response.Status.NOT_FOUND).times(2);
+ EasyMock.expect(response.readEntity(String.class)).andReturn("Failed to update the logic link information.");
thrown.expect(CorrelationException.class);
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQueryTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQueryTest.java
index 42becaa..11dba54 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQueryTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/aai/AaiQueryTest.java
@@ -97,7 +97,7 @@ public class AaiQueryTest {
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
headers.put("Authorization", AaiConfig.getAuthenticationCredentials());
headers.put("Accept", "application/json");
- String url = "http://10.96.33.33/api/aai-cloudInfrastructure/v11";
+ String url = "http://10.96.33.33:80/api/aai-cloudInfrastructure/v11";
HttpResponse httpResponse = PowerMock.createMock(HttpResponse.class);
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
when(HttpsUtils.getHttpClient(30000)).thenReturn(httpClient);
@@ -136,7 +136,7 @@ public class AaiQueryTest {
headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID);
headers.put("Authorization", AaiConfig.getAuthenticationCredentials());
headers.put("Accept", "application/json");
- String url = "http://10.96.33.33/api/aai-cloudInfrastructure/v11";
+ String url = "http://10.96.33.33:80/api/aai-cloudInfrastructure/v11";
CloseableHttpClient httpClient = PowerMock.createMock(CloseableHttpClient.class);
when(HttpsUtils.getHttpClient(30000)).thenReturn(httpClient);
HttpGet httpGet = new HttpGet(url);
@@ -293,7 +293,7 @@ public class AaiQueryTest {
PowerMock.replayAll();
String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "/url");
PowerMock.verifyAll();
- assertThat(actual, equalTo("http://10.96.33.33/url"));
+ assertThat(actual, equalTo("http://10.96.33.33:80/url"));
}
@Test