aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java41
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json39
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json6
10 files changed, 108 insertions, 27 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
index 5da16f4326..0ca98883c9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
@@ -70,6 +70,10 @@ public abstract class BaseTest {
return "http://localhost:" + port + uri;
}
+ protected String createURLWithPort(String uri, String orchestrationPath) {
+ return "http://localhost:" + port + orchestrationPath + uri;
+ }
+
protected String createURLWithPort(String uri, int iPort) {
return "http://localhost:" + iPort + uri;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
index 081f235db1..7b2e502892 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
@@ -29,10 +29,12 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
-import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_PARTNER_NAME;
+import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID;
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -46,7 +48,6 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.springframework.beans.factory.annotation.Autowired;
@@ -57,8 +58,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.util.UriComponentsBuilder;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
public class InstanceManagementTest extends BaseTest {
@@ -72,6 +71,7 @@ public class InstanceManagementTest extends BaseTest {
private String wiremockPort;
private final String instanceManagementUri = "/onap/so/infra/instanceManagement/";
+ private final String orchestration_path = "/onap/so/infra";
private String uri;
private URL selfLink;
@@ -93,7 +93,7 @@ public class InstanceManagementTest extends BaseTest {
headers.set(ONAP_PARTNER_NAME, "VID");
headers.set(REQUESTOR_ID, "xxxxxx");
try { // generate one-time port number to avoid RANDOM port number later.
- initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
+ initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH, orchestration_path));
initialPort = initialUrl.getPort();
} catch (MalformedURLException e) {
e.printStackTrace();
@@ -208,6 +208,35 @@ public class InstanceManagementTest extends BaseTest {
}
@Test
+ public void executeServiceLevelCustomWorkflow() throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/testingServiceLevelWorkflow"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(get(urlMatching(
+ ".*/workflow/search/findByArtifactUUID[?]artifactUUID=81526781-e55c-4cb7-adb3-97e09d9c76bf"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("workflow_ServiceLevel_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ // expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ requestReferences.setRequestSelfLink(createExpectedSelfLink("v1", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = instanceManagementUri + "v1"
+ + "/serviceInstances/5df8b6de-2083-11e7-93ae-92361f002676/workflows/81526781-e55c-4cb7-adb3-97e09d9c76bf";
+ ResponseEntity<String> response =
+ sendRequest(inputStream("/ExecuteServiceLevelCustomWorkflow.json"), uri, HttpMethod.POST, headers);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
public void workflowAndOperationNameTest() {
wireMockServer.stubFor(get(urlMatching(
".*/workflow/search/findByArtifactUUID[?]artifactUUID=71526781-e55c-4cb7-adb3-97e09d9c76be"))
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 9b892af869..7711608288 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -133,7 +133,6 @@ public class OrchestrationRequestsTest extends BaseTest {
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
- e.setTag("pincFabricConfigRequest");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
@@ -210,7 +209,6 @@ public class OrchestrationRequestsTest extends BaseTest {
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
- e.setTag("pincFabricConfigRequest");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
@@ -256,7 +254,6 @@ public class OrchestrationRequestsTest extends BaseTest {
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
- e.setTag("pincFabricConfigRequest");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
@@ -463,13 +460,11 @@ public class OrchestrationRequestsTest extends BaseTest {
HashMap<String, String> secondExpectedMap = new HashMap<>();
List<RequestProcessingData> expectedDataList = new ArrayList<>();
entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
- entry.setTag("pincFabricConfigRequest");
expectedMap.put("requestAction", "assign");
- expectedMap.put("pincFabricId", "testId");
+ expectedMap.put("fabricId", "testId");
expectedList.add(expectedMap);
entry.setDataPairs(expectedList);
secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
- secondEntry.setTag("pincFabricConfig");
secondExpectedMap.put("requestAction", "unassign");
secondExpectedList.add(secondExpectedMap);
secondEntry.setDataPairs(secondExpectedList);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index ef90b22b01..33d86a2cc6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -1,8 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +13,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -97,6 +97,8 @@ public class ServiceInstancesTest extends BaseTest {
private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
+ private final String orchestration_path = "/onap/so/infra";
+
private String uri;
private URL selfLink;
private URL initialUrl;
@@ -115,7 +117,7 @@ public class ServiceInstancesTest extends BaseTest {
headers.set(ONAP_PARTNER_NAME, "VID");
headers.set(REQUESTOR_ID, "xxxxxx");
try { // generate one-time port number to avoid RANDOM port number later.
- initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
+ initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH, orchestration_path));
initialPort = initialUrl.getPort();
} catch (MalformedURLException e) {
e.printStackTrace();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
index d39192cdf0..6c643c77d7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
@@ -61,4 +61,15 @@ public class AbstractRestHandlerTest {
restHandler.createResponse("instanceId", "requestId", mockRequestContext);
assertThat(actualResponse, sameBeanAs(expectedResponse));
}
+
+ @Test
+ public void test_buildSelfLinkUrl() throws MalformedURLException {
+ String initialLink = "http://some.domain.com:30277/onap/so/infra/serviceInstantiation/v7/serviceInstances";
+ String requestId = "4d0437c3-ee48-4361-a4f7-e1613c82493a";
+ Optional<URL> expectedLink = Optional.of(new URL(
+ "http://some.domain.com:30277/onap/so/infra/orchestrationRequests/v7/4d0437c3-ee48-4361-a4f7-e1613c82493a"));
+ Optional<URL> resultURL = restHandler.buildSelfLinkUrl(initialLink, requestId);
+
+ assertThat(resultURL, sameBeanAs(expectedLink));
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json
index 79caa33419..a84b2dbe11 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json
@@ -4,21 +4,18 @@
"soRequestId": "00032ab7-na18-42e5-965d-8ea592502018",
"groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714",
"name": "requestAction",
- "value": "assign",
- "tag": "pincFabricConfigRequest"
+ "value": "assign"
},{
"id": 2,
"soRequestId": "00032ab7-na18-42e5-965d-8ea592502018",
"groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714",
- "name": "pincFabricId",
- "value": "testId",
- "tag": "pincFabricConfigRequest"
+ "name": "fabricId",
+ "value": "testId"
},{
"id": 3,
"soRequestId": "00032ab7-na18-42e5-965d-8ea592502018",
"groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca715",
"name": "requestAction",
- "value": "unassign",
- "tag": "pincFabricConfig"
+ "value": "unassign"
}
] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json
index af28007900..6ebe55201a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json
@@ -3,6 +3,5 @@
"soRequestId": "00032ab7-na18-42e5-965d-8ea592502018",
"groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714",
"name": "requestAction",
- "value": "assign",
- "tag": "pincFabricConfigRequest"
+ "value": "assign"
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json
index c746020e7f..c3554c86a5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingDataArray.json
@@ -3,6 +3,5 @@
"soRequestId": "00032ab7-na18-42e5-965d-8ea592502018",
"groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714",
"name": "requestAction",
- "value": "assign",
- "tag": "pincFabricConfigRequest"
+ "value": "assign"
}]
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json
new file mode 100644
index 0000000000..e466ac08a3
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteServiceLevelCustomWorkflow.json
@@ -0,0 +1,39 @@
+{
+ "requestDetails":{
+ "subscriberInfo":{
+ "globalSubscriberId":"Test"
+ },
+ "requestInfo":{
+ "suppressRollback": false,
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "demo",
+ "instanceName":"testInstanceName",
+ "source":"VID"
+ },
+ "cloudConfiguration":{
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f",
+ "cloudOwner": "CloudOwner"
+ },
+ "requestParameters":{
+ "subscriptionServiceType": "test",
+ "userParams":[],
+ "aLaCarte": false,
+ "payload": "{\"k1\": \"v1\"}"
+ },
+ "project":{
+ "projectName": "PNFSWUProject"
+ },
+ "owningEntity":{
+ "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "owningEntityName":"OE-Test"
+ },
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json
new file mode 100644
index 0000000000..133c724b43
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_ServiceLevel_Response.json
@@ -0,0 +1,6 @@
+{
+ "artifactUUID": "81526781-e55c-4cb7-adb3-97e09d9c76bf",
+ "artifactName": "testingServiceLevelWorkflow.bpmn",
+ "name": "testingServiceLevelWorkflow",
+ "operationName": "testServiceLevelOperation"
+}