summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@intl.att.com>2018-10-18 08:15:24 +0000
committerGerrit Code Review <gerrit@onap.org>2018-10-18 08:15:24 +0000
commitbd1e5afc394d1cfd1adaf4a38d52eb93c46e1ae0 (patch)
tree781cdcc299601de7f27ee1ca1d24e7e32434072d /vid-app-common/src/test
parent73fb3a115e5eaa4b2c9c0de10b70af98ef493e01 (diff)
parent281ed983c5deb49d085ad1417fa417aed0fe42fa (diff)
Merge "Added scaleOut to dashboard orchestrationRequests"
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java47
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json174
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json108
3 files changed, 321 insertions, 8 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 e0e3c363..54e924d9 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
@@ -2,14 +2,11 @@ package org.onap.vid.mso;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.*;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.controllers.MsoController;
+import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.properties.Features;
import org.springframework.test.context.ContextConfiguration;
@@ -22,13 +19,15 @@ import org.testng.annotations.Test;
import org.togglz.core.manager.FeatureManager;
import java.io.IOException;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.List;
+import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import static org.onap.vid.controllers.MsoController.SVC_INSTANCE_ID;
import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath;
@@ -41,7 +40,9 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
private static final String EXPECTED_SCALE_OUT_PATH = "/serviceInstantiation/v7/serviceInstances/1/vnfs/1/vfModules/scaleOut";
private static final Path PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayload.json");
private static final Path PATH_TO_FINAL_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayloadToMso.json");
- private static final ObjectMapper OBJECT_MAPPER=new ObjectMapper();
+ private static final Path PATH_TO_EXPECTED_MSO_MODEL_TYPE_REQ = Paths.get("src", "test", "resources", "payload_jsons", "mso_model_info_sample_response.json");
+ private static final Path PATH_TO_EXPECTED_MSO_SCALEOUT_REQ = Paths.get("src", "test", "resources", "payload_jsons", "mso_action_scaleout_sample_response.json");
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@InjectMocks
private MsoBusinessLogicImpl msoBusinessLogic;
@@ -161,6 +162,36 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
assertThat(expectedRequestWrapper.requestDetails).isEqualTo(actual.requestDetails);
}
+ @Test
+ public void shouldFilterOutOrchestrationRequestsNotAllowedInDashboard() throws IOException {
+ String vnfModelTypeOrchestrationRequests = getFileContentAsString(PATH_TO_EXPECTED_MSO_MODEL_TYPE_REQ);
+ String scaleOutActionOrchestrationRequests = getFileContentAsString(PATH_TO_EXPECTED_MSO_SCALEOUT_REQ);
+
+ MsoResponseWrapper msoResponseWrapperMock = mock(MsoResponseWrapper.class);
+ when(msoInterfaceMock.getOrchestrationRequestsForDashboard(any(String.class), any(String.class), any(String.class), any(RestObject.class)))
+ .thenReturn(msoResponseWrapperMock);
+ when(msoResponseWrapperMock.getEntity()).thenReturn(vnfModelTypeOrchestrationRequests, scaleOutActionOrchestrationRequests);
+
+ List<Request> filteredOrchestrationReqs = msoBusinessLogic.getOrchestrationRequestsForDashboard();
+
+ assertThat(filteredOrchestrationReqs).hasSize(3);
+ assertThat(MsoBusinessLogicImpl.DASHBOARD_ALLOWED_TYPES)
+ .containsAll(filteredOrchestrationReqs
+ .stream()
+ .map(el -> el.getRequestType().toUpperCase())
+ .collect(Collectors.toList()));
+ assertThat(filteredOrchestrationReqs
+ .stream()
+ .map(org.onap.vid.domain.mso.Request::getRequestScope)
+ .collect(Collectors.toList()))
+ .containsOnly("vnf", "vfModule");
+ }
+
+
+ private String getFileContentAsString(Path pathToFile) throws IOException {
+ return new String(Files.readAllBytes(pathToFile));
+ }
+
private org.onap.vid.changeManagement.RequestDetails getScaleOutRequest() throws IOException {
return OBJECT_MAPPER.readValue(PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST.toFile(), org.onap.vid.changeManagement.RequestDetails.class);
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json b/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json
new file mode 100644
index 00000000..d37f6af1
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json
@@ -0,0 +1,174 @@
+{
+ "requestList": [
+ {
+ "request": {
+ "requestId": "799d7380-60fe-4b64-9d99-82f6ab09163b",
+ "startTime": "Fri, 12 Oct 2018 08:53:07 GMT",
+ "requestScope": "vfModule",
+ "requestType": "scaleOut",
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "WsSp..base_ws..module-0",
+ "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+ "modelType": "vfModule",
+ "modelName": "WsSp..base_ws..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+ "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+ "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+ "modelUuid": "53f52586-236b-4d52-a94c-990883e054f0",
+ "modelInvariantUuid": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+ "modelInstanceName": "WsSp..base_ws..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "ws-test-0310-8_NaN",
+ "suppressRollback": false,
+ "requestorId": "demo"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "modelInfo": {
+ "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+ "modelType": "service",
+ "modelName": "ws-service",
+ "modelVersion": "1.0",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "modelInfo": {
+ "modelCustomizationName": "ws-sp 0",
+ "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelType": "vnf",
+ "modelName": "ws-sp",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelInstanceName": "ws-sp 0"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+ "lcpCloudRegionId": "RegionOne"
+ },
+ "requestParameters": {},
+ "configurationParameters": [
+ {
+ "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "vfModuleInstanceName": "ws-test-0310-8_NaN",
+ "requestorId": "demo"
+ },
+ "requestStatus": {
+ "requestState": "FAILED",
+ "statusMessage": "No valid vfModuleCustomization is specified",
+ "percentProgress": 100,
+ "finishTime": "Fri, 12 Oct 2018 08:53:07 GMT"
+ }
+ }
+ },
+ {
+ "request": {
+ "requestId": "44b534c7-57b5-42ec-85bb-219167021b34",
+ "startTime": "Fri, 12 Oct 2018 09:08:01 GMT",
+ "requestScope": "vfModule",
+ "requestType": "scaleOut",
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "WsSp..base_ws..module-0",
+ "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+ "modelType": "vfModule",
+ "modelName": "WsSp..base_ws..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+ "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+ "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+ "modelUuid": "53f52586-236b-4d52-a94c-990883e054f0",
+ "modelInvariantUuid": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+ "modelInstanceName": "WsSp..base_ws..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "ws-test-0310-8_NaN",
+ "suppressRollback": false,
+ "requestorId": "demo"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "modelInfo": {
+ "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+ "modelType": "service",
+ "modelName": "ws-service",
+ "modelVersion": "1.0",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "modelInfo": {
+ "modelCustomizationName": "ws-sp 0",
+ "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelType": "vnf",
+ "modelName": "ws-sp",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelInstanceName": "ws-sp 0"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+ "lcpCloudRegionId": "RegionOne"
+ },
+ "requestParameters": {},
+ "configurationParameters": [
+ {
+ "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "vfModuleInstanceId": "scaleOut",
+ "vfModuleInstanceName": "ws-test-0310-8_NaN",
+ "requestorId": "demo"
+ },
+ "requestStatus": {
+ "requestState": "FAILED"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json b/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json
new file mode 100644
index 00000000..9dbdfb04
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json
@@ -0,0 +1,108 @@
+{
+ "requestList": [
+ {
+ "request": {
+ "requestId": "f8c813a2-b22b-4e3d-9be0-8e2d16b1add3",
+ "startTime": "Wed, 03 Oct 2018 13:13:04 GMT",
+ "requestScope": "vnf",
+ "requestType": "createInstance",
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "ws-sp 0",
+ "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelType": "vnf",
+ "modelName": "ws-sp",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelInstanceName": "ws-sp 0"
+ },
+ "requestInfo": {
+ "productFamilyId": "61cc3239-5c2e-4762-a281-7422a2e54d5a",
+ "source": "VID",
+ "instanceName": "ws-test-0310-8",
+ "suppressRollback": false,
+ "requestorId": "demo"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "modelInfo": {
+ "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+ "modelType": "service",
+ "modelName": "ws-service",
+ "modelVersion": "1.0",
+ "modelVersionId": "cd3fbd06-6bc8-43a4-b803-933fc2e3cdf7",
+ "modelUuid": "cd3fbd06-6bc8-43a4-b803-933fc2e3cdf7",
+ "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+ "lcpCloudRegionId": "RegionOne"
+ },
+ "requestParameters": {
+ "testApi": "VNF_API"
+ },
+ "platform": {
+ "platformName": "Demo"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "Demo"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "vnfInstanceName": "ws-test-0310-8",
+ "requestorId": "demo"
+ },
+ "requestStatus": {
+ "requestState": "COMPLETE",
+ "statusMessage": "Vnf has been created successfully.",
+ "percentProgress": 100,
+ "finishTime": "Wed, 03 Oct 2018 13:13:09 GMT"
+ }
+ }
+ },
+ {
+ "request": {
+ "requestId": "3447ba35-015d-4d72-9345-d89b1e35b2d6",
+ "startTime": "Thu, 04 Oct 2018 10:35:17 GMT",
+ "requestScope": "vnf",
+ "requestType": "inPlaceSoftwareUpdate",
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "demo"
+ },
+ "cloudConfiguration": {
+ "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+ "lcpCloudRegionId": "RegionOne"
+ },
+ "requestParameters": {
+ "payload": "{\"existing_software_version\":\"0.7\",\"new_software_version\":\"1.0\",\"operations_timeout\":\"10\"}"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "requestorId": "demo"
+ },
+ "requestStatus": {
+ "requestState": "FAILED",
+ "statusMessage": "Cloud Region with cloudRegionId RegionOne does not exist in A&AI",
+ "percentProgress": 100,
+ "finishTime": "Thu, 04 Oct 2018 10:35:21 GMT"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file