diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-10-03 07:24:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-10-03 07:24:49 +0000 |
commit | 1a04f3cb5ddf81d5b42a52d1a3a16bce7880d320 (patch) | |
tree | df2a8dc18b0804b33b63eb934307cb035f20a0cb /vid-app-common/src/test/java | |
parent | 6a4bbd8dded066fae4bc034d65a059e41b06661e (diff) | |
parent | ee96ce43b819ff4a65345a03f6336b79b2f3e1b8 (diff) |
Merge changes I3d32b225,I75b554a6
* changes:
add test case of restCall to outgoing request header test
remove unused interface and unused methods
Diffstat (limited to 'vid-app-common/src/test/java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java | 143 | ||||
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java | 10 |
2 files changed, 2 insertions, 151 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java index ea83fde29..792435002 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java @@ -43,8 +43,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.vid.aai.util.HttpClientMode; import org.onap.vid.aai.util.HttpsAuthClient; -import org.onap.vid.changeManagement.RequestDetailsWrapper; -import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.utils.Logging; import org.onap.vid.utils.SystemPropertiesWrapper; @@ -105,46 +103,6 @@ public class RestMsoImplementationTest { assertThat(result).doesNotContainKey("notExistingKey"); } - @Test - public void shouldProperlyGetRestObjectWithRequestInfo() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks(rawData, HttpStatus.ACCEPTED.value(),""); - - // when - RestObjectWithRequestInfo<HttpRequest> response = restMsoImplementation.Get(httpRequest, path, restObject,false); - - // then - assertThat(response.getRequestedUrl()).contains(path); - assertThat(response.getRawData()).isEqualTo(rawData); - assertThat(response.getHttpCode()).isEqualTo(HttpStatus.ACCEPTED.value()); - assertThat(response.getHttpMethod()).isEqualTo(HttpMethod.GET); - } - - @Test( expectedExceptions = GenericUncheckedException.class) - public void shouldThrowExceptionWhenGetRestObjectWithRequestInfoGetsWrongStatus() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks("",HttpStatus.BAD_REQUEST.value(),""); - - // when - restMsoImplementation.Get(httpRequest, "", restObject,false); - } - - @Test( expectedExceptions = MsoTestException.class) - public void shouldThrowExceptionWhenGetRestObjectWithRequestInfoGetsWrongParameters() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - - prepareMocks("",HttpStatus.ACCEPTED.value(),""); - when(systemProperties.getProperty(MsoProperties.MSO_SERVER_URL)).thenReturn("SAMPLE_URL"); - when(mockClient.target("SAMPLE_URL")).thenThrow(new MsoTestException("test-target-exception")); - - // when - restMsoImplementation.Get(httpRequest, "", restObject,false); - } @Test() public void shouldProperlyGetRestObjectForObjectWithRequestInfoAndAcceptCode() { @@ -192,43 +150,6 @@ public class RestMsoImplementationTest { } @Test - public void shouldProperlyDeleteForObject() { - // given - RequestDetails requestDetails = new RequestDetails(); - - RestObject<HttpRequest> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value()); - expectedResponse.setRaw(rawData); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE"); - - // when - RestObject<HttpRequest> response = restMsoImplementation.DeleteForObject(requestDetails, path, HttpRequest.class); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test - public void shouldProperlyPost() { - // given - RequestDetails requestDetails = new RequestDetails(); - RestObject<String> response = new RestObject<>(); - - RestObject<String> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value()); - expectedResponse.setRaw(rawData); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"POST"); - - // when - restMsoImplementation.Post(rawData,requestDetails, path, response); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test public void shouldProperlyPrepareClient() { // given String method = "POST"; @@ -267,70 +188,6 @@ public class RestMsoImplementationTest { restMsoImplementation.restCall(HttpMethod.GET, String.class, null, "", Optional.empty()); } - @Test - public void shouldProperlyPutRestObjectWithProperParametersAndStatusAccepted() { - // given - String method = "PUT"; - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),method); - - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - RestObject<String> response = new RestObject<>(); - - RestObject<String> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value()); - expectedResponse.set(rawData); - - // when - restMsoImplementation.Put("testPutBody", requestDetailsWrapper , path, response); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test - public void shouldProperlyPutRestObjectWithProperParametersAndStatusMultipleChoices() { - // given - String method = "PUT"; - prepareMocks(rawData,HttpStatus.MULTIPLE_CHOICES.value(),method); - - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - RestObject<String> response = new RestObject<>(); - - RestObject<String> expectedResponse = new RestObject<>(); - expectedResponse.setStatusCode(HttpStatus.MULTIPLE_CHOICES.value()); - expectedResponse.set(rawData); - - // when - restMsoImplementation.Put("testPutBody", requestDetailsWrapper , path, response); - - // then - assertThat(response).isEqualToComparingFieldByField(expectedResponse); - } - - @Test( expectedExceptions = MsoTestException.class) - public void shouldThrowExceptionWhenCallsPutWithWrongParameters() { - // given - when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testDeleteException")); - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - - // when - restMsoImplementation.Put(null, requestDetailsWrapper, "", null); - } - - @Test( expectedExceptions = NullPointerException.class) - public void shouldThrowExceptionWhenCallsPutWithWrongObjectType() { - // given - RestObject<HttpRequest> restObject = new RestObject<>(); - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - - prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE"); - - // when - restMsoImplementation.Put(null, requestDetailsWrapper, path, restObject); - } - - - private void prepareMocks(String rawData,int status,String httpMethod) { when(mockClient.target(any(String.class))).thenReturn(webTarget); diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java index c4d447465..414bcf4ac 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java @@ -57,12 +57,10 @@ import org.onap.vid.aai.util.AAIRestInterface; import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.aai.util.ServletRequestHelper; import org.onap.vid.aai.util.SystemPropertyHelper; -import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.controller.filter.PromiseRequestIdFilter; import org.onap.vid.logging.Headers; import org.onap.vid.mso.MsoProperties; import org.onap.vid.mso.RestMsoImplementation; -import org.onap.vid.mso.RestObject; import org.onap.vid.testUtils.TestUtils; import org.onap.vid.utils.Logging; import org.onap.vid.utils.SystemPropertiesWrapper; @@ -125,13 +123,9 @@ public class OutgoingRequestHeadersTest { @DataProvider public Object[][] msoMethods() { return Stream.<ThrowingConsumer<RestMsoImplementation>>of( - - client -> client.Get(new Object(), "/any path", new RestObject<>(), false), client -> client.GetForObject("/any path", Object.class), - client -> client.Post("", "some payload", "/any path", new RestObject<>()), - client -> client.PostForObject("some payload", "/any path", Object.class), - client -> client.Put(Object.class, new RequestDetailsWrapper(), "/any path", new RestObject<>()) - + client -> client.restCall(HttpMethod.DELETE, Object.class, "some payload", "/any path", Optional.of("userId")), + client -> client.PostForObject("some payload", "/any path", Object.class) ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); } |