diff options
Diffstat (limited to 'common/src/test/java/org')
17 files changed, 38 insertions, 44 deletions
diff --git a/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java b/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java index 587e4841d7..418220778a 100644 --- a/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java +++ b/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java @@ -71,8 +71,6 @@ public class CryptoTest { String encode2String = CryptoUtils.encrypt(testData, testKey); assertNotNull(encode2String); - assertEquals(encodeString,encode2String); - assertEquals(CryptoUtils.decrypt(encodeString, testKey),CryptoUtils.decrypt(encode2String, testKey)); encodeString = CryptoUtils.encryptCloudConfigPassword(testData); diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java index 1443f04f3a..6fca4a1820 100644 --- a/common/src/test/java/org/onap/so/client/RestClientTest.java +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -20,7 +20,8 @@ package org.onap.so.client; -import static org.mockito.Matchers.any; + +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -39,8 +40,9 @@ import javax.ws.rs.core.UriBuilderException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.ArgumentMatchers; import org.onap.so.utils.TargetEntity; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class RestClientTest { @@ -55,7 +57,7 @@ public class RestClientTest { RestClient spy = buildSpy(); RestRequest mockCallable = mock(RestRequest.class); when(mockCallable.call()).thenThrow(new WebApplicationException(new SocketTimeoutException())); - doReturn(mockCallable).when(spy).buildRequest(any(String.class), any(Object.class)); + doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull()); try { spy.get(); } catch (Exception e) { @@ -70,7 +72,7 @@ public class RestClientTest { RestClient spy = buildSpy(); RestRequest mockCallable = mock(RestRequest.class); when(mockCallable.call()).thenThrow(new WebApplicationException(new NotFoundException())); - doReturn(mockCallable).when(spy).buildRequest(any(String.class), any(Object.class)); + doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull()); try { spy.get(); } catch (Exception e) { diff --git a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java index 40410019f0..f30d2e17aa 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java @@ -25,7 +25,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -34,13 +34,12 @@ import static org.mockito.Mockito.verify; import java.util.Optional; import java.util.UUID; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.aai.entities.Configuration; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUri; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java b/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java index 008b612cd8..0cee366679 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java @@ -33,7 +33,7 @@ import java.util.HashMap; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import com.fasterxml.jackson.core.JsonParseException; @@ -72,9 +72,10 @@ public class AAIPatchConverterTest { AAIPatchConverter validator = new AAIPatchConverter(); HashMap<String, String> map = new HashMap<>(); map.put("ipv4-loopback0-address", ""); + map.put("ipv4-loopback1-address", "192.168.1.1"); String result = validator.marshallObjectToPatchFormat(map); - assertEquals("expect string", "{\"ipv4-loopback0-address\":\"\"}", result); + assertEquals("expect string", "{\"ipv4-loopback1-address\":\"192.168.1.1\"}", result); } @Test diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java index 6e9c38517d..f4b6141b0a 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java @@ -22,7 +22,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -39,7 +39,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.RestClient; import org.onap.so.client.aai.entities.CustomQuery; import org.onap.so.client.aai.entities.uri.AAIResourceUri; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java index 22dc1cac30..32a9ca54a8 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java @@ -96,7 +96,7 @@ public class AAIResourcesClientTest { AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); wireMockRule.stubFor(get( urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) - .withHeader("Authorization", equalTo("Basic TVNPOk1TTw==")) + .withHeader("Authorization", equalTo("Basic dGVzdDp0ZXN0")) .willReturn( aResponse() .withHeader("Content-Type", "application/json") diff --git a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java index 752c49eb5b..6abeea9d9b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai; import static org.hamcrest.CoreMatchers.containsString; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -39,7 +39,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.RestClientSSL; import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; diff --git a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java index 8c42686e5f..428fa276db 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java @@ -23,7 +23,7 @@ package org.onap.so.client.aai; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -35,6 +35,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Optional; +import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.onap.aai.domain.yang.Pserver; @@ -66,7 +67,7 @@ public class AAISingleTransactionClientTest { } @Test - public void testRequest() throws IOException { + public void testRequest() throws JSONException,IOException { AAIResourcesClient client = createClient(); Pserver pserver = new Pserver(); pserver.setHostname("pserver-hostname"); diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java index cbf8d67a82..621375882b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java index fddd1e63ba..8989d6d696 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java @@ -20,7 +20,7 @@ package org.onap.so.client.aai; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class AAIUpdatorTest { diff --git a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java index a2de528d9f..63c7290065 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java @@ -30,7 +30,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pserver; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java b/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java index d4bf1b0224..324be0114d 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java @@ -35,7 +35,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.springframework.util.SerializationUtils; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java index 71ec49789e..0d2da3339a 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai.entities.uri; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java index 26f9d871fd..7e70f2d5f4 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java @@ -29,7 +29,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -181,10 +181,6 @@ public class ServiceInstanceUriTest { ServiceInstanceUri spy = spy(instance); AAIResourcesClient client = createClient(); doReturn(client).when(spy).getResourcesClient(); - /*AAIResultWrapper wrapper = mock(AAIResultWrapper.class); - when(client.get(Matchers.<AAIResourceUri>any(AAIResourceUri.class), Matchers.<Class<NotFoundException>>any())).thenReturn(wrapper); - when(wrapper.getJson()).thenReturn("{\"results\":[]}"); - doReturn(client).when(spy).getResourcesClient();*/ stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3")) .willReturn(aResponse() .withStatus(404) diff --git a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java index 7b783762fa..388e89a438 100644 --- a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java +++ b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java @@ -21,44 +21,43 @@ package org.onap.so.client.grm; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static com.github.tomakehurst.wiremock.client.WireMock.*; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; + import java.io.File; import java.nio.file.Files; -import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.ws.rs.core.MediaType; -import ch.qos.logback.classic.spi.ILoggingEvent; -import org.apache.log4j.MDC; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.client.grm.beans.OperationalInfo; -import org.onap.so.client.grm.beans.Property; import org.onap.so.client.grm.beans.ServiceEndPoint; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.client.grm.beans.ServiceEndPointLookupRequest; import org.onap.so.client.grm.beans.ServiceEndPointRequest; -import org.onap.so.client.grm.beans.Version; import org.onap.so.client.grm.exceptions.GRMClientCallFailed; +import org.onap.so.utils.TestAppender; +import org.slf4j.MDC; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.onap.so.utils.TestAppender; +import ch.qos.logback.classic.spi.ILoggingEvent; public class GRMClientTest { @@ -75,8 +74,6 @@ public class GRMClientTest { System.setProperty("mso.config.path", "src/test/resources"); } - private ObjectMapper mapper = new ObjectMapper(); - @Test public void testFind() throws Exception { TestAppender.events.clear(); diff --git a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java index 4cb9bd0e16..46f9de2268 100644 --- a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java +++ b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java @@ -23,9 +23,9 @@ package org.onap.so.client.policy; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import java.io.File; import java.io.IOException; diff --git a/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java b/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java index 89dd2f554f..d66f5f64f7 100644 --- a/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java +++ b/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.sdno; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; |