diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-02 14:29:47 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-02 14:29:47 +0300 |
commit | 9f8e3d7ae1bd7c38312e68d8a7f88c6dc86488ab (patch) | |
tree | c173ed2a57271b71e59050e5bd10662923d94e26 /vid-app-common/src/test/java/org/onap | |
parent | a98f4ff3ed19a38ed18e34a5a18e3be2c9e63732 (diff) |
add UT for MsoController.testActivateFabricConfiguration
Issue-ID: VID-378
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: Iddecbfef0378a559a34501e15911b350ec0766a0
Diffstat (limited to 'vid-app-common/src/test/java/org/onap')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java index a2f86f437..a32450510 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java @@ -27,6 +27,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; +import static org.mockito.Mockito.when; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -48,6 +49,7 @@ import org.junit.Test; import org.onap.vid.model.RequestReferencesContainer; import org.onap.vid.mso.MsoBusinessLogic; import org.onap.vid.mso.MsoResponseWrapper; +import org.onap.vid.mso.MsoResponseWrapper2; import org.onap.vid.mso.RestObject; import org.onap.vid.mso.rest.MsoRestClientNew; import org.onap.vid.mso.rest.Request; @@ -447,4 +449,38 @@ public class MsoControllerTest { private <T> T objectEqualTo(T expected) { return argThat(given -> asJson(given).equals(asJson(expected))); } -}
\ No newline at end of file + + @Test + public void testActivateFabricConfiguration() throws Exception { + + String serviceInstanceId = "tempId"; + + //define mock response object + String responseString = "{" + + " \"requestReferences\": {" + + " \"instanceId\": \"tempId\"," + + " \"requestId\": \"dbe54591-c8ed-46d3-abc7-d3a24873dfbd\"" + + " }" + + " }"; + final RestObject<RequestReferencesContainer> restObject = new RestObject<>(); + restObject.set(objectMapper.readValue(responseString, RequestReferencesContainer.class)); + restObject.setStatusCode(200); + + //register mock + String msoPath = "justAFakePath"; + + when(msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId)).thenReturn(msoPath); + when(msoRestClient.PostForObject(new RequestDetails(), msoPath, RequestReferencesContainer.class)).thenReturn(restObject); + + //expected response + MsoResponseWrapper2<RequestReferencesContainer> expectedResponse = new MsoResponseWrapper2<>(restObject); + + //get response from controller + // when & then + mockMvc.perform(post(format("/mso/mso_activate_fabric_configuration/%s", serviceInstanceId)) + .content(asJson(new RequestDetails())) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + } +} |