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=0340e04cd64cf31c5bde3545e27b85cf97857735;hb=490fc3c1fafe50d5fb0e23db5cfd10730be96866;hp=7ce3fcfd53119317a9708b1eb1ae62e057ea10e1;hpb=58401075a66f7c5963848a7349067f995fe4f947;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 7ce3fcf..0340e04 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 @@ -1,12 +1,12 @@ /** - * Copyright 2017 ZTE Corporation. - * + * Copyright 2017-2020 ZTE Corporation. + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,14 +15,7 @@ */ package org.onap.holmes.common.aai; -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; -import static org.powermock.api.mockito.PowerMockito.when; -import java.util.HashMap; -import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -39,12 +32,19 @@ import org.onap.holmes.common.config.MicroServiceConfig; import org.onap.holmes.common.exception.CorrelationException; import org.onap.holmes.common.utils.HttpsUtils; import org.powermock.api.easymock.PowerMock; -import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; +import java.util.HashMap; +import java.util.Map; + +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.expect; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.Assert.assertThat; + @PrepareForTest({AaiQuery.class, HttpsUtils.class, MicroServiceConfig.class, HttpGet.class}) @PowerMockIgnore("javax.net.ssl.*") @@ -153,7 +153,7 @@ public class AaiQueryTest { PowerMock.mockStatic(MicroServiceConfig.class); PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2") .andReturn("/aai/v11/cloud-infrastructure"); - PowerMock.expectPrivate(httpClient,"close"); + PowerMock.expectPrivate(httpClient, "close"); EasyMock.expectLastCall(); PowerMock.replayAll(); Whitebox.invokeMethod(aaiQuery, "getAaiVmData", "test1", "test2"); @@ -179,7 +179,6 @@ public class AaiQueryTest { } - @Test public void testAaiQuery_getResourceLinksResponse() throws Exception { PowerMock.resetAll(); @@ -188,9 +187,6 @@ public class AaiQueryTest { aaiResponseUtil = new AaiResponseUtil(); Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil); - PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("host_url"); - PowerMock.expectPrivate(aaiQuery, "getResponse", anyObject(String.class)).andReturn("").anyTimes(); PowerMock.replayAll(); String resource = Whitebox.invokeMethod(aaiQuery, "getResourceLinksResponse", "test1", "test2"); @@ -207,9 +203,6 @@ public class AaiQueryTest { aaiResponseUtil = new AaiResponseUtil(); Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil); - PowerMockito.mockStatic(MicroServiceConfig.class); - when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("host_url"); - PowerMock.expectPrivate(aaiQuery, "getResponse", anyObject(String.class)).andReturn("").anyTimes(); PowerMock.replayAll(); String resource = Whitebox.invokeMethod(aaiQuery, "getVnfDataResponse", "test1", "test2"); @@ -294,24 +287,12 @@ public class AaiQueryTest { PowerMock.resetAll(); aaiQuery = new AaiQuery(); - PowerMockito.mockStatic(MicroServiceConfig.class); + PowerMock.mockStatic(MicroServiceConfig.class); PowerMock.replayAll(); - String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "/url"); + String actual = Whitebox.invokeMethod(aaiQuery, "getBaseUrl", "/url"); PowerMock.verifyAll(); assertThat(actual, equalTo("https://aai.onap:8443/url")); } - - @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)); - } }