From 4dc2c4df24d733db6176c738eb9a9ee35a112795 Mon Sep 17 00:00:00 2001 From: Tomasz Gwozdecki Date: Wed, 15 May 2019 04:01:18 -0400 Subject: junits for AaiController -Added new test for getNodeTemplateInstances method Change-Id: I1214445de2710482964c3e195a91b73bef9ef6da Issue-ID: VID-478 Signed-off-by: Tomasz Gwozdecki --- .../org/onap/vid/controller/AaiControllerTest.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'vid-app-common/src/test') 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 a7676d152..bd6e0f986 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 @@ -32,11 +32,13 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import java.util.Map; +import java.util.UUID; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData; import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataError; import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataOk; @@ -47,6 +49,7 @@ import org.onap.vid.aai.util.AAIRestInterface; import org.onap.vid.roles.RoleProvider; import org.onap.vid.services.AaiService; import org.onap.vid.utils.SystemPropertiesWrapper; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -111,4 +114,27 @@ public class AaiControllerTest { .andExpect(status().isOk()) .andExpect(content().json(new ObjectMapper().writeValueAsString(expectedJson.asMap()))); } + + @Test + public void getNodeTemplateInstances_givenParams_shouldReturnCorrectResponse() throws Exception { + String globalCustomerId = "testCustomerId"; + String serviceType = "testServiceType"; + String modelVersionId = UUID.nameUUIDFromBytes("modelVersionId".getBytes()).toString(); + String modelInvariantId = UUID.nameUUIDFromBytes("modelInvariantId".getBytes()).toString(); + String cloudRegion = "testRegion"; + String urlTemplate = "/aai_get_vnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}"; + String expectedResponseBody = "myResponse"; + AaiResponse aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value()); + given(aaiService + .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion)) + .willReturn(aaiResponse); + + mockMvc + .perform(get(urlTemplate, globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); + } } + -- cgit 1.2.3-korg