summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-10-02 10:55:06 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-10-02 10:55:06 +0300
commit0d422d4cc6a1580d38216ccf5a51a2acba0a884e (patch)
tree611f89fa2fc9014605603bfe1b6eb8e03e4adee3 /vid-app-common/src/test
parentfdea9e36bd95193d2e920398beee914e4953919c (diff)
enable mso rest client send DELETE request with body
config SUPPRESS_HTTP_COMPLIANCE_VALIDATION directly from RestMsoImplementation, instead of relaying on the jersey client configuration. Also remove Delete method from RestMsoImplementation since it's not used in production code. Issue-ID: VID-657 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: If30d60c6aca9b7d9ab3e6d07b13c1246ed3d67e3
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java75
1 files changed, 2 insertions, 73 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 e1b78740a..ea83fde29 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
@@ -37,6 +37,7 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.JerseyInvocation;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -171,79 +172,6 @@ public class RestMsoImplementationTest {
assertThat(response.getRaw()).isEqualTo(rawData);
}
- @Test()
- public void shouldProperlyDeleteRestObjectWithStatusHttpAccepted() {
- // given
- RestObject<HttpRequest> restObject = new RestObject<>();
-
- prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE");
-
- // when
- restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
-
- // then
- assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED.value());
- }
-
- @Test()
- public void shouldProperlyDeleteRestObjectWithStatusOK() {
- // given
- RestObject<HttpRequest> restObject = new RestObject<>();
-
- prepareMocks(rawData,HttpStatus.OK.value(),"DELETE");
-
- // when
- restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
-
- // then
- assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.OK.value());
- }
-
- @Test()
- public void shouldProperlyReturnFromDeleteWithStatusBadRequest() {
- // given
- RestObject<HttpRequest> restObject = new RestObject<>();
-
- prepareMocks(rawData,HttpStatus.BAD_REQUEST.value(),"DELETE");
-
- // when
- restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
-
- // then
- assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST.value());
- }
-
- @Test()
- public void shouldProperlyReturnFromDeleteWithStatusOtherThenAbove() {
- // given
- RestObject<HttpRequest> restObject = new RestObject<>();
- prepareMocks(rawData,HttpStatus.NOT_EXTENDED.value(),"DELETE");
-
- // when
- restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
-
- // then
- assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.NOT_EXTENDED.value());
- }
-
- @Test( expectedExceptions = MsoTestException.class)
- public void shouldThrowExceptionWhenCallsDeleteWithWrongParameters() {
- // given
- when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testDeleteException"));
-
- // when
- restMsoImplementation.Delete(httpRequest, "testObject", "", null);
- }
-
- @Test( expectedExceptions = NullPointerException.class)
- public void shouldThrowExceptionWhenCallsDeleteWithWrongObjectType() {
- // given
- RestObject<HttpRequest> restObject = new RestObject<>();
- prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE");
-
- // when
- restMsoImplementation.Delete(null, "testObject", path, restObject);
- }
@Test
public void shouldProperlyPostForObject() {
@@ -411,6 +339,7 @@ public class RestMsoImplementationTest {
when(builder.accept(any(String.class))).thenReturn(builder);
when(builder.headers(any(MultivaluedMap.class))).thenReturn(builder);
+ when(builder.property(eq(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION), eq(true))).thenReturn(builder);
when(builder.get()).thenReturn(response);
when(builder.build( eq(httpMethod), any(Entity.class))).thenReturn(jerseyInvocation);