aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java
diff options
context:
space:
mode:
authorTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>2019-07-18 03:41:57 -0400
committerTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>2019-07-18 03:41:57 -0400
commit0f54454a7f6a26b42aa78c228d63a74f9a619a78 (patch)
tree679d8c181fcb848c612b4e17b7c8724ab6a572ef /vid-app-common/src/test/java
parentdb98c7976e57f8bacbcc93b802b4d05b1db7b8cf (diff)
junits for AaiController
-Added new test for getVersionByInvariantId method Change-Id: Iba77e8638047ba20ac80816b779575ce5e32df86 Issue-ID: VID-478 Signed-off-by: Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
index 301101399..2df28d973 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
@@ -22,7 +22,9 @@
package org.onap.vid.controller;
import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -34,6 +36,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import java.util.Map;
import java.util.UUID;
+import javax.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,6 +53,7 @@ import org.onap.vid.aai.model.PortDetailsTranslator.PortDetails;
import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsError;
import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsOk;
import org.onap.vid.aai.util.AAIRestInterface;
+import org.onap.vid.model.VersionByInvariantIdsRequest;
import org.onap.vid.roles.RoleProvider;
import org.onap.vid.services.AaiService;
import org.onap.vid.utils.SystemPropertiesWrapper;
@@ -224,5 +228,24 @@ public class AaiControllerTest {
.andExpect(status().isOk())
.andExpect(content().string(expectedResponseBody));
}
+
+ @Test
+ public void getVersionByInvariantId_shouldReturnOKResponse() throws Exception {
+ String expectedResponse = "OKResponse";
+ VersionByInvariantIdsRequest request = new VersionByInvariantIdsRequest();
+ request.versions = ImmutableList.of("ver1", "ver2");
+ Response response = mock(Response.class);
+ given(response.readEntity(String.class)).willReturn(expectedResponse);
+ given(aaiService
+ .getVersionByInvariantId(request.versions)).willReturn(response);
+
+ mockMvc.perform(
+ post("/aai_get_version_by_invariant_id")
+ .content(new ObjectMapper().writeValueAsString(request))
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponse));
+ }
}