From 0f54454a7f6a26b42aa78c228d63a74f9a619a78 Mon Sep 17 00:00:00 2001 From: Tomasz Gwozdecki Date: Thu, 18 Jul 2019 03:41:57 -0400 Subject: junits for AaiController -Added new test for getVersionByInvariantId method Change-Id: Iba77e8638047ba20ac80816b779575ce5e32df86 Issue-ID: VID-478 Signed-off-by: Tomasz Gwozdecki --- .../org/onap/vid/controller/AaiControllerTest.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'vid-app-common/src/test/java') 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)); + } } -- cgit 1.2.3-korg