+
+ @Test
+ public void testAaiQuery_getBaseUrl_msb() throws Exception {
+ PowerMock.resetAll();
+ aaiQuery = new AaiQuery();
+
+ PowerMockito.mockStatic(MicroServiceConfig.class);
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80");
+ when(MicroServiceConfig.getServiceConfigInfoFromCBS("nihao")).thenReturn("");
+
+ PowerMock.replayAll();
+ String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "/url");
+ PowerMock.verifyAll();
+ assertThat(actual, equalTo("http://10.96.33.33/url"));
+ }
+
+ @Test
+ public void testAaiQuery_getBaseUrl_aaiurl() throws Exception {
+ PowerMock.resetAll();
+ aaiQuery = new AaiQuery();
+
+ PowerMockito.mockStatic(MicroServiceConfig.class);
+ 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"));
+ }
+
+ @Test
+ public void testAaiQuery_getBaseUrl_exception() throws Exception {
+ PowerMock.resetAll();
+ aaiQuery = new AaiQuery();
+
+ PowerMockito.mockStatic(MicroServiceConfig.class);
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenThrow(new NullPointerException());
+ when(MicroServiceConfig.getServiceConfigInfoFromCBS("aai_config"))
+ .thenThrow(new NullPointerException());
+
+ PowerMock.replayAll();
+ String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "url");
+ System.out.println(actual);
+ PowerMock.verifyAll();
+ assertThat(actual, equalTo(""));
+ }
+
+ @Test
+ public void testAaiQuery_getMsbSuffixAddr_Ok() throws Exception {
+ PowerMock.resetAll();
+ String url = "/aai/v11/network/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);
+ PowerMock.verifyAll();
+ assertThat(actual, equalTo(expect));
+ }