aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-10-06 08:44:02 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-10-06 11:00:23 +0300
commit81aef70267474eaa2a212958e9b17d424e5d8480 (patch)
treee507bd95219af9e3bc17fa006cc454f96b0b0579 /vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
parent39b185a11e5978991eedd4763415eed51b7c9462 (diff)
all rest calls of AAIRestInterface use doRest method
Issue-ID: VID-253 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: Ie25a8be8d649fe322698c81a969c720dc123c629 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java56
1 files changed, 6 insertions, 50 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
index bf8a5a1bc..2076d83ef 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/AAIRestInterfaceTest.java
@@ -22,7 +22,6 @@ package org.onap.vid.aai.util;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.Response.Status.OK;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -166,12 +165,12 @@ public class AAIRestInterfaceTest {
Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
// when
+ when(builder.build(any(), any())).thenReturn(invocation);
+ when(invocation.invoke()).thenReturn(response);
when(builder.post(Mockito.any(Entity.class))).thenReturn(response);
when(response.getStatusInfo()).thenReturn(OK);
Response finalResponse = testSubject.RestPost("", PATH, payload, false);
- // then
- verify(builder).post(entity);
Assert.assertEquals(response, finalResponse);
}
@@ -182,13 +181,13 @@ public class AAIRestInterfaceTest {
Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
// when
- when(builder.post(Mockito.any(Entity.class))).thenReturn(response);
+ when(builder.build(any(), any())).thenReturn(invocation);
+ when(invocation.invoke()).thenReturn(response);
when(response.getStatusInfo()).thenReturn(BAD_REQUEST);
when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode());
Response finalResponse = testSubject.RestPost("", PATH, payload, false);
// then
- verify(builder).post(entity);
Assert.assertEquals(response, finalResponse);
}
@@ -199,58 +198,15 @@ public class AAIRestInterfaceTest {
Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
// when
- when(builder.post(Mockito.any(Entity.class))).thenThrow(new RuntimeException());
+ when(builder.build(any(), any())).thenReturn(invocation);
+ when(invocation.invoke()).thenThrow(new RuntimeException());
Response finalResponse = testSubject.RestPost("", PATH, payload, false);
// then
- verify(builder).post(entity);
Assert.assertNull(finalResponse);
}
@Test
- public void shouldExecuteRestDeleteMethodWithResponse400() {
- // given
- // when
- when(builder.delete()).thenReturn(response);
- when(response.getStatusInfo()).thenReturn(BAD_REQUEST);
- String reason = "Any reason";
- when(response.readEntity(String.class)).thenReturn(reason);
- when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode());
- boolean finalResponse = testSubject.Delete("", "", PATH);
-
- // then
- verify(builder).delete();
- Assert.assertFalse(finalResponse);
- }
-
- @Test
- public void shouldExecuteRestDeleteMethodWithResponse404() {
- // given
- // when
- when(builder.delete()).thenReturn(response);
- when(response.getStatusInfo()).thenReturn(NOT_FOUND);
- String reason = "Any reason";
- when(response.readEntity(String.class)).thenReturn(reason);
- when(response.getStatus()).thenReturn(NOT_FOUND.getStatusCode());
- boolean finalResponse = testSubject.Delete("", "", PATH);
-
- // then
- verify(builder).delete();
- Assert.assertFalse(finalResponse);
- }
-
- @Test
- public void shouldFailWhenRestDeleteExecuted() {
- // given
- // when
- when(builder.delete()).thenThrow(new RuntimeException());
- boolean finalResponse = testSubject.Delete("", "", PATH);
- // then
- verify(builder).delete();
- Assert.assertFalse(finalResponse);
- }
-
- @Test
public void shouldExecuteRestGetMethodWithResponse200() {
// given
// when