aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asdc-controller/src/main/resources/resource-examples/resource_Extvl.csarbin2638 -> 3328 bytes
-rw-r--r--asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csarbin42061 -> 44650 bytes
-rw-r--r--asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csarbin97110 -> 109898 bytes
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java68
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java78
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java93
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java139
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java (renamed from bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java)17
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java92
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java)43
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java143
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java118
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java108
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfWorkflows_Response.json41
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java12
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java6
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java16
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java10
-rw-r--r--version.properties4
24 files changed, 976 insertions, 181 deletions
diff --git a/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar b/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar
index bd35b0ab60..20ce62b8de 100644
--- a/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar
+++ b/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar
Binary files differ
diff --git a/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar b/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar
index 29d30f8023..dd0115b716 100644
--- a/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar
+++ b/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar
Binary files differ
diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar
index 4c906aba38..817b83135d 100644
--- a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar
+++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/service-VfZrdm5bpxmc02092017Service-csar.csar
Binary files differ
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java
index 0766dae8e1..fb79880572 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2019 Bell Canada
* ================================================================================
+ * Modifications Copyright (c) 2020 Nordix
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -20,6 +22,7 @@
package org.onap.so.client.cds;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
@@ -34,8 +37,9 @@ import java.util.UUID;
public class GeneratePayloadForCds {
private static final String ORIGINATOR_ID = "SO";
- private static final String MODE = "sync";
private static final String BUILDING_BLOCK = "buildingBlock";
+ private static final String DEFAULT_SYNC_MODE = "sync";
+ private static final String MSO_REQUEST_ID = "msoRequestId";
@Autowired
private VnfCDSRequestProvider vnfCDSRequestProvider;
@@ -49,8 +53,12 @@ public class GeneratePayloadForCds {
@Autowired
private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private PnfCDSRequestProvider pnfCDSRequestProvider;
+
/**
- * Build properties like (blueprint name, version, action etc..) along with the request payload.
+ * Build properties like (blueprint name, version, action etc..) along with the request payload for vnf, vf-module
+ * and service.
*
* @param execution - A building block execution object.
* @return AbstractCDSPropertiesBean - A POJO which contains CDS related information.
@@ -61,8 +69,9 @@ public class GeneratePayloadForCds {
ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
- String scope = buildingBlock.getBpmnScope();
- String action = buildingBlock.getBpmnAction();
+ final String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
+ final String scope = buildingBlock.getBpmnScope();
+ final String action = buildingBlock.getBpmnAction();
CDSRequestProvider requestProvider = getRequestProviderByScope(scope);
@@ -71,7 +80,35 @@ public class GeneratePayloadForCds {
final String requestPayload = requestProvider.buildRequestPayload(action)
.orElseThrow(() -> new PayloadGenerationException("Failed to build payload for CDS"));
- final String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
+ return prepareAndSetCdsPropertyBean(requestProvider, requestPayload, requestId, action, DEFAULT_SYNC_MODE);
+ }
+
+ /**
+ * Build properties like (blueprint name, version, action etc..) along with the request payload for pnf.
+ *
+ * @param execution - A building block execution object.
+ * @return AbstractCDSPropertiesBean - A POJO which contains CDS related information.
+ * @throws PayloadGenerationException - Throw an exception if it fails to build payload for CDS.
+ */
+ public AbstractCDSPropertiesBean buildCdsPropertiesBean(DelegateExecution execution)
+ throws PayloadGenerationException {
+
+ final String scope = String.valueOf(execution.getVariable(PayloadConstants.SCOPE));
+ final String action = String.valueOf(execution.getVariable(PayloadConstants.ACTION));
+ final String requestId = String.valueOf(execution.getVariable(MSO_REQUEST_ID));
+ final String mode = extractAndSetMode(execution);
+
+ CDSRequestProvider requestProvider = getRequestProviderByScope(scope);
+ requestProvider.setExecutionObject(execution);
+
+ final String requestPayload = requestProvider.buildRequestPayload(action)
+ .orElseThrow(() -> new PayloadGenerationException("Failed to build payload for CDS"));
+
+ return prepareAndSetCdsPropertyBean(requestProvider, requestPayload, requestId, action, mode);
+ }
+
+ private AbstractCDSPropertiesBean prepareAndSetCdsPropertyBean(CDSRequestProvider requestProvider,
+ String requestPayload, String requestId, String action, String mode) {
final AbstractCDSPropertiesBean cdsPropertiesBean = new AbstractCDSPropertiesBean();
cdsPropertiesBean.setRequestObject(requestPayload);
cdsPropertiesBean.setBlueprintName(requestProvider.getBlueprintName());
@@ -80,23 +117,34 @@ public class GeneratePayloadForCds {
cdsPropertiesBean.setOriginatorId(ORIGINATOR_ID);
cdsPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
cdsPropertiesBean.setActionName(action);
- cdsPropertiesBean.setMode(MODE);
-
+ cdsPropertiesBean.setMode(mode);
return cdsPropertiesBean;
}
+ private String extractAndSetMode(DelegateExecution execution) {
+ String mode = DEFAULT_SYNC_MODE;
+ Object obj = execution.getVariable(PayloadConstants.MODE);
+ if (obj != null && !String.valueOf(obj).isEmpty()) {
+ mode = String.valueOf(obj);
+ }
+ return mode;
+ }
+
private CDSRequestProvider getRequestProviderByScope(String scope) throws PayloadGenerationException {
CDSRequestProvider requestProvider;
switch (scope) {
- case "vnf":
+ case PayloadConstants.VNF_SCOPE:
requestProvider = vnfCDSRequestProvider;
break;
- case "vfModule":
+ case PayloadConstants.VF_MODULE_SCOPE:
requestProvider = vfModuleCDSRequestProvider;
break;
- case "service":
+ case PayloadConstants.SERVICE_SCOPE:
requestProvider = serviceCDSRequestProvider;
break;
+ case PayloadConstants.PNF_SCOPE:
+ requestProvider = pnfCDSRequestProvider;
+ break;
default:
throw new PayloadGenerationException("No scope defined with " + scope);
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java
index e758f548f7..808d427d65 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2019 Bell Canada
* ================================================================================
+ * Modifications Copyright (C) 2020 Nordix
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -30,5 +32,22 @@ public final class PayloadConstants {
public static final String PROPERTIES = "properties";
public static final String SCOPE = "scope";
public static final String ACTION = "action";
+ public static final String MODE = "mode";
public static final String SEPARATOR = "-";
+ public static final String PNF_SCOPE = "pnf";
+ public static final String VNF_SCOPE = "vnf";
+ public static final String VF_MODULE_SCOPE = "vfModule";
+ public static final String SERVICE_SCOPE = "service";
+ public static final String RESOLUTION_KEY = "resolution-key";
+ public static final String CDS_ACTOR = "cds";
+
+ public static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName";
+ public static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
+ public static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
+ public static final String PRC_TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+
+ public final static String PNF_CORRELATION_ID = "pnfCorrelationId";
+ public final static String PNF_UUID = "pnfUuid";
+ public final static String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ public final static String MODEL_UUID = "modelUuid";
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java
new file mode 100644
index 0000000000..86bca755ed
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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=========================================================
+ */
+package org.onap.so.client.cds;
+
+import com.google.gson.JsonObject;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import java.util.Optional;
+import static org.onap.so.client.cds.PayloadConstants.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PnfCDSRequestProvider implements CDSRequestProvider {
+ private String blueprintName;
+ private String blueprintVersion;
+ private DelegateExecution execution;
+
+ @Override
+ public String getBlueprintName() {
+ return blueprintName;
+ }
+
+ @Override
+ public String getBlueprintVersion() {
+ return blueprintVersion;
+ }
+
+ @Override
+ public <T> void setExecutionObject(T executionObject) {
+ execution = (DelegateExecution) executionObject;
+ }
+
+ @Override
+ public Optional<String> buildRequestPayload(String action) {
+
+ final JsonObject pnfObject = new JsonObject();
+ final String resolutionKey = String.valueOf(execution.getVariable(PNF_CORRELATION_ID));
+ blueprintName = String.valueOf(execution.getVariable(PRC_BLUEPRINT_NAME));
+ blueprintVersion = String.valueOf(execution.getVariable(PRC_BLUEPRINT_VERSION));
+
+ extractAndSetExecutionVariable("service-instance-id", SERVICE_INSTANCE_ID, pnfObject);
+ extractAndSetExecutionVariable("service-model-uuid", MODEL_UUID, pnfObject);
+ extractAndSetExecutionVariable("pnf-id", PNF_UUID, pnfObject);
+ extractAndSetExecutionVariable("pnf-name", PNF_CORRELATION_ID, pnfObject);
+ extractAndSetExecutionVariable("pnf-customization-uuid", PRC_CUSTOMIZATION_UUID, pnfObject);
+ extractAndSetExecutionVariable("target-software-version", PRC_TARGET_SOFTWARE_VERSION, pnfObject);
+
+ final JsonObject cdsPropertyObject = new JsonObject();
+ cdsPropertyObject.addProperty(RESOLUTION_KEY, resolutionKey);
+ cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, pnfObject);
+
+ return Optional.of(buildRequestJsonObject(cdsPropertyObject, action));
+ }
+
+ private void extractAndSetExecutionVariable(String jsonProperty, String executionProperty, JsonObject pnfObject) {
+ if (execution.getVariable(executionProperty) != null) {
+ pnfObject.addProperty(jsonProperty, String.valueOf(execution.getVariable(executionProperty)));
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java
index 471bdb74fc..24962a0c14 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java
@@ -19,9 +19,6 @@
*/
package org.onap.so.client.cds;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonParser;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -30,7 +27,6 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.omg.Messaging.SYNC_WITH_TRANSPORT;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
@@ -38,28 +34,19 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
-import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
-import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.PayloadGenerationException;
import org.onap.so.serviceinstancebeans.*;
import java.util.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.ThrowableAssert.catchThrowable;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
@RunWith(MockitoJUnitRunner.Silent.class)
public class GeneratePayloadForCdsTest {
- private static final String GENERIC_VNF_ID = "vnfId_configVnfTest1";
- private static final String VF_MODULE_ID = "vf-module-id-1";
- private static final String VF_MODULE_NAME = "vf-module-name-1";
private static final String VF_MODULE_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce1";
- private static final String GENERIC_VNF_NAME = "vnf-name-1";
- private static final String SERVICE_INSTANCE_ID = "serviceInst_configTest";
- private static final String SERVICE_MODEL_UUID = "b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4";
- private static final String SERVICE_INSTANCE_NAME = "test-service-instance";
private static final String VNF_MODEL_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4";
private static final String GENERAL_BLOCK_EXECUTION_MAP_KEY = "gBBInput";
private static final String VNF_SCOPE = "vnf";
@@ -68,10 +55,34 @@ public class GeneratePayloadForCdsTest {
private static final String VF_SCOPE = "vfModule";
private static final String ASSIGN_ACTION = "configAssign";
private static final String DEPLOY_ACTION = "configDeploy";
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
private static final String MSO_REQUEST_ID = "1234";
private static final String BUILDING_BLOCK = "buildingBlock";
private static final String PUBLIC_NET_ID = "public-net-id";
private static final String CLOUD_REGION = "acl-cloud-region";
+ private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static final String TEST_PROCESS_KEY = "processKey1";
+ private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static final String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static final String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static final String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static final String TEST_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+ private static final String PNF_CORRELATION_ID = "pnfCorrelationId";
+ private static final String PNF_UUID = "pnfUuid";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ private static final String MODEL_UUID = "modelUuid";
+ private static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
+ private static final String PRC_INSTANCE_NAME = "PRC_instanceName";
+ private static final String PRC_TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+ private static final String SCOPE = "scope";
+ private static final String ACTION = "action";
+ private static final String PROCESS_KEY = "testProcessKey";
+ private static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName";
+ private static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
private BuildingBlockExecution buildingBlockExecution;
private ExecuteBuildingBlock executeBuildingBlock;
@@ -88,6 +99,9 @@ public class GeneratePayloadForCdsTest {
@Mock
private ServiceCDSRequestProvider serviceCDSRequestProvider;
+ @Mock
+ private PnfCDSRequestProvider pnfCDSRequestProvider;
+
@Before
public void setup() {
@@ -100,9 +114,7 @@ public class GeneratePayloadForCdsTest {
// given
final String assignPayload =
"{\"configAssign-request\":{\"resolution-key\":\"vnf-name-1\",\"configAssign-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\",\"vnf-id\":\"vnfId_configVnfTest1\",\"vnf-name\":\"vnf-name-1\",\"vnf-customization-uuid\":\"23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4\",\"acl-cloud-region\":\"acl-cloud-region\",\"public_net_id\":\"public-net-id\"}}}";
-
setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
-
doReturn(Optional.of(assignPayload)).when(vnfCDSRequestProvider).buildRequestPayload(ASSIGN_ACTION);
// when
@@ -125,7 +137,6 @@ public class GeneratePayloadForCdsTest {
final String deployPayload =
"{\"configDeploy-request\":{\"resolution-key\":\"vnf-name-1\",\"configDeploy-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\",\"vnf-id\":\"vnfId_configVnfTest1\",\"vnf-name\":\"vnf-name-1\",\"vnf-customization-uuid\":\"23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4\",\"acl-cloud-region\":\"acl-cloud-region\",\"public_net_id\":\"public-net-id\"}}}";
setScopeAndAction(VNF_SCOPE, DEPLOY_ACTION);
-
doReturn(Optional.of(deployPayload)).when(vnfCDSRequestProvider).buildRequestPayload(DEPLOY_ACTION);
// when
@@ -188,10 +199,35 @@ public class GeneratePayloadForCdsTest {
}
@Test
+ public void testBuildCdsPropertiesBeanDownloadPnf() throws Exception {
+ // given
+ final String downloadPayload =
+ "{\"downloadNeSw-request\":{\"resolution-key\":\"PNFDemo\",\"downloadNeSw-properties\":{\"service-instance-id\":\"test_service_id\",\"service-model-uuid\":\"6bc0b04d-1873-4721-b53d-6615225b2a28\",\"pnf-id\":\"5df8b6de-2083-11e7-93ae-92361f002671\",\"pnf-name\":\"PNFDemo\",\"pnf-customization-uuid\":\"9acb3a83-8a52-412c-9a45-901764938144\",\"target-software-version\":\"demo-sw-ver2.0.0\"}}}";
+ DelegateExecution execution = prepareDelegateExecutionObj(PayloadConstants.PNF_SCOPE, DOWNLOAD_ACTION);
+ doReturn(Optional.of(downloadPayload)).when(pnfCDSRequestProvider).buildRequestPayload(DOWNLOAD_ACTION);
+ doReturn(TEST_PNF_RESOURCE_BLUEPRINT_NAME).when(pnfCDSRequestProvider).getBlueprintName();
+ doReturn(TEST_PNF_RESOURCE_BLUEPRINT_VERSION).when(pnfCDSRequestProvider).getBlueprintVersion();
+
+ // when
+ AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(execution);
+
+ // verify
+ assertNotNull(propertyBean);
+ String payload = propertyBean.getRequestObject();
+ assertThat(downloadPayload.equals(payload));
+ assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
+ assertThat(propertyBean.getOriginatorId().equals("SO"));
+ assertNotNull(propertyBean.getSubRequestId());
+ assertThat(propertyBean.getActionName().equals(DOWNLOAD_ACTION));
+ assertThat(propertyBean.getMode().equalsIgnoreCase("async"));
+ assertThat(propertyBean.getBlueprintName().equalsIgnoreCase(TEST_PNF_RESOURCE_BLUEPRINT_NAME));
+ assertThat(propertyBean.getBlueprintVersion().equalsIgnoreCase(TEST_PNF_RESOURCE_BLUEPRINT_VERSION));
+ }
+
+ @Test
public void testFailureWhenServiceInstanceIsNotPresent() throws Exception {
// given
setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
-
doThrow(PayloadGenerationException.class).when(serviceCDSRequestProvider).buildRequestPayload(ASSIGN_ACTION);
// when
@@ -284,4 +320,23 @@ public class GeneratePayloadForCdsTest {
executeBuildingBlock.setBuildingBlock(buildingBlock);
buildingBlockExecution.setVariable(BUILDING_BLOCK, executeBuildingBlock);
}
+
+ private DelegateExecution prepareDelegateExecutionObj(String scope, String action) {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_TARGET_SOFTWARE_VERSION, TEST_SOFTWARE_VERSION);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ execution.setVariable(SCOPE, scope);
+ execution.setVariable(ACTION, action);
+ execution.setVariable("mode", "async");
+ return execution;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java
new file mode 100644
index 0000000000..e5cbc9a369
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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=========================================================
+ */
+
+package org.onap.so.client.cds;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.JsonParser;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.junit.MockitoJUnitRunner;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class PnfCDSRequestProviderTest {
+
+ @InjectMocks
+ private PnfCDSRequestProvider pnfCDSRequestProvider;
+
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String ACTIVATE_ACTION = "activateNeSw";
+ private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static final String TEST_PROCESS_KEY = "processKey1";
+ private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static final String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static final String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static final String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static final String TEST_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+ private static final String PNF_CORRELATION_ID = "pnfCorrelationId";
+ private static final String PNF_UUID = "pnfUuid";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ private static final String MSO_REQUEST_ID = "msoRequestId";
+ private static final String MODEL_UUID = "modelUuid";
+ private static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
+ private static final String PRC_INSTANCE_NAME = "PRC_instanceName";
+ private static final String PRC_TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+ private static final String SCOPE = "scope";
+ private static final String ACTION = "action";
+ private static final String PROCESS_KEY = "testProcessKey";
+ private static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName";
+ private static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+
+ @Test
+ public void testBuildRequestPayloadDownloadActionPnf() {
+ try {
+ runTest(DOWNLOAD_ACTION);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testBuildRequestPayloadActivateActionPnf() {
+ try {
+ runTest(ACTIVATE_ACTION);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ private void runTest(String action) throws Exception {
+ // given
+ DelegateExecution execution = prepareDelegateExecutionObj(PayloadConstants.PNF_SCOPE, action);
+
+ // when
+ pnfCDSRequestProvider.setExecutionObject(execution);
+ String payload = pnfCDSRequestProvider.buildRequestPayload(action).get();
+ System.out.println(payload);
+
+ // verify
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode payloadJson = mapper.readTree(payload);
+ JsonNode requestNode = payloadJson.findValue(action + "-request");
+ JsonNode propertiesNode = payloadJson.findValue(action + "-properties");
+
+ assertNotNull(payload);
+ assertTrue(verfiyJsonFromString(payload));
+ assertThat(requestNode.get("resolution-key").asText()).isEqualTo(TEST_PNF_CORRELATION_ID);
+ assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(TEST_SERVICE_INSTANCE_ID);
+ assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(TEST_MODEL_UUID);
+ assertThat(propertiesNode.get("pnf-id").asText()).isEqualTo(TEST_PNF_UUID);
+ assertThat(propertiesNode.get("pnf-customization-uuid").asText())
+ .isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(propertiesNode.get("target-software-version").asText()).isEqualTo(TEST_SOFTWARE_VERSION);
+ assertThat(pnfCDSRequestProvider.getBlueprintName().equals(TEST_PNF_RESOURCE_BLUEPRINT_NAME));
+ assertThat(pnfCDSRequestProvider.getBlueprintVersion().equals(TEST_PNF_RESOURCE_BLUEPRINT_VERSION));
+ }
+
+ private DelegateExecution prepareDelegateExecutionObj(String scope, String action) {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_TARGET_SOFTWARE_VERSION, TEST_SOFTWARE_VERSION);
+ execution.setVariable(SCOPE, scope);
+ execution.setVariable(ACTION, action);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ return execution;
+ }
+
+ private boolean verfiyJsonFromString(String payload) {
+ JsonParser parser = new JsonParser();
+ return parser.parse(payload).isJsonObject();
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
index 6d5b2a2f28..693dd922e2 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_13i2vsn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_13i2vsn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.5">
<bpmn:process id="ConfigurePnfResource" name="ConfigurePnfResource" isExecutable="true">
<bpmn:startEvent id="ConfigurePnfResource_StartEvent">
<bpmn:outgoing>SequenceFlow_069mxkg</bpmn:outgoing>
@@ -57,6 +57,7 @@
<camunda:inputOutput>
<camunda:inputParameter name="action">config-assign</camunda:inputParameter>
<camunda:inputParameter name="scope">pnf</camunda:inputParameter>
+ <camunda:inputParameter name="mode">sync</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0j3pm2g</bpmn:incoming>
@@ -68,6 +69,7 @@
<camunda:inputOutput>
<camunda:inputParameter name="action">config-deploy</camunda:inputParameter>
<camunda:inputParameter name="scope">pnf</camunda:inputParameter>
+ <camunda:inputParameter name="mode">async</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1owbpsy</bpmn:incoming>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java
index 0f65b4b3d4..ffd49e6b84 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java
@@ -24,6 +24,7 @@ import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.PayloadConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -31,17 +32,23 @@ import org.springframework.stereotype.Component;
* This implementation of {@ref ControllerRunnable} is used for Self service, i.e, blueprint based Controller.
*/
@Component
-public class CdsControllerDE implements ControllerRunnable<DelegateExecution> {
+public class PnfConfigCdsControllerDE implements ControllerRunnable<DelegateExecution> {
+
+ private static final String ASSIGN_ACTION = "config-assign";
+ private static final String DEPLOY_ACTION = "config-deploy";
@Autowired(required = false)
private List<ControllerPreparable<DelegateExecution>> prepareList;
@Autowired
- private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils;
+ private AbstractCDSProcessingBBUtils cdsDispatcher;
@Override
public Boolean understand(ControllerContext<DelegateExecution> context) {
- return context.getControllerActor().equalsIgnoreCase("cds");
+ return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
+ && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(context.getControllerScope())
+ && (ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction())
+ || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction())); // legacy behavior
}
@Override
@@ -58,7 +65,7 @@ public class CdsControllerDE implements ControllerRunnable<DelegateExecution> {
@Override
public void run(ControllerContext<DelegateExecution> context) {
DelegateExecution execution = context.getExecution();
- abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution);
- abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution);
+ cdsDispatcher.constructExecutionServiceInputObject(execution);
+ cdsDispatcher.sendRequestToCDSClient(execution);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java
new file mode 100644
index 0000000000..d5423b2ff7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.GeneratePayloadForCds;
+import org.onap.so.client.cds.PayloadConstants;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * For pnf, DelegateExecution is being used.
+ *
+ * @param - DelegateExecution
+ */
+@Component
+public class GenericPnfCDSProcessingDE implements ControllerRunnable<DelegateExecution> {
+ private static final Logger logger = LoggerFactory.getLogger(GenericPnfCDSProcessingDE.class);
+ private static final String EXECUTION_OBJECT = "executionObject";
+ private static final String ASSIGN_ACTION = "config-assign";
+ private static final String DEPLOY_ACTION = "config-deploy";
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private AbstractCDSProcessingBBUtils cdsDispather;
+
+ @Autowired
+ private GeneratePayloadForCds generatePayloadForCds;
+
+ @Override
+ public Boolean understand(ControllerContext<DelegateExecution> context) {
+ final String scope = context.getControllerScope();
+ return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
+ && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(scope)
+ && !(ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction())
+ || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction()));
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<DelegateExecution> context) {
+ return true;
+ }
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> context) {
+ DelegateExecution delegateExecution = context.getExecution();
+ try {
+ AbstractCDSPropertiesBean abstractCDSPropertiesBean =
+ generatePayloadForCds.buildCdsPropertiesBean(delegateExecution);
+
+ delegateExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
+
+ } catch (Exception ex) {
+ logger.error("An exception occurred when creating payload for CDS request", ex);
+ exceptionBuilder.buildAndThrowWorkflowException(delegateExecution, 7000, ex);
+ }
+ }
+
+ @Override
+ public void run(ControllerContext<DelegateExecution> context) {
+ DelegateExecution obj = context.getExecution();
+ cdsDispather.constructExecutionServiceInputObject(obj);
+ cdsDispather.sendRequestToCDSClient(obj);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
index 860780a2fc..275cd18f0b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
@@ -19,50 +19,63 @@
package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.fail;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
import com.google.protobuf.Struct;
-import java.util.List;
import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.GrpcNettyServer;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.client.aai.AAIVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.fail;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+@RunWith(Parameterized.class)
public class ControllerExecutionDETestIT extends BaseIntegrationTest {
private Logger logger = LoggerFactory.getLogger(this.getClass());
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule smr = new SpringMethodRule();
+
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String ACTIVATE_ACTION = "activateNeSw";
+ private static final String PRECHECK_ACTION = "precheck";
+ private static final String POSTCHECK_ACTION = "postcheck";
+ private static final String ASSIGN_ACTION = "config-assign";
+ private static final String DEPLOY_ACTION = "config-deploy";
+ private static final String CDS_ACTOR = "cds";
+
@Autowired
private ControllerExecutionDE controllerExecutionDE;
@Autowired
private GrpcNettyServer grpcNettyServer;
- private GenericVnf genericVnf;
-
private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
private static String TEST_PROCESS_KEY = "processKey1";
private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
- private static String TEST_CDS_ACTION = "config-assign";
- private static String TEST_APPC_ACTION = "HealthCheck";
+ private static final AAIVersion VERSION = AAIVersion.LATEST;
private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
@@ -70,75 +83,112 @@ public class ControllerExecutionDETestIT extends BaseIntegrationTest {
private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static String TEST_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+
+ private String description;
+ private String action;
+ private String scope;
+
+ public ControllerExecutionDETestIT(String desc, String action, String scope) {
+ this.description = desc;
+ this.action = action;
+ this.scope = scope;
+
+ }
+
+ @Parameterized.Parameters(name = "index {0}")
+ public static Collection<String[]> data() {
+ return Arrays.asList(
+ new String[][] {{"Test JSON for action:" + ACTIVATE_ACTION + " scope:pnf", ACTIVATE_ACTION, "pnf"},
+ {"Test JSON for action:" + DOWNLOAD_ACTION + " scope:pnf", DOWNLOAD_ACTION, "pnf"},
+ {"Test JSON for action:" + ASSIGN_ACTION + " scope:pnf", ASSIGN_ACTION, "pnf"},
+ {"Test JSON for action:" + DEPLOY_ACTION + " scope:pnf", DEPLOY_ACTION, "pnf"},
+ {"Test JSON for action:" + PRECHECK_ACTION + " scope:pnf", PRECHECK_ACTION, "pnf"},
+ {"Test JSON for action:" + POSTCHECK_ACTION + " scope:pnf", POSTCHECK_ACTION, "pnf"}});
+ }
@Before
public void setUp() {
+ delegateExecution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ delegateExecution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
delegateExecution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
delegateExecution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
delegateExecution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
- delegateExecution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ delegateExecution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ delegateExecution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ delegateExecution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ delegateExecution.setVariable("targetSoftwareVersion", TEST_SOFTWARE_VERSION);
+
+ delegateExecution.setVariable("actor", CDS_ACTOR);
+ delegateExecution.setVariable("action", this.action);
+ delegateExecution.setVariable("scope", this.scope);
+
+
+ /**
+ * Get the PNF entry from AAI.
+ */
+ if (action.equalsIgnoreCase(DEPLOY_ACTION)) {
+ final String aaiPnfEntry = "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n"
+ + " \"in-maint\":true,\n" + " \"resource-version\":\"1541720264047\",\n"
+ + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}";
+ wireMockServer.stubFor(
+ get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry)));
+ }
grpcNettyServer.cleanMessage();
}
@Test
- public void testExecution_cdsConfigAssign_actionExecuted() {
-
- configureCdsConfigAssign();
+ public void testExecution_cds_actions() {
controllerExecutionDE.execute(delegateExecution);
List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
assertThat(detailedMessages).hasSize(1);
try {
- checkConfigAssign(detailedMessages.get(0));
+ verifyRequestContentForAction(detailedMessages.get(0));
} catch (Exception e) {
e.printStackTrace();
- fail("ConfigAssign request exception", e);
+ fail(this.action + " request exception", e);
}
}
- private void configureCdsConfigAssign() {
- delegateExecution.setVariable("actor", "cds");
- delegateExecution.setVariable("action", TEST_CDS_ACTION);
- delegateExecution.setVariable("scope", "pnf");
+ private void verifyRequestContentForAction(ExecutionServiceInput executionServiceInput) {
- delegateExecution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
- delegateExecution.setVariable(PNF_UUID, TEST_PNF_UUID);
- delegateExecution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
- delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
- delegateExecution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
- delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
- }
-
- private void checkConfigAssign(ExecutionServiceInput executionServiceInput) {
-
- logger.info("Checking the configAssign request");
+ logger.info("Checking the " + this.action + " request");
ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
- /**
- * the fields of actionIdentifiers should match the one in the
- * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json.
- */
assertThat(actionIdentifiers.getBlueprintName()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
- assertThat(actionIdentifiers.getActionName()).isEqualTo(TEST_CDS_ACTION);
- assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+ assertThat(actionIdentifiers.getActionName()).isEqualTo(this.action);
CommonHeader commonHeader = executionServiceInput.getCommonHeader();
assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
assertThat(commonHeader.getRequestId()).isEqualTo(TEST_MSO_REQUEST_ID);
Struct payload = executionServiceInput.getPayload();
- Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue();
+ Struct requeststruct = payload.getFieldsOrThrow(this.action + "-request").getStructValue();
assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue())
.isEqualTo(TEST_PNF_CORRELATION_ID);
- Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue();
+ Struct propertiesStruct = requeststruct.getFieldsOrThrow(this.action + "-properties").getStructValue();
assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo(TEST_PNF_CORRELATION_ID);
assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).isEqualTo(TEST_MODEL_UUID);
assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
.isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ if (action.equalsIgnoreCase(DEPLOY_ACTION)) {
+ assertThat(actionIdentifiers.getMode()).isEqualTo("async");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv4-address").getStringValue()).isEqualTo("1.1.1.1");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv6-address").getStringValue()).isEqualTo("::/128");
+ } else if (!action.equalsIgnoreCase(ASSIGN_ACTION)) {
+ assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+ assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue())
+ .isEqualTo(TEST_SOFTWARE_VERSION);
+ } else {
+ assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+ }
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java
index 142cb53ed8..d8f607f6d9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java
@@ -37,11 +37,12 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {CdsControllerDE.class, ExceptionBuilder.class, AbstractCDSProcessingBBUtils.class})
-public class CdsControllerDETest {
+@ContextConfiguration(
+ classes = {PnfConfigCdsControllerDE.class, ExceptionBuilder.class, AbstractCDSProcessingBBUtils.class})
+public class PnfConfigCdsControllerDETest {
@Autowired
- private CdsControllerDE cdsControllerDE;
+ private PnfConfigCdsControllerDE pnfConfigCdsControllerDE;
@MockBean
private ControllerContext controllerContext;
@@ -52,20 +53,46 @@ public class CdsControllerDETest {
@Mock
private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils;
- @Before
- public void setUp() {
+ @Test
+ public void testUnderstand_action_assign_TrueReturned() {
+ // when
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ when(controllerContext.getControllerScope()).thenReturn("pnf");
+ when(controllerContext.getControllerAction()).thenReturn("config-assign");
+
+ // verify
+ assertTrue(pnfConfigCdsControllerDE.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_action_deploy_TrueReturned() {
+ // when
when(controllerContext.getControllerActor()).thenReturn("cds");
+ when(controllerContext.getControllerScope()).thenReturn("pnf");
+ when(controllerContext.getControllerAction()).thenReturn("config-deploy");
+
+ // verify
+ assertTrue(pnfConfigCdsControllerDE.understand(controllerContext));
}
@Test
- public void testUnderstand_validContext_TrueReturned() {
- assertTrue(cdsControllerDE.understand(controllerContext));
+ public void testUnderstand_action_any_FalseReturned() {
+ // when
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ when(controllerContext.getControllerScope()).thenReturn("pnf");
+ when(controllerContext.getControllerAction()).thenReturn("any-action");
+
+ // verify
+ assertFalse(pnfConfigCdsControllerDE.understand(controllerContext));
}
@Test
public void testUnderstand_invalidContext_FalseReturned() {
+ // when
when(controllerContext.getControllerActor()).thenReturn("appc");
- assertFalse(cdsControllerDE.understand(controllerContext));
+
+ // verify
+ assertFalse(pnfConfigCdsControllerDE.understand(controllerContext));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java
new file mode 100644
index 0000000000..c69adeec50
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.GeneratePayloadForCds;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import java.util.Arrays;
+import java.util.Collection;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+
+@RunWith(Parameterized.class)
+public class GenericPnfCDSProcessingDETest extends BaseTaskTest {
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule smr = new SpringMethodRule();
+
+ @InjectMocks
+ private GenericPnfCDSProcessingDE controllerRunnable;
+
+ @Mock
+ private GeneratePayloadForCds generatePayloadForCds;
+
+ @Mock
+ private AbstractCDSProcessingBBUtils cdsDispather;
+
+ private static final String PRECHECK_ACTION = "precheck";
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String ACTIVATE_ACTION = "activateNeSw";
+ private static final String POSTCHECK_ACTION = "postcheck";
+
+ private String description;
+ private String action;
+ private String scope;
+ private String expectedJson;
+
+ public GenericPnfCDSProcessingDETest(String desc, String action, String scope, String expectedJson) {
+ this.description = desc;
+ this.action = action;
+ this.scope = scope;
+ this.expectedJson = expectedJson;
+
+ }
+
+ @Parameterized.Parameters(name = "index {0}")
+ public static Collection<String[]> data() {
+ return Arrays.asList(new String[][] {
+ {"Test JSON for action:" + PRECHECK_ACTION + " scope:pnf", PRECHECK_ACTION, "pnf",
+ buildExpectedJson(PRECHECK_ACTION, "pnf")},
+ {"Test JSON for action:" + DOWNLOAD_ACTION + " scope:pnf", DOWNLOAD_ACTION, "pnf",
+ buildExpectedJson(DOWNLOAD_ACTION, "pnf")},
+ {"Test JSON for action:" + ACTIVATE_ACTION + " scope:pnf", ACTIVATE_ACTION, "pnf",
+ buildExpectedJson(ACTIVATE_ACTION, "pnf")},
+ {"Test JSON for action:" + POSTCHECK_ACTION + " scope:pnf", POSTCHECK_ACTION, "pnf",
+ buildExpectedJson(POSTCHECK_ACTION, "pnf")},});
+ }
+
+ private static String buildExpectedJson(String action, String scope) {
+ return "{\"" + action + "-request\":" + "{\"" + action + "-" + "properties\":"
+ + "{\"service-instance-id\":\"test_service_id\","
+ + "\"pnf-customization-uuid\":\"9acb3a83-8a52-412c-9a45-901764938144\","
+ + "\"pnf-id\":\"5df8b6de-2083-11e7-93ae-92361f002671\","
+ + "\"target-software-version\":\"demo-sw-ver2.0.0\"," + "\"pnf-name\":\"PNFDemo\","
+ + "\"service-model-uuid\":\"6bc0b04d-1873-4721-b53d-6615225b2a28\"}," + "\"resolution-key\":\"PNFDemo\""
+ + "}" + "}";
+ }
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Test
+ public void testExecution_validPnf_action_executionObjectCreated() {
+ try {
+
+ // given
+ ControllerContext controllerContext = new ControllerContext();
+ controllerContext.setExecution(execution);
+ controllerContext.setControllerActor("cds");
+ controllerContext.setControllerAction(this.action);
+ controllerContext.setControllerScope(this.scope);
+ AbstractCDSPropertiesBean bean = new AbstractCDSPropertiesBean();
+ doNothing().when(cdsDispather).constructExecutionServiceInputObject(execution);
+ doNothing().when(cdsDispather).sendRequestToCDSClient(execution);
+ doReturn(bean).when(generatePayloadForCds).buildCdsPropertiesBean(execution);
+
+ // when
+ Boolean isUnderstandable = controllerRunnable.understand(controllerContext);
+ Boolean isReady = controllerRunnable.ready(controllerContext);
+ controllerRunnable.prepare(controllerContext);
+ controllerRunnable.run(controllerContext);
+
+ // verify
+ assertEquals(isUnderstandable, true);
+ assertEquals(isReady, true);
+ Object executionObject = execution.getVariable(EXECUTION_OBJECT);
+ assertThat(executionObject).isNotNull();
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
index 0d0e6ee92f..d9955352c6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nordix
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -21,36 +23,23 @@
*/
package org.onap.so.apihandlerinfra;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.TreeSet;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import javax.transaction.Transactional;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.ActivitySequence;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.ArtifactInfo;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.Validation;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowInputParameter;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecification;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecificationList;
-import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
-import org.onap.so.db.catalog.beans.ActivitySpec;
-import org.onap.so.db.catalog.beans.ActivitySpecUserParameters;
-import org.onap.so.db.catalog.beans.UserParameters;
-import org.onap.so.db.catalog.beans.Workflow;
-import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.*;
+import org.onap.so.db.catalog.beans.*;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
@@ -58,16 +47,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.swagger.v3.oas.annotations.OpenAPIDefinition;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.info.Info;
-import io.swagger.v3.oas.annotations.media.ArraySchema;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import javax.transaction.Transactional;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import java.util.*;
+import java.util.stream.Collectors;
+
@Path("onap/so/infra/workflowSpecifications")
@OpenAPIDefinition(info = @Info(title = "onap/so/infra/workflowSpecifications",
@@ -84,6 +72,7 @@ public class WorkflowSpecificationsHandler {
private static Logger logger = LoggerFactory.getLogger(WorkflowSpecificationsHandler.class);
private static final String ARTIFACT_TYPE_WORKFLOW = "workflow";
private static final String NATIVE_WORKFLOW = "native";
+ private static final String EMPTY_BODY = "";
@Path("/{version:[vV]1}/workflows")
@GET
@@ -125,24 +114,29 @@ public class WorkflowSpecificationsHandler {
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Workflow::getArtifactUUID))),
ArrayList::new));
- WorkflowSpecifications workflowSpecifications = mapWorkflowsToWorkflowSpecifications(retWorkflows);
+ Optional<String> optional = getResponseByWorkflowSpec(retWorkflows);
+ return builder.buildResponse(HttpStatus.SC_OK, "", optional.isPresent() ? optional.get() : EMPTY_BODY,
+ apiVersion);
+ }
- String jsonResponse;
- try {
- ObjectMapper mapper = new ObjectMapper();
- jsonResponse = mapper.writeValueAsString(workflowSpecifications);
- } catch (JsonProcessingException e) {
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError)
- .build();
- ValidateException validateException =
- new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
- HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- throw validateException;
- }
+ @Path("/{version:[vV]1}/pnfWorkflows")
+ @GET
+ @Operation(description = "Finds pnf workflow specifications", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
+ @Transactional
+ public Response getWorkflowsSpecForPnf(@PathParam("version") String version) throws Exception {
+
+ final String pnf_resource = "pnf";
+ String apiVersion = version.substring(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- return builder.buildResponse(HttpStatus.SC_OK, "", jsonResponse, apiVersion);
+ List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(pnf_resource);
+
+ Optional<String> optional = getResponseByWorkflowSpec(workflows);
+ return builder.buildResponse(HttpStatus.SC_OK, "", optional.isPresent() ? optional.get() : EMPTY_BODY,
+ apiVersion);
}
protected WorkflowSpecifications mapWorkflowsToWorkflowSpecifications(List<Workflow> workflows) {
@@ -165,6 +159,28 @@ public class WorkflowSpecificationsHandler {
return workflowSpecifications;
}
+ private Optional<String> getResponseByWorkflowSpec(List<Workflow> workflows) throws ValidateException {
+ WorkflowSpecifications workflowSpecifications = mapWorkflowsToWorkflowSpecifications(workflows);
+
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ return Optional.of(mapper.writeValueAsString(workflowSpecifications));
+ } catch (JsonProcessingException e) {
+ catchAndThrowValidationEx(e);
+ }
+ return Optional.empty();
+ }
+
+ private Response catchAndThrowValidationEx(JsonProcessingException e) throws ValidateException {
+ ErrorLoggerInfo errorLoggerInfo =
+ new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build();
+ ValidateException validateException =
+ new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo)
+ .build();
+ throw validateException;
+ }
+
private ArtifactInfo buildArtifactInfo(Workflow workflow) {
ArtifactInfo artifactInfo = new ArtifactInfo();
artifactInfo.setArtifactType(ARTIFACT_TYPE_WORKFLOW);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
index 7af92cb8ef..21e6d53c14 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nordix
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -20,30 +22,15 @@
package org.onap.so.apihandlerinfra;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONException;
import org.junit.Test;
import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowInputParameter;
import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
-import org.onap.so.db.catalog.beans.ActivitySpec;
-import org.onap.so.db.catalog.beans.ActivitySpecUserParameters;
-import org.onap.so.db.catalog.beans.UserParameters;
-import org.onap.so.db.catalog.beans.Workflow;
-import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence;
+import org.onap.so.db.catalog.beans.*;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -53,10 +40,19 @@ 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.core.JsonParseException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
public class WorkflowSpecificationsHandlerTest extends BaseTest {
@Autowired
@@ -65,12 +61,13 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
@Value("${wiremock.server.port}")
private String wiremockPort;
- private final String basePath = "onap/so/infra/workflowSpecifications/v1/workflows";
+ private final String basePath = "onap/so/infra/workflowSpecifications";
@Test
public void queryWorkflowSpecificationsByVnfModelUUID_Test_Success()
throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException {
+ final String urlPath = basePath + "/v1/workflows";
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
@@ -147,7 +144,7 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
.withBody(getWiremockResponseForCatalogdb("UserParameters6_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath))
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(urlPath))
.queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52");
ResponseEntity<String> response =
@@ -174,7 +171,7 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
@Test
public void mapWorkflowsToWorkflowSpecifications_Test_Success() throws Exception {
- List<Workflow> workflows = new ArrayList<Workflow>();
+ List<Workflow> workflows = new ArrayList<>();
Workflow workflow = new Workflow();
workflow.setArtifactUUID("ab6478e4-ea33-3346-ac12-ab121484a333");
workflow.setArtifactName("inPlaceSoftwareUpdate-1_0.bpmn");
@@ -267,8 +264,7 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
activitySpecUserParameter6.setUserParameters(userParameter6);
activitySpecUserParameters.add(activitySpecUserParameter6);
- List<WorkflowActivitySpecSequence> workflowActivitySpecSequences =
- new ArrayList<WorkflowActivitySpecSequence>();
+ List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = new ArrayList<>();
ActivitySpec activitySpec1 = new ActivitySpec();
activitySpec1.setName("VNFQuiesceTrafficActivity");
@@ -325,9 +321,9 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
}
@Test
- public void queryWorkflowSpecificationsByPnfModelUUID_Test_Success()
- throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException {
+ public void queryWorkflowSpecificationsByPnfModelUUID_Test_Success() throws JSONException, IOException {
+ final String urlPath = basePath + "/v1/workflows";
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
@@ -345,7 +341,7 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
.withBody(getWiremockResponseForCatalogdb("Empty_workflowActivitySpecSequence_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath))
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(urlPath))
.queryParam("pnfModelVersionId", "f2d1f2b2-88bb-49da-b716-36ae420ccbff");
ResponseEntity<String> response =
@@ -370,6 +366,54 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
}
+ @Test
+ public void testWorkflowSpecificationsForPnf_Success() throws JSONException, IOException {
+
+ final String urlPath = basePath + "/v1/pnfWorkflows";
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity(null, headers);
+
+ wireMockServer.stubFor(get(urlMatching("/workflow/search/findByResourceTarget[?]resource_target=pnf"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(
+ getWiremockResponseForCatalogdb("WorkflowSpecificationsForPnfWorkflows_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(get(urlMatching("/infraActiveRequests.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(get(urlMatching("/workflow/1/workflowActivitySpecSequence"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("Empty_workflowActivitySpecSequence_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(urlPath));
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ WorkflowSpecifications expectedResponse = mapper.readValue(
+ new String(Files.readAllBytes(
+ Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json"))),
+ WorkflowSpecifications.class);
+ WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ assertThat(expectedResponse, sameBeanAs(realResponse));
+ assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+
private String getWiremockResponseForCatalogdb(String file) {
try {
File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json
index 89675e8f02..6779c1f3e4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/Empty_workflowActivitySpecSequence_Response.json
@@ -2,4 +2,4 @@
"_embedded": {
"workflowActivitySpecSequence": []
}
-}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json
index 257b9dc843..b5b93873c8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json
@@ -17,4 +17,4 @@
}
}
]
-}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfWorkflows_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfWorkflows_Response.json
new file mode 100644
index 0000000000..2447617897
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnfWorkflows_Response.json
@@ -0,0 +1,41 @@
+{
+ "_embedded": {
+ "workflow": [
+ {
+ "artifactChecksum": "MANUAL RECORD",
+ "artifactName": "DummyPnfWorkflow",
+ "artifactUUID": "b2fd5627-55e4-4f4f-8064-9e6f443e9152",
+ "body": null,
+ "created": "2020-02-18T08:28:15.000+0000",
+ "description": "Dummy Pnf Workflow to test custom Pnf workflow",
+ "id": 4,
+ "name": "Dummy Pnf Workflow",
+ "operationName": "DummyPnfWorkflow",
+ "pnfResourceWorkflow": null,
+ "resourceTarget": "pnf",
+ "source": "native",
+ "timeoutMinutes": null,
+ "version": 1.0,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findByResourceTarget?resource_target=pnf"
+ },
+ "workflow": {
+ "href": "http://localhost:8090/workflow/4"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/4/workflowActivitySpecSequence"
+ }
+ }
+ }
+ ]
+ },
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findByResourceTarget?resource_target=pnf"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/4/workflowActivitySpecSequence"
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index cf066f9721..26c33941ed 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -158,6 +158,7 @@ public class CatalogDbClient {
protected static final String HOMING_INSTANCE = "/homingInstance";
protected static final String ARTIFACT_UUID = "artifactUUID";
protected static final String SOURCE = "source";
+ protected static final String RESOURCE_TARGET = "resource_target";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -209,6 +210,7 @@ public class CatalogDbClient {
private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid";
private String findBBNameSelectionReferenceByControllerActorAndScopeAndAction =
"/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
+ private String findWorkflowByResourceTarget = "/findByResourceTarget";
private String serviceURI;
private String vfModuleURI;
@@ -348,6 +350,7 @@ public class CatalogDbClient {
findWorkflowByVnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByVnfModelUUID;
findWorkflowByPnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByPnfModelUUID;
findWorkflowBySource = endpoint + WORKFLOW + SEARCH + findWorkflowBySource;
+ findWorkflowByResourceTarget = endpoint + WORKFLOW + SEARCH + findWorkflowByResourceTarget;
findVnfResourceCustomizationByModelUuid =
endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findVnfResourceCustomizationByModelUuid;
@@ -1084,6 +1087,11 @@ public class CatalogDbClient {
getUri(UriBuilder.fromUri(findWorkflowBySource).queryParam(SOURCE, source).build().toString()));
}
+ public List<Workflow> findWorkflowByResourceTarget(String resourceTarget) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByResourceTarget)
+ .queryParam(RESOURCE_TARGET, resourceTarget).build().toString()));
+ }
+
public String getEndpoint() {
return endpoint;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
index 91c6940e95..93ec54a2eb 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,6 +33,8 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> {
List<Workflow> findBySource(String source);
+ List<Workflow> findByResourceTarget(String resourceTarget);
+
/**
* Used to fetch the @{link Workflow} by the Model UUID.
*
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index 66fc0f5dc5..79e3cbcc08 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nordix
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -179,7 +181,7 @@ public class CatalogDbClientTest {
}
@Test
- public final void testFindWorkflowByPnfModelUUID() throws Exception {
+ public final void testFindWorkflowByPnfModelUUID() {
String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff";
doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
@@ -190,4 +192,16 @@ public class CatalogDbClientTest {
}
+ @Test
+ public final void testFindWorkflowByResourceTarget() {
+ // when
+ final String pnf_resource = "pnf";
+ doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+ catalogDbClient.findWorkflowByResourceTarget(pnf_resource);
+
+ // verify
+ verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByResourceTarget")
+ .queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build()));
+ }
+
}
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
index b07e82b8a8..e47c61d8b4 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
@@ -55,4 +55,14 @@ public class WorkflowRepositoryTest extends BaseTest {
Assert.assertTrue("testingWorkflow.bpmn".equals(workflows.get(0).getArtifactName()));
}
+ @Test
+ public void findByResourceTargetTest() {
+ List<Workflow> workflows = workflowRepository.findByResourceTarget("pnf");
+
+ Assert.assertTrue(workflows != null);
+ Assert.assertTrue(workflows.size() == 1);
+
+ Assert.assertTrue("DummyPnfWorkflow".equals(workflows.get(0).getArtifactName()));
+ }
+
}
diff --git a/version.properties b/version.properties
index 9eb3b93ac9..a0756adf2b 100644
--- a/version.properties
+++ b/version.properties
@@ -3,8 +3,8 @@
# because they are used in Jenkins, whose plug-in doesn't support
major=1
-minor=5
-patch=3
+minor=6
+patch=0
base_version=${major}.${minor}.${patch}