From 151d768e923994b3e81ade049d21bf65e931faac Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Mon, 5 Aug 2019 23:38:18 +0300 Subject: handle errors in change management and tenant isolation use more tolerance way for parsing responses from MSO so VID can handle error responses with html body Issue-ID: VID-378 Signed-off-by: Eylon Malin Change-Id: I72741ec1bf636a1200e8ecbd684ab1f3b2ab332a Signed-off-by: Ittay Stern Signed-off-by: Eylon Malin --- .../java/org/onap/vid/mso/rest/MsoRestClientTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'vid-app-common/src/test/java/org/onap/vid/mso') diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java index 8ea4836a2..e4e699d55 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java @@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; +import com.fasterxml.jackson.core.JsonProcessingException; import io.joshworks.restclient.http.HttpResponse; import io.joshworks.restclient.http.JsonMapper; import org.apache.http.ProtocolVersion; @@ -60,6 +61,7 @@ import java.util.UUID; import static org.mockito.ArgumentMatchers.refEq; import static org.mockito.hamcrest.MockitoHamcrest.argThat; +import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER; @ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class}) @@ -593,25 +595,23 @@ public class MsoRestClientTest { } @Test - public void shouldProperlyChangeManagementUpdate() { + public void shouldProperlyChangeManagementUpdate() throws JsonProcessingException { // given RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest(); RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails); String endpoint = "testEndpoint"; - HttpResponse httpResponse = HttpResponse.fallback( - new RequestReferencesContainer( - new RequestReferences())); + RequestReferencesContainer entity = new RequestReferencesContainer(new RequestReferences()); + HttpResponse httpResponse = HttpResponse.fallback(JACKSON_OBJECT_MAPPER.writeValueAsString(entity)); - MsoResponseWrapperInterface expectedResponse = MsoUtil.wrapResponse(httpResponse); - - when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetailsWrapper), eq(RequestReferencesContainer.class))).thenReturn(httpResponse); + when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetailsWrapper), eq(String.class))).thenReturn(httpResponse); // when MsoResponseWrapperInterface response = restClient.changeManagementUpdate(requestDetailsWrapper, endpoint); // then - assertThat(expectedResponse).isEqualToComparingFieldByField(response); + assertThat(response.getEntity()).isEqualToComparingFieldByField(entity); + assertThat(response.getStatus()).isEqualTo(0); } @Test -- cgit 1.2.3-korg