X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Faai%2FAaiQueryTest.java;h=b3f1eb6c45c9cbede96c262cdf96ce4aceccbe9e;hb=1be6bdd6b55219294a9ce6f708433fef3737cc13;hp=59f8848b3e252e513939cb39831ea68889fa937b;hpb=c9ed775685b01f5622618216748eeac3000285c4;p=holmes%2Fcommon.git 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 59f8848..b3f1eb6 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 @@ -93,13 +93,14 @@ public class AaiQueryTest { headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID); headers.put("Authorization", AaiConfig.getAuthenticationCredentials()); headers.put("Accept", "application/json"); - String url = "host_url"; + String url = "http://10.96.33.33/api/aai-cloudInfrastructure/v11"; when(HttpsUtils.get(url, headers)).thenReturn("{}"); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url"); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80"); - PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2").andReturn(""); + PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2") + .andReturn("/aai/v11/cloud-infrastructure"); PowerMock.replayAll(); VmEntity vmEntity = Whitebox.invokeMethod(aaiQuery, "getAaiVmData", "test1", "test2"); PowerMock.verifyAll(); @@ -125,14 +126,15 @@ public class AaiQueryTest { headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID); headers.put("Authorization", AaiConfig.getAuthenticationCredentials()); headers.put("Accept", "application/json"); - String url = "host_url"; + String url = "http://10.96.33.33/api/aai-cloudInfrastructure/v11"; when(HttpsUtils.get(url, headers)).thenReturn(""); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url"); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80"); - PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2").andReturn(""); + PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2") + .andReturn("/aai/v11/cloud-infrastructure"); PowerMock.replayAll(); Whitebox.invokeMethod(aaiQuery, "getAaiVmData", "test1", "test2"); @@ -155,14 +157,15 @@ public class AaiQueryTest { headers.put("X-FromAppId", AaiConfig.X_FROMAPP_ID); headers.put("Authorization", AaiConfig.getAuthenticationCredentials()); headers.put("Accept", "application/json"); - String url = "host_url"; + String url = "http://10.96.33.33/api/aai-cloudInfrastructure/v11"; when(HttpsUtils.get(url, headers)).thenThrow(new CorrelationException("")); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url"); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80"); - PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2").andReturn(""); + PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2") + .andReturn("/aai/v11/cloud-infrastructure"); PowerMock.replayAll(); Whitebox.invokeMethod(aaiQuery, "getAaiVmData", "test1", "test2"); PowerMock.verifyAll(); @@ -213,7 +216,7 @@ public class AaiQueryTest { Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url"); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("host_url"); PowerMock.expectPrivate(aaiQuery, "getResponse", anyObject(String.class)).andReturn("").anyTimes(); PowerMock.replayAll(); @@ -232,7 +235,7 @@ public class AaiQueryTest { Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url"); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("host_url"); PowerMock.expectPrivate(aaiQuery, "getResponse", anyObject(String.class)).andReturn("").anyTimes(); PowerMock.replayAll(); @@ -277,15 +280,11 @@ public class AaiQueryTest { headers.put("Authorization", AaiConfig.getAuthenticationCredentials()); headers.put("Accept", "application/json"); String url = "host_url"; - when(HttpsUtils.get(url, headers)).thenThrow(new CorrelationException("")); - PowerMock.replayAll(); String resource = Whitebox.invokeMethod(aaiQuery, "getResponse", "host_url"); PowerMock.verifyAll(); - assertThat(resource, equalTo("")); - } @Test @@ -308,13 +307,13 @@ public class AaiQueryTest { aaiQuery = new AaiQuery(); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenReturn("msb"); - when(MicroServiceConfig.getServiceAddrInfoFromCBS("nihao")).thenReturn(""); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80"); + when(MicroServiceConfig.getServiceConfigInfoFromCBS("nihao")).thenReturn(""); PowerMock.replayAll(); - String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "url"); + String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "/url"); PowerMock.verifyAll(); - assertThat(actual, equalTo("msburl")); + assertThat(actual, equalTo("http://10.96.33.33/url")); } @Test @@ -323,14 +322,14 @@ public class AaiQueryTest { aaiQuery = new AaiQuery(); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenThrow(new NullPointerException()); - when(MicroServiceConfig.getServiceAddrInfoFromCBS("aai_config")).thenReturn("aai"); + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenThrow(new NullPointerException()); + when(MicroServiceConfig.getServiceConfigInfoFromCBS("aai_config")).thenReturn("aai"); PowerMock.replayAll(); String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "url"); System.out.println(actual); PowerMock.verifyAll(); - assertThat(actual, equalTo("https:\\\\aaiurl")); + assertThat(actual, equalTo("https://aaiurl")); } @Test @@ -339,8 +338,8 @@ public class AaiQueryTest { aaiQuery = new AaiQuery(); PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddr()).thenThrow(new NullPointerException()); - when(MicroServiceConfig.getServiceAddrInfoFromCBS("aai_config")) + when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenThrow(new NullPointerException()); + when(MicroServiceConfig.getServiceConfigInfoFromCBS("aai_config")) .thenThrow(new NullPointerException()); PowerMock.replayAll(); @@ -354,7 +353,7 @@ public class AaiQueryTest { public void testAaiQuery_getMsbSuffixAddr_Ok() throws Exception { PowerMock.resetAll(); String url = "/aai/v11/network/generic-vnfs/generic-vnf?"; - String expect = "/aai/network/v11/generic-vnfs/generic-vnf?"; + String expect = "/api/aai-network/v11/generic-vnfs/generic-vnf?"; aaiQuery = new AaiQuery(); PowerMock.replayAll(); String actual = Whitebox.invokeMethod(aaiQuery, "getMsbSuffixAddr", url);