summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-03-18 11:26:39 +0200
committerIttay Stern <ittay.stern@att.com>2019-03-18 12:06:33 +0200
commit4fe07922c0c85e9814f444d1aff7fbd4a294db19 (patch)
tree6305e8f01095c2a0ef927a8917be50671a870380 /vid-app-common/src/test/java/org
parent756a9c041981e05a3f5bd740ebc0d3fc22579003 (diff)
Fix getManualTasks double-addition of baseUrl
Inline getManualTasks which was used only once, and adjusted the tests. Issue-ID: VID-403 Change-Id: Icf61586e0047d1d9fd828b8394da10fea8fabea0 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java67
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java4
3 files changed, 48 insertions, 59 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index f58462dd6..12fd4a519 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -20,8 +20,18 @@
*/
package org.onap.vid.mso.rest;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.server.StubServer;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.UUID;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -37,17 +47,6 @@ import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.RestObject;
import org.springframework.test.context.ContextConfiguration;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-import java.util.UUID;
-
-import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
-
@ContextConfiguration(classes = {SystemProperties.class})
public class MsoRestClientNewTest {
@@ -280,16 +279,39 @@ public class MsoRestClientNewTest {
}
@Test
- public void testGetManualTasks() {
+ public void testGetManualTasksByRequestId() {
String p = props.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
String path = p + "/" + UUID.randomUUID();
+ String validResponse = ""
+ + "{ "
+ + " \"taskList\": [ "
+ + " { "
+ + " \"taskId\": \"daf4dd84-b77a-42da-a051-3239b7a9392c\", "
+ + " \"type\": \"fallout\", "
+ + " \"nfRole\": \"vEsmeralda\", "
+ + " \"subscriptionServiceType\": \"Emanuel\", "
+ + " \"originalRequestId\": \"d352c70d-5ef8-4977-9ea8-4c8cbe860422\", "
+ + " \"originalRequestorId\": \"ss835w\", "
+ + " \"errorSource\": \"A&AI\", "
+ + " \"errorCode\": \"404\", "
+ + " \"errorMessage\": \"Failed in A&AI 404\", "
+ + " \"validResponses\": [ "
+ + " \"rollback\", "
+ + " \"abort\", "
+ + " \"skip\", "
+ + " \"resume\", "
+ + " \"retry\" "
+ + " ] "
+ + " } "
+ + " ] "
+ + "}";
try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
server,
path,
HttpStatus.OK_200,
- CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
- closure.executeGet(msoRestClient()::getManualTasks);
+ validResponse,validResponse)) {
+ closure.executeGet(endpoint -> msoRestClient().getManualTasksByRequestId(null, null, endpoint, null));
}
}
@@ -311,23 +333,6 @@ public class MsoRestClientNewTest {
}
@Test
- public void testGetManualTasksByRequestId() throws Exception {
- MsoRestClientNew testSubject;
- String t = "";
- String sourceId = "";
- String endpoint = "";
- RestObject restObject = null;
- MsoResponseWrapper result;
-
- // default test
- try {
- testSubject = createTestSubject();
- result = testSubject.getManualTasksByRequestId(t, sourceId, endpoint, restObject);
- } catch (Exception e) {
- }
- }
-
- @Test
public void testCompleteManualTask() throws Exception {
MsoRestClientNew testSubject;
RequestDetails requestDetails = null;
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 7caafed00..ff71d85fc 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
@@ -20,6 +20,13 @@
*/
package org.onap.vid.mso.rest;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonMapper;
import org.apache.http.ProtocolVersion;
@@ -42,14 +49,6 @@ import org.springframework.test.context.web.WebAppConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.mockito.ArgumentMatchers.any;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-
@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
@WebAppConfiguration
@@ -391,22 +390,6 @@ public class MsoRestClientTest {
}
@Test
- public void shouldProperlyGetManualTasks() {
- // given
- String endpoint = "testEndpoint";
- HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
- MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
-
- when( client.get( eq(baseUrl+endpoint),anyMap(),anyMap(),eq(String.class) ) ).thenReturn(httpResponse);
-
- // when
- MsoResponseWrapper response = restClient.getManualTasks(endpoint);
-
- // then
- assertThat(response).isEqualToComparingFieldByField(expectedResponse);
- }
-
- @Test
public void shouldProperlyGetManualTasksByRequestId() {
// given
RestObject restObject = generateMockMsoRestObject();
@@ -415,8 +398,7 @@ public class MsoRestClientTest {
HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
- /// WUT 'baseUrl+baseUrl+endpoint'
- when( client.get( eq(baseUrl+baseUrl+endpoint),anyMap(),anyMap(),eq(String.class) ) ).thenReturn(httpResponse);
+ when( client.get( eq(baseUrl+endpoint),anyMap(),anyMap(),eq(String.class) ) ).thenReturn(httpResponse);
// when
MsoResponseWrapper response = restClient.getManualTasksByRequestId(null,null,endpoint,restObject);
@@ -428,7 +410,7 @@ public class MsoRestClientTest {
@Test(expectedExceptions = MsoTestException.class)
public void shouldThrowExceptionWhenGetManualTasksByRequestIdGetsWrongParameter() {
// given
- when( client.get( eq(baseUrl+baseUrl),anyMap(),anyMap(),eq(String.class) ) ).thenThrow(new MsoTestException("testsException"));
+ when( client.get( eq(baseUrl),anyMap(),anyMap(),eq(String.class) ) ).thenThrow(new MsoTestException("testsException"));
// when
restClient.getManualTasksByRequestId(null,null,"",null);
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
index 1720e0467..f10a7f14f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
@@ -31,6 +31,7 @@ import static com.xebialabs.restito.semantics.Condition.method;
import static com.xebialabs.restito.semantics.Condition.post;
import static com.xebialabs.restito.semantics.Condition.uri;
import static com.xebialabs.restito.semantics.Condition.withHeader;
+import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.semantics.Action;
@@ -42,7 +43,6 @@ import java.util.function.BiFunction;
import java.util.function.Function;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
-
import org.glassfish.grizzly.http.Method;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.json.JSONObject;
@@ -116,6 +116,7 @@ class MsoRestClientTestUtil implements AutoCloseable {
MsoResponseWrapper response = func.apply(sampleRequestDetails, endpoint);
Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ assertJsonEquals(expectedResponseStr, response.getEntity());
verifyServer(server, endpoint, Method.DELETE);
}
@@ -127,6 +128,7 @@ class MsoRestClientTestUtil implements AutoCloseable {
MsoResponseWrapper response = func.apply(endpoint);
Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ assertJsonEquals(expectedResponseStr, response.getEntity());
verifyServer(server, endpoint, Method.GET);
}