aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/mso
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-09-01 15:02:06 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-09-01 15:02:06 +0300
commite6c30425575cd76a3955b03ab389150ed74fbb1d (patch)
treee1a668efc3bbd6b5da72ebd8b9825d5e1a96d74c /vid-app-common/src/test/java/org/onap/vid/mso
parent406cc2fe614d089c2f7834f9a22d6dfa47b4fa16 (diff)
handle non OK response from SDC while getting model
Issue-ID: VID-378 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: Idc6e587abb24fbec65ed159db7008e50abee2581
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/mso')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java24
2 files changed, 8 insertions, 24 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index ffabc18a2..c0683425b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -55,7 +55,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.joshworks.restclient.http.HttpResponse;
import java.io.IOException;
import java.net.URL;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -97,6 +96,7 @@ import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.RequestDetailsWrapper;
import org.onap.vid.mso.rest.Task;
+import org.onap.vid.testUtils.TestUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
@@ -1442,11 +1442,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
HttpResponse<String> httpResponse = mockForGetOrchestrationRequest();
when(httpResponse.getStatus()).thenReturn(statusCode);
when(httpResponse.getBody()).thenReturn(body);
- try {
- when(httpResponse.getRawBody()).thenReturn(IOUtils.toInputStream(body, StandardCharsets.UTF_8.name()));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ TestUtils.mockGetRawBodyWithStringBody(httpResponse, body);
return httpResponse;
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java
index 650bda13b..10456bebf 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java
@@ -21,17 +21,13 @@
package org.onap.vid.mso;
-import io.joshworks.restclient.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.message.BasicStatusLine;
-import org.testng.annotations.Test;
-
import static org.apache.http.HttpStatus.SC_OK;
-import static org.apache.http.HttpVersion.HTTP_1_1;
import static org.assertj.core.api.Assertions.assertThat;
+import io.joshworks.restclient.http.HttpResponse;
+import org.onap.vid.testUtils.TestUtils;
+import org.testng.annotations.Test;
+
public class MsoUtilTest {
@Test
@@ -51,7 +47,7 @@ public class MsoUtilTest {
@Test
public void shouldWrapHttpResponse() throws Exception {
// given
- HttpResponse<String> httpResponse = createTestHttpResponse(SC_OK, null);
+ HttpResponse<String> httpResponse = TestUtils.createTestHttpResponse(SC_OK, null);
// when
MsoResponseWrapper result = MsoUtil.wrapResponse(httpResponse);
// then
@@ -63,7 +59,7 @@ public class MsoUtilTest {
public void shouldWrapHttpResponseWithEntity() throws Exception {
// given
String entity = "entity";
- HttpResponse<String> httpResponse = createTestHttpResponse(SC_OK, entity);
+ HttpResponse<String> httpResponse = TestUtils.createTestHttpResponse(SC_OK, entity);
// when
MsoResponseWrapper result = MsoUtil.wrapResponse(httpResponse);
// then
@@ -71,12 +67,4 @@ public class MsoUtilTest {
assertThat(result.getStatus()).isEqualTo(SC_OK);
}
- private HttpResponse<String> createTestHttpResponse(int statusCode, String entity) throws Exception {
- HttpResponseFactory factory = new DefaultHttpResponseFactory();
- org.apache.http.HttpResponse response = factory.newHttpResponse(new BasicStatusLine(HTTP_1_1, statusCode, null), null);
- if (entity != null) {
- response.setEntity(new StringEntity(entity));
- }
- return new HttpResponse<>(response, String.class, null);
- }
}