summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java15
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql27
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.10__AlterforWorkFlowDesignerTables.sql14
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java15
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java15
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java123
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java67
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpec.java99
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpecCreateResponse.java61
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Input.java61
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Output.java73
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java52
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java7
-rw-r--r--asdc-controller/src/test/java/org/onap/asdc/activity/ActivitySpecsActionsTest.java76
-rw-r--r--asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java38
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java1
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/BeansTest.java70
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java6
-rw-r--r--asdc-controller/src/test/resources/application-test.yaml2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy1
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java9
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java39
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn95
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java42
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java17
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java17
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java15
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java15
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java148
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java196
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json432
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json (renamed from mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json)59
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json468
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java7
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java17
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java14
-rw-r--r--mso-catalog-db/src/test/resources/data.sql9
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql132
46 files changed, 2424 insertions, 183 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
index 053c6da1cb..469a7ad7e4 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
@@ -69,21 +69,6 @@ public class R__CloudConfigMigration implements JdbcMigration, MigrationInfoProv
CloudConfig cloudConfig = null;
- String tableQuery = "SELECT * FROM identity_services";
- int totalRetries = 20;
- boolean tableExists = false;
- int count = 1;
- while (!tableExists && count != totalRetries) {
- try (Statement stmt = connection.createStatement();) {
- stmt.executeQuery(tableQuery);
- tableExists = true;
- } catch (SQLException e) {
- count++;
- // Wait 5 mintues
- Thread.sleep(300000);
- }
- }
-
// Try the override file
String configLocation = System.getProperty("spring.config.additional-location");
if (configLocation != null) {
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql
new file mode 100644
index 0000000000..c74ce6940c
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql
@@ -0,0 +1,27 @@
+use catalogdb;
+
+DELETE FROM activity_spec_to_activity_spec_parameters;
+DELETE FROM activity_spec_to_activity_spec_categories;
+DELETE FROM activity_spec;
+DELETE FROM activity_spec_categories;
+DELETE FROM activity_spec_parameters;
+
+INSERT INTO activity_spec (NAME, DESCRIPTION, VERSION)
+VALUES ('VNFSetInMaintFlagActivity','Activity to Set InMaint Flag in A&AI',1.0);
+
+INSERT INTO activity_spec_categories (NAME)
+VALUES ('VNF');
+
+INSERT INTO activity_spec_parameters (NAME, TYPE, DIRECTION, DESCRIPTION)
+VALUES('WorkflowException','WorkflowException','outputParameters','Description');
+
+INSERT INTO activity_spec_to_activity_spec_categories(ACTIVITY_SPEC_ID, ACTIVITY_SPEC_CATEGORIES_ID)
+VALUES
+(
+(select ID from ACTIVITY_SPEC where NAME='VNFSetInMaintFlagActivity' and VERSION=1.0),
+(select ID from activity_spec_categories where NAME='VNF'));
+
+INSERT INTO activity_spec_to_activity_spec_parameters( ACTIVITY_SPEC_ID, ACTIVITY_SPEC_PARAMETERS_ID)
+VALUES(
+(select ID from ACTIVITY_SPEC where NAME='VNFSetInMaintFlagActivity' and VERSION=1.0),
+(select ID from activity_spec_parameters where NAME='WorkflowException' and DIRECTION='outputParameters')); \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.10__AlterforWorkFlowDesignerTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.10__AlterforWorkFlowDesignerTables.sql
new file mode 100644
index 0000000000..775455d589
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.10__AlterforWorkFlowDesignerTables.sql
@@ -0,0 +1,14 @@
+use catalogdb;
+
+ALTER TABLE activity_spec_to_activity_spec_categories DROP FOREIGN KEY fk_activity_spec_to_activity_spec_categories__activity_spec_c1;
+
+ALTER TABLE activity_spec_categories modify id INT(11) not null auto_increment;
+
+ALTER TABLE activity_spec_to_activity_spec_categories ADD
+ CONSTRAINT `fk_activity_spec_to_activity_spec_categories__activity_spec_c1`
+ FOREIGN KEY (`ACTIVITY_SPEC_CATEGORIES_ID`)
+ REFERENCES `activity_spec_categories` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE;
+
+ALTER TABLE activity_spec_to_activity_spec_categories modify id INT(11) not null auto_increment; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index e1152bad4a..51b44b0d3a 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -658,4 +658,19 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
Assert.assertNull(workflow);
}
+ @Test
+ public void getWorkflowByModelUUID_validUuid_expectedOutput() {
+ List<Workflow> workflows = client.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
+ assertTrue(workflows != null);
+ assertTrue(workflows.size() != 0);
+
+ assertEquals("testingWorkflow", workflows.get(0).getArtifactName());
+ }
+
+ @Test
+ public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
+ Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
+ Assert.assertNull(workflow);
+ }
+
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
index af00732f2b..0229dd0d85 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
@@ -226,3 +226,6 @@ insert into pnf_resource_customization_to_service(service_model_uuid, resource_m
insert into workflow(artifact_uuid, artifact_name, name, operation_name, version, description, body, resource_target, source) values
('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc');
+
+insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values
+('ff2ae348-214a-11e7-93ae-92361f002671', '1');
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
index d13b1724df..4753b1c18d 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
@@ -67,7 +67,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterAsyncImpl.class);
private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth";
- private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey";
+ private static final String ENCRYPTION_KEY_PROP = "mso.msoKey";
private static final String NETWORK_EXCEPTION_MSG = "Got a NetworkException on createNetwork: ";
private static final String CREATE_NETWORK_ERROR_LOGMSG = "{} {} Error sending createNetwork notification {} ";
private static final String FAULT_INFO_ERROR_LOGMSG = "{} {} Exception - fault info ";
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
index 487b14b942..e81b211b27 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
@@ -359,22 +359,7 @@ public class VnfAdapterRest {
vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
outputs.value = VolumeAdapterRest.testMap();
} else {
- // vnfAdapter.createVnf (createReq.getCloudSiteId(),
- // createReq.getTenantId(),
- // createReq.getVnfType(),
- // createReq.getVnfVersion(),
- // createReq.getVfModuleName(),
- // createReq.getRequestType(),
- // createReq.getVolumeGroupStackId(),
- // createReq.getVfModuleParams(),
- // createReq.getFailIfExists(),
- // createReq.getBackout(),
- // createReq.getMsoRequest(),
- // vfModuleStackId,
- // outputs,
- // vnfRollback);
vnfAdapter.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- // req.getVnfType(),
completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(),
req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(),
req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(),
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index f314d32328..0c56222558 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -296,7 +296,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
- "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
+ "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map,
Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
new Holder<Map<String, String>>(), new Holder<VnfRollback>());
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java
new file mode 100644
index 0000000000..c80e84b574
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc.activity;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.ContentType;
+import org.onap.so.asdc.activity.beans.ActivitySpec;
+import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
+import org.onap.so.client.HttpClient;
+import org.onap.so.client.HttpClientFactory;
+import org.onap.so.utils.TargetEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.net.URL;
+
+@Component
+public class ActivitySpecsActions {
+
+ private static final String ACTIVITY_SPEC_URI = "/v1.0/activity-spec";
+ private static final String ACTIVITY_SPEC_URI_SUFFIX = "/versions/latest/actions";
+ private static final String CERTIFY_ACTIVITY_PAYLOAD = "{\"action\": \"CERTIFY\"}";
+
+ private final HttpClientFactory httpClientFactory = new HttpClientFactory();
+ protected static final Logger logger = LoggerFactory.getLogger(ActivitySpecsActions.class);
+
+ public String createActivitySpec(String hostname, ActivitySpec activitySpec) {
+ if (activitySpec == null) {
+ return null;
+ }
+
+ String activitySpecId = null;
+
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String payload = mapper.writer().writeValueAsString(activitySpec);
+
+ String urlString = UriBuilder.fromUri(hostname).path(ACTIVITY_SPEC_URI).build().toString();
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC);
+ httpClient.addAdditionalHeader("Content-Type", ContentType.APPLICATION_JSON.toString());
+
+ Response response = httpClient.post(payload);
+
+ int statusCode = response.getStatus();
+ if (statusCode != HttpStatus.SC_OK) {
+ logger.warn("{} {} {}", "Error creating activity spec", activitySpec.getName(), statusCode);
+ } else {
+ if (response.getEntity() != null) {
+ ActivitySpecCreateResponse activitySpecCreateResponse =
+ response.readEntity(ActivitySpecCreateResponse.class);
+ if (activitySpecCreateResponse != null) {
+ activitySpecId = activitySpecCreateResponse.getId();
+ } else {
+ logger.warn("{} {}", "Unable to read activity spec", activitySpec.getName());
+ }
+ } else {
+ logger.warn("{} {}", "No activity spec response returned", activitySpec.getName());
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("{} {}", "Exception creating activitySpec", e.getMessage());
+ }
+
+ return activitySpecId;
+ }
+
+ public boolean certifyActivitySpec(String hostname, String activitySpecId) {
+ boolean certificationResult = false;
+ if (activitySpecId == null) {
+ return false;
+ }
+
+ try {
+ String path = ACTIVITY_SPEC_URI + "/" + activitySpecId + ACTIVITY_SPEC_URI_SUFFIX;
+
+ String urlString = UriBuilder.fromUri(hostname).path(path).build().toString();
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC);
+ httpClient.addAdditionalHeader("Content-Type", ContentType.APPLICATION_JSON.toString());
+
+ Response response = httpClient.put(CERTIFY_ACTIVITY_PAYLOAD);
+
+ int statusCode = response.getStatus();
+
+ if (statusCode != HttpStatus.SC_OK) {
+ logger.warn("{} {} {}", "Error certifying activity", activitySpecId, statusCode);
+ } else {
+ certificationResult = true;
+ }
+
+ } catch (Exception e) {
+ logger.warn("{} {}", "Exception certifying activitySpec", e.getMessage());
+ }
+
+ return certificationResult;
+ }
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
new file mode 100644
index 0000000000..46d0f78e35
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc.activity;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+import org.onap.so.asdc.activity.beans.ActivitySpec;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component
+public class DeployActivitySpecs {
+ @Autowired
+ private ActivitySpecsActions activitySpecsActions;
+
+ @Autowired
+ private Environment env;
+
+ private static final String SDC_ENDPOINT = "mso.asdc.config.activity.endpoint";
+
+ protected static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class);
+
+ public void deployActivities() throws Exception {
+ String hostname = this.env.getProperty(SDC_ENDPOINT);
+ List<ActivitySpec> activitySpecs = new ArrayList<ActivitySpec>();
+
+ // Initialize activitySpecs from Catalog DB
+
+ for (ActivitySpec activitySpec : activitySpecs) {
+ String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec);
+ if (activitySpecId != null) {
+ logger.info("{} {}", "Successfully created activitySpec", activitySpec.getName());
+ boolean certificationResult = activitySpecsActions.certifyActivitySpec(hostname, activitySpecId);
+ if (certificationResult) {
+ logger.info("{} {}", "Successfully certified activitySpec", activitySpec.getName());
+ } else {
+ logger.info("{} {}", "Failed to certify activitySpec", activitySpec.getName());
+ }
+ } else {
+ logger.info("{} {}", "Failed to create activitySpec", activitySpec.getName());
+ }
+ }
+ }
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpec.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpec.java
new file mode 100644
index 0000000000..e7d1ff15ab
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpec.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.activity.beans;
+
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"name", "description", "categoryList", "inputs", "outputs"})
+public class ActivitySpec {
+
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("description")
+ private String description;
+ @JsonProperty("categoryList")
+ private List<String> categoryList = null;
+ @JsonProperty("inputs")
+ private List<Input> inputs = null;
+ @JsonProperty("outputs")
+ private List<Output> outputs = null;
+
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @JsonProperty("description")
+ public String getDescription() {
+ return description;
+ }
+
+ @JsonProperty("description")
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @JsonProperty("categoryList")
+ public List<String> getCategoryList() {
+ return categoryList;
+ }
+
+ @JsonProperty("categoryList")
+ public void setCategoryList(List<String> categoryList) {
+ this.categoryList = categoryList;
+ }
+
+ @JsonProperty("inputs")
+ public List<Input> getInputs() {
+ return inputs;
+ }
+
+ @JsonProperty("inputs")
+ public void setInputs(List<Input> inputs) {
+ this.inputs = inputs;
+ }
+
+ @JsonProperty("outputs")
+ public List<Output> getOutputs() {
+ return outputs;
+ }
+
+ @JsonProperty("outputs")
+ public void setOutputs(List<Output> outputs) {
+ this.outputs = outputs;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("name", name).append("description", description)
+ .append("categoryList", categoryList).append("inputs", inputs).append("outputs", outputs).toString();
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpecCreateResponse.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpecCreateResponse.java
new file mode 100644
index 0000000000..13844257b6
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/ActivitySpecCreateResponse.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.activity.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"id", "versionId"})
+public class ActivitySpecCreateResponse {
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("versionId")
+ private String versionId;
+
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("versionId")
+ public String getVersionId() {
+ return versionId;
+ }
+
+ @JsonProperty("versionId")
+ public void setVersionId(String versionId) {
+ this.versionId = versionId;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("id", id).append("versionId", versionId).toString();
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Input.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Input.java
new file mode 100644
index 0000000000..3359d1df2d
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Input.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.activity.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"name", "type"})
+public class Input {
+
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @JsonProperty("type")
+ public String getType() {
+ return type;
+ }
+
+ @JsonProperty("type")
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("name", name).append("type", type).toString();
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Output.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Output.java
new file mode 100644
index 0000000000..1e3d2e4dd2
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/beans/Output.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.activity.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"name", "type", "value"})
+public class Output {
+
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("type")
+ private String type;
+ @JsonProperty("value")
+ private String value;
+
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @JsonProperty("type")
+ public String getType() {
+ return type;
+ }
+
+ @JsonProperty("type")
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @JsonProperty("value")
+ public String getValue() {
+ return value;
+ }
+
+ @JsonProperty("value")
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("name", name).append("type", type).append("value", value).toString();
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index 92326b1907..57e9c173b9 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -1,5 +1,5 @@
/*-
-d * ============LICENSE_START=======================================================
+ * ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
@@ -250,9 +250,11 @@ public class ASDCController {
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
}
- private boolean checkResourceAlreadyDeployed(VfResourceStructure resource) throws ArtifactInstallerException {
+ protected boolean checkResourceAlreadyDeployed(ResourceStructure resource, boolean serviceDeployed)
+ throws ArtifactInstallerException {
- if (toscaInstaller.isResourceAlreadyDeployed(resource)) {
+
+ if (toscaInstaller.isResourceAlreadyDeployed(resource, serviceDeployed)) {
logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(),
resource.getResourceInstance().getResourceInstanceName(),
resource.getResourceInstance().getResourceUUID(), resource.getResourceInstance().getResourceName());
@@ -656,6 +658,7 @@ public class ASDCController {
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
boolean deploySuccessful = true;
String errorMessage = null;
+ boolean serviceDeployed = false;
try {
this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
@@ -686,12 +689,45 @@ public class ASDCController {
resourceStructure.setResourceType(ResourceType.OTHER);
}
- for (IArtifactInfo artifact : resource.getArtifacts()) {
- IDistributionClientDownloadResult resultArtifact =
- this.downloadTheArtifact(artifact, iNotif.getDistributionID());
- if (resultArtifact != null) {
- resourceStructure.addArtifactToStructure(distributionClient, artifact, resultArtifact);
+ try {
+
+ if (!this.checkResourceAlreadyDeployed(resourceStructure, serviceDeployed)) {
+
+ logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: "
+ + resourceStructure.getResourceInstance().getResourceUUID());
+
+ if ("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)) {
+
+ for (IArtifactInfo artifact : resource.getArtifacts()) {
+ IDistributionClientDownloadResult resultArtifact =
+ this.downloadTheArtifact(artifact, iNotif.getDistributionID());
+ if (resultArtifact != null) {
+
+ if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) {
+ logger.debug("VF_MODULE_ARTIFACT: "
+ + new String(resultArtifact.getArtifactPayload(), "UTF-8"));
+ logger.debug(ASDCNotificationLogging
+ .dumpVfModuleMetaDataList(((VfResourceStructure) resourceStructure)
+ .decodeVfModuleArtifact(resultArtifact.getArtifactPayload())));
+ }
+ resourceStructure.addArtifactToStructure(distributionClient, artifact,
+ resultArtifact);
+ }
+ }
+
+ // Deploy VF resource and artifacts
+ logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
+
+
+ this.deployResourceStructure(resourceStructure, toscaResourceStructure);
+ serviceDeployed = true;
+ }
}
+
+ } catch (ArtifactInstallerException e) {
+ deploySuccessful = false;
+ errorMessage = e.getMessage();
+ logger.error("Exception occurred", e);
}
// Deploy VF resource and artifacts
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 0e30b77b01..e61aafac2e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -249,9 +249,10 @@ public class ToscaResourceInstaller {
protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
+ public boolean isResourceAlreadyDeployed(ResourceStructure vfResourceStruct, boolean serviceDeployed)
+ throws ArtifactInstallerException {
boolean status = false;
- VfResourceStructure vfResourceStructure = vfResourceStruct;
+ ResourceStructure vfResourceStructure = vfResourceStruct;
try {
status = vfResourceStructure.isDeployedSuccessfully();
} catch (RuntimeException e) {
@@ -260,7 +261,7 @@ public class ToscaResourceInstaller {
try {
Service existingService =
serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
- if (existingService != null)
+ if (existingService != null && serviceDeployed == false)
status = true;
if (status) {
logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/ActivitySpecsActionsTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/ActivitySpecsActionsTest.java
new file mode 100644
index 0000000000..438120924a
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/asdc/activity/ActivitySpecsActionsTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.asdc.activity;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.so.asdc.BaseTest;
+import org.onap.so.asdc.activity.ActivitySpecsActions;
+import org.onap.so.asdc.activity.beans.ActivitySpec;
+import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ActivitySpecsActionsTest extends BaseTest {
+ @Autowired
+ ActivitySpecsActions activitySpecsActions;
+
+ @Test
+ public void CreateActivitySpec_Test() throws Exception {
+ String HOSTNAME = createURLWithPort("");
+
+ ActivitySpec activitySpec = new ActivitySpec();
+ activitySpec.setName("testActivitySpec");
+ activitySpec.setDescription("Test Activity Spec");
+ ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
+ activitySpecCreateResponse.setId("testActivityId");
+ ObjectMapper mapper = new ObjectMapper();
+ String body = mapper.writeValueAsString(activitySpecCreateResponse);
+ wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withStatus(org.springframework.http.HttpStatus.OK.value()).withBody(body)));
+
+ String activitySpecId = activitySpecsActions.createActivitySpec(HOSTNAME, activitySpec);
+ assertEquals("testActivityId", activitySpecId);
+ }
+
+ @Test
+ public void CertifyActivitySpec_Test() throws Exception {
+ String HOSTNAME = createURLWithPort("");
+
+ String activitySpecId = "testActivitySpec";
+ String urlPath = "/v1.0/activity-spec/testActivitySpec/versions/latest/actions";
+
+ wireMockServer.stubFor(
+ put(urlPathMatching(urlPath)).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withStatus(org.springframework.http.HttpStatus.OK.value())));
+
+ boolean certificationResult = activitySpecsActions.certifyActivitySpec(HOSTNAME, activitySpecId);
+ assertTrue(certificationResult);
+ }
+
+ private String createURLWithPort(String uri) {
+ return "http://localhost:" + wireMockPort + uri;
+ }
+}
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
new file mode 100644
index 0000000000..86f6a89af5
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.asdc.activity;
+
+import org.junit.Test;
+import org.onap.so.asdc.BaseTest;
+import org.onap.so.asdc.activity.DeployActivitySpecs;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public class DeployActivitySpecsTest extends BaseTest {
+
+ @Autowired
+ private DeployActivitySpecs deployActivitySpecs;
+
+ @Test
+ public void DeployActivitySpecs_Test() throws Exception {
+ // Mock catalog DB results
+ deployActivitySpecs.deployActivities();
+ }
+}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
index 0fcf9b0559..7ecd472c50 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
@@ -45,6 +45,7 @@ import com.github.tomakehurst.wiremock.WireMockServer;
@ActiveProfiles("test")
@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
@AutoConfigureWireMock(port = 0)
+
public abstract class BaseTest {
@MockBean
protected VfResourceStructure vfResourceStructure;
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/BeansTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/BeansTest.java
new file mode 100644
index 0000000000..86e4d27a1e
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/BeansTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc;
+
+import org.junit.Test;
+import org.onap.so.openpojo.rules.ToStringTester;
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.PojoClassFilter;
+import com.openpojo.reflection.filters.FilterEnum;
+import com.openpojo.reflection.filters.FilterNonConcrete;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+public class BeansTest {
+
+
+ private PojoClassFilter filterTestClasses = new FilterTestClasses();
+
+ private PojoClassFilter enumFilter = new FilterEnum();
+
+
+ @Test
+ public void pojoStructure() {
+ test("org.onap.so.asdc.activity.beans");
+ }
+
+ private void test(String pojoPackage) {
+ Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule())
+
+ .with(new SetterTester()).with(new GetterTester())
+
+ .with(new SetterTester()).with(new GetterTester()).with(new ToStringTester())
+
+ .build();
+
+
+ validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, enumFilter,
+ new FilterNonConcrete());
+ }
+
+ private static class FilterTestClasses implements PojoClassFilter {
+ @Override
+ public boolean include(PojoClass pojoClass) {
+ return !pojoClass.getSourcePath().contains("/test-classes/");
+ }
+ }
+}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index 99833da3a3..d3c0bdef66 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -131,7 +131,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
doReturn("resourceName").when(resourceInstance).getResourceName();
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure, false);
WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(
watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
@@ -156,7 +156,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
doReturn("resourceName").when(resourceInstance).getResourceName();
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure, false);
verify(vfResourceStructure, times(3)).getResourceInstance();
verify(vfResourceStructure, times(4)).getNotification();
@@ -166,7 +166,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
expectedException.expect(ArtifactInstallerException.class);
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure, false);
}
@Test
diff --git a/asdc-controller/src/test/resources/application-test.yaml b/asdc-controller/src/test/resources/application-test.yaml
index 5ba8521b3c..ec536491a1 100644
--- a/asdc-controller/src/test/resources/application-test.yaml
+++ b/asdc-controller/src/test/resources/application-test.yaml
@@ -89,6 +89,8 @@ mso:
messageBusAddress: localhost,localhost
asdc:
config:
+ activity:
+ endpoint: http://localhost:${wiremock.server.port}
key: 566B754875657232314F5548556D3665
components:
count: 3,
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
index 918bcdd4cc..64567a349e 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
@@ -143,12 +143,14 @@ class ExternalAPIUtil {
String uuid = utils.getRequestID()
logger.debug( "Generated uuid is: " + uuid)
logger.debug( "URL to be used is: " + url)
+ logger.debug("URL to be passed in header is: " + execution.getVariable("SPPartnerUrl"))
HttpClient client = httpClientFactory.newJsonClient(new URL(url), TargetEntity.EXTERNAL)
client.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
client.addAdditionalHeader("X-FromAppId", "MSO")
client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, uuid)
client.addAdditionalHeader("Accept", MediaType.APPLICATION_JSON)
+ client.addAdditionalHeader("Target",execution.getVariable("SPPartnerUrl"))
apiResponse = client.get()
@@ -179,11 +181,13 @@ class ExternalAPIUtil {
String uuid = utils.getRequestID()
logger.debug( "Generated uuid is: " + uuid)
logger.debug( "URL to be used is: " + url)
+ logger.debug("URL to be passed in header is: " + execution.getVariable("SPPartnerUrl"))
HttpClient httpClient = httpClientFactory.newJsonClient(new URL(url), TargetEntity.AAI)
httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
httpClient.addAdditionalHeader("X-FromAppId", "MSO")
httpClient.addAdditionalHeader("X-TransactionId", uuid)
+ httpClient.addAdditionalHeader("Target",execution.getVariable("SPPartnerUrl"))
apiResponse = httpClient.post(payload)
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy
index db11cb6044..837bc77f19 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy
@@ -146,6 +146,7 @@ class ExternalAPIUtilTest {
DelegateExecution delegateExecution = mock(DelegateExecution.class)
given(delegateExecution.getVariable("URN_externalapi_auth")).willReturn("value_externalapi_auth")
given(delegateExecution.getVariable("URN_mso_msoKey")).willReturn("value_mso_msoKey")
+ given(delegateExecution.getVariable("SPPartnerUrl")).willReturn("http://LocalExtAPIURL:8080")
return delegateExecution
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java
index 0e03989e64..419f545cdf 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java
@@ -54,7 +54,6 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable {
private String serviceRole;
private ServiceInstance serviceInstance;
private Request request;
- private Customer customer;
private String callbackURN;
private String sdncVersion;
@JsonProperty("project")
@@ -217,14 +216,6 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable {
this.request = request;
}
- public Customer getCustomer() {
- return customer;
- }
-
- public void setCustomer(Customer customer) {
- this.customer = customer;
- }
-
public String getCallbackURN() {
return callbackURN;
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
index bd430fd679..c61808ebb1 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
@@ -28,18 +28,24 @@ import org.camunda.bpm.application.PostDeploy;
import org.camunda.bpm.application.PreUndeploy;
import org.camunda.bpm.application.ProcessApplicationInfo;
import org.camunda.bpm.engine.ProcessEngine;
+import org.camunda.bpm.engine.repository.DeploymentBuilder;
import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.data.repository.WorkflowRepository;
import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Primary;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -50,12 +56,18 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@SpringBootApplication
@EnableAsync
+@EnableJpaRepositories("org.onap.so.db.catalog.data.repository")
+@EntityScan({"org.onap.so.db.catalog.beans"})
@ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+
public class MSOInfrastructureApplication {
private static final Logger logger = LoggerFactory.getLogger(MSOInfrastructureApplication.class);
+ @Autowired
+ private WorkflowRepository workflowRepository;
+
@Value("${mso.async.core-pool-size}")
private int corePoolSize;
@@ -66,6 +78,7 @@ public class MSOInfrastructureApplication {
private int queueCapacity;
private static final String LOGS_DIR = "logs_dir";
+ private static final String BPMN_SUFFIX = ".bpmn";
private static void setLogsDir() {
@@ -81,7 +94,10 @@ public class MSOInfrastructureApplication {
}
@PostDeploy
- public void postDeploy(ProcessEngine processEngineInstance) {}
+ public void postDeploy(ProcessEngine processEngineInstance) {
+ DeploymentBuilder deploymentBuilder = processEngineInstance.getRepositoryService().createDeployment();
+ deployCustomWorkflows(deploymentBuilder);
+ }
@PreUndeploy
public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo,
@@ -99,4 +115,25 @@ public class MSOInfrastructureApplication {
executor.initialize();
return executor;
}
+
+ public void deployCustomWorkflows(DeploymentBuilder deploymentBuilder) {
+ if (workflowRepository == null) {
+ return;
+ }
+ List<Workflow> workflows = workflowRepository.findAll();
+ if (workflows != null && workflows.size() != 0) {
+ for (Workflow workflow : workflows) {
+ String workflowName = workflow.getName();
+ String workflowBody = workflow.getBody();
+ if (!workflowName.endsWith(BPMN_SUFFIX)) {
+ workflowName += BPMN_SUFFIX;
+ }
+ if (workflowBody != null) {
+ logger.info("{} {}", "Deploying custom workflow", workflowName);
+ deploymentBuilder.addString(workflowName, workflowBody);
+ }
+ }
+ deploymentBuilder.deploy();
+ }
+ }
}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
index ce4d2e1dab..ea762c8719 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
@@ -1,13 +1,9 @@
<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1">
+<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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2">
<bpmn:process id="AssignVnfBB" name="AssignVnfBB" isExecutable="true">
<bpmn:startEvent id="Start_AssignVnfBB">
<bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing>
</bpmn:startEvent>
- <bpmn:serviceTask id="Task_SDNCAdapterVnfTopologyAssign" name="&#10;SDNC &#10;Create Request&#10;(vnf)&#10;" camunda:expression="${SDNCAssignTasks.assignVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_1samncw</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1qkhm79</bpmn:outgoing>
- </bpmn:serviceTask>
<bpmn:endEvent id="End_AssignVnfBB">
<bpmn:incoming>SequenceFlow_0csh9dc</bpmn:incoming>
</bpmn:endEvent>
@@ -18,7 +14,7 @@
<bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_AssignVnfBB" targetRef="Task_CreateVnf" />
<bpmn:sequenceFlow id="SequenceFlow_0csh9dc" sourceRef="Task_UpdateVnfOrchestrationStatusAssigned" targetRef="End_AssignVnfBB" />
<bpmn:serviceTask id="Task_UpdateVnfOrchestrationStatusAssigned" name="&#10;AAI&#10;Update&#10;(vnf)&#10;" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusAssignedVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_1vw20wu</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0yzidhu</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0csh9dc</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="Task_createInstanceGroups" name="&#10;AAI&#10;Create&#10;(instance grp)&#10;" camunda:expression="${AssignVnf.createInstanceGroups(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
@@ -62,6 +58,7 @@
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1i52a7x" sourceRef="StartEvent_1c3cyuv" targetRef="EndEvent_1bywujf" />
</bpmn:subProcess>
+ <bpmn:sequenceFlow id="SequenceFlow_14mpqit" sourceRef="ExclusiveGateway_1blf52g" targetRef="Task_SDNCCreateRequest" />
<bpmn:inclusiveGateway id="ExclusiveGateway_02tchpp" name="Call Homing?" default="SequenceFlow_11jum90">
<bpmn:incoming>SequenceFlow_1nle8kc</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_11jum90</bpmn:outgoing>
@@ -70,7 +67,7 @@
<bpmn:inclusiveGateway id="ExclusiveGateway_1blf52g">
<bpmn:incoming>SequenceFlow_11jum90</bpmn:incoming>
<bpmn:incoming>SequenceFlow_0v8d14a</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1samncw</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_14mpqit</bpmn:outgoing>
</bpmn:inclusiveGateway>
<bpmn:serviceTask id="ServiceTask_ConnectVnfToCloudRegion" name="&#10;AAI&#10;Connect&#10;(vnf to cloud region)&#10;" camunda:expression="${AAICreateTasks.connectVnfToCloudRegion(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_0qj7zcn</bpmn:incoming>
@@ -83,19 +80,22 @@
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_0nsg48b" sourceRef="ServiceTask_ConnectVnfToCloudRegion" targetRef="ServiceTask_ConnectVnfToTenant" />
<bpmn:sequenceFlow id="SequenceFlow_18ixm0j" sourceRef="ServiceTask_ConnectVnfToTenant" targetRef="Task_createPlatform" />
- <bpmn:callActivity id="CallActivity_sdncAssign" name="SDNC Assign (vnf)" calledElement="SDNCHandler">
+ <bpmn:serviceTask id="Task_SDNCCreateRequest" name="&#10;SDNC &#10;Create Request&#10;(vnf)&#10;" camunda:expression="${SDNCAssignTasks.assignVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_14mpqit</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1991eue</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:callActivity id="CallActivity_SDNCAssignVnf" name="SDNC Assign (vnf)" calledElement="SDNCHandler">
<bpmn:extensionElements>
<camunda:in source="SDNCRequest" target="SDNCRequest" />
<camunda:out source="SDNCResponse" target="SDNCResponse" />
<camunda:out source="WorkflowException" target="WorkflowException" />
<camunda:in source="mso-request-id" target="mso-request-id" />
</bpmn:extensionElements>
- <bpmn:incoming>SequenceFlow_1qkhm79</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1vw20wu</bpmn:outgoing>
+ <bpmn:incoming>SequenceFlow_1991eue</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0yzidhu</bpmn:outgoing>
</bpmn:callActivity>
- <bpmn:sequenceFlow id="SequenceFlow_1samncw" sourceRef="ExclusiveGateway_1blf52g" targetRef="Task_SDNCAdapterVnfTopologyAssign" />
- <bpmn:sequenceFlow id="SequenceFlow_1qkhm79" sourceRef="Task_SDNCAdapterVnfTopologyAssign" targetRef="CallActivity_sdncAssign" />
- <bpmn:sequenceFlow id="SequenceFlow_1vw20wu" sourceRef="CallActivity_sdncAssign" targetRef="Task_UpdateVnfOrchestrationStatusAssigned" />
+ <bpmn:sequenceFlow id="SequenceFlow_1991eue" sourceRef="Task_SDNCCreateRequest" targetRef="CallActivity_SDNCAssignVnf" />
+ <bpmn:sequenceFlow id="SequenceFlow_0yzidhu" sourceRef="CallActivity_SDNCAssignVnf" targetRef="Task_UpdateVnfOrchestrationStatusAssigned" />
</bpmn:process>
<bpmn:error id="Error_0rgauy1" name="gDelegateError" errorCode="7000" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
@@ -106,13 +106,10 @@
<dc:Bounds x="-275" y="152" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="ServiceTask_0m0ikey_di" bpmnElement="Task_SDNCAdapterVnfTopologyAssign">
- <dc:Bounds x="930" y="94" width="100" height="80" />
- </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_1h93h9d_di" bpmnElement="End_AssignVnfBB">
- <dc:Bounds x="1323" y="116" width="36" height="36" />
+ <dc:Bounds x="1415" y="116" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1296" y="156" width="90" height="12" />
+ <dc:Bounds x="1388" y="156" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_1r380lg_di" bpmnElement="Task_CreateVnf">
@@ -126,14 +123,14 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0csh9dc_di" bpmnElement="SequenceFlow_0csh9dc">
- <di:waypoint xsi:type="dc:Point" x="1303" y="134" />
- <di:waypoint xsi:type="dc:Point" x="1323" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="1342" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="1415" y="134" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1268" y="113" width="90" height="12" />
+ <dc:Bounds x="1334" y="113" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_0s6d1be_di" bpmnElement="Task_UpdateVnfOrchestrationStatusAssigned">
- <dc:Bounds x="1203" y="94" width="100" height="80" />
+ <dc:Bounds x="1242" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0wjy7za_di" bpmnElement="Task_createInstanceGroups">
<dc:Bounds x="534" y="94" width="100" height="80" />
@@ -194,25 +191,32 @@
<dc:Bounds x="404" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_19596dp_di" bpmnElement="SubProcess_19596dp" isExpanded="true">
- <dc:Bounds x="673" y="239" width="231" height="135" />
+ <dc:Bounds x="249" y="267" width="231" height="135" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_1c3cyuv_di" bpmnElement="StartEvent_1c3cyuv">
- <dc:Bounds x="710" y="295" width="36" height="36" />
+ <dc:Bounds x="286" y="323" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="638" y="331" width="90" height="12" />
+ <dc:Bounds x="259" y="359" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_1bywujf_di" bpmnElement="EndEvent_1bywujf">
- <dc:Bounds x="846" y="295" width="36" height="36" />
+ <dc:Bounds x="422" y="323" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="774" y="331" width="90" height="12" />
+ <dc:Bounds x="395" y="359" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1i52a7x_di" bpmnElement="SequenceFlow_1i52a7x">
- <di:waypoint xsi:type="dc:Point" x="746" y="313" />
- <di:waypoint xsi:type="dc:Point" x="846" y="313" />
+ <di:waypoint xsi:type="dc:Point" x="322" y="341" />
+ <di:waypoint xsi:type="dc:Point" x="422" y="341" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="372" y="320" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_14mpqit_di" bpmnElement="SequenceFlow_14mpqit">
+ <di:waypoint xsi:type="dc:Point" x="899" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="937" y="134" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="751" y="292" width="90" height="12" />
+ <dc:Bounds x="873" y="113" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="InclusiveGateway_0x0c3kk_di" bpmnElement="ExclusiveGateway_02tchpp">
@@ -254,31 +258,26 @@
<dc:Bounds x="259.5" y="113" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="CallActivity_12uxg1m_di" bpmnElement="CallActivity_sdncAssign">
- <dc:Bounds x="1060" y="94" width="100" height="80" />
+ <bpmndi:BPMNShape id="ServiceTask_07icomz_di" bpmnElement="Task_SDNCCreateRequest">
+ <dc:Bounds x="940" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_1samncw_di" bpmnElement="SequenceFlow_1samncw">
- <di:waypoint xsi:type="dc:Point" x="899" y="134" />
- <di:waypoint xsi:type="dc:Point" x="930" y="134" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="914.5" y="113" width="0" height="12" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_1qkhm79_di" bpmnElement="SequenceFlow_1qkhm79">
- <di:waypoint xsi:type="dc:Point" x="1030" y="134" />
- <di:waypoint xsi:type="dc:Point" x="1060" y="134" />
+ <bpmndi:BPMNShape id="CallActivity_09hycsr_di" bpmnElement="CallActivity_SDNCAssignVnf">
+ <dc:Bounds x="1088" y="94" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1991eue_di" bpmnElement="SequenceFlow_1991eue">
+ <di:waypoint xsi:type="dc:Point" x="1040" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="1088" y="134" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1045" y="113" width="0" height="12" />
+ <dc:Bounds x="1064" y="113" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_1vw20wu_di" bpmnElement="SequenceFlow_1vw20wu">
- <di:waypoint xsi:type="dc:Point" x="1160" y="134" />
- <di:waypoint xsi:type="dc:Point" x="1203" y="134" />
+ <bpmndi:BPMNEdge id="SequenceFlow_0yzidhu_di" bpmnElement="SequenceFlow_0yzidhu">
+ <di:waypoint xsi:type="dc:Point" x="1188" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="1242" y="134" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1181.5" y="113" width="0" height="12" />
+ <dc:Bounds x="1215" y="113" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
-
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
index 078b0ae4e2..9943e39ef6 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
@@ -39,9 +39,8 @@ public class AssignVnfBBTest extends BaseBPMNTest {
assertThat(pi).isNotNull();
assertThat(pi).isStarted().hasPassedInOrder("Start_AssignVnfBB", "Task_CreateVnf",
"ServiceTask_ConnectVnfToCloudRegion", "ServiceTask_ConnectVnfToTenant", "Task_createPlatform",
- "Task_createLineOfBusiness", "Task_createInstanceGroups", "Task_callHoming",
- "Task_SDNCAdapterVnfTopologyAssign", "CallActivity_sdncAssign",
- "Task_UpdateVnfOrchestrationStatusAssigned", "End_AssignVnfBB");
+ "Task_createLineOfBusiness", "Task_createInstanceGroups", "Task_callHoming", "Task_SDNCCreateRequest",
+ "CallActivity_SDNCAssignVnf", "Task_UpdateVnfOrchestrationStatusAssigned", "End_AssignVnfBB");
assertThat(pi).isEnded();
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
index c8b48c6703..1578f0f7c0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
@@ -347,8 +347,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
logger.info(" ***** Started prepare3rdONAPRequest *****")
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
- String extAPIPath = sppartnerUrl + '/serviceOrder'
+ String extAPIPath = UrnPropertiesReader.getVariable("extapi.endpoint", execution) + '/serviceOrder'
execution.setVariable("ExternalAPIURL", extAPIPath)
+ execution.setVariable("SPPartnerUrl",sppartnerUrl)
// ExternalAPI message format
String externalId = execution.getVariable("resourceName")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java
new file mode 100644
index 0000000000..267ddbf6a7
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.pnf;
+
+import org.springframework.context.ApplicationEvent;
+
+public class PnfNotificationEvent extends ApplicationEvent {
+
+ private String pnfCorrelationId;
+
+ /**
+ * Create a new ApplicationEvent.
+ *
+ * @param source the object on which the event initially occurred (never {@code null})
+ */
+ public PnfNotificationEvent(Object source, String pnfCorrelationId) {
+ super(source);
+ this.pnfCorrelationId = pnfCorrelationId;
+ }
+
+ public String getPnfCorrelationId() {
+ return pnfCorrelationId;
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
index 5cbd530a93..e2dc375cd1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
@@ -23,14 +23,20 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@Component
-public class InformDmaapClient implements JavaDelegate {
+public class InformDmaapClient implements JavaDelegate, ApplicationListener<PnfNotificationEvent> {
+ private Logger logger = LoggerFactory.getLogger(getClass());
private DmaapClient dmaapClient;
+ private DelegateExecution execution;
@Override
public void execute(DelegateExecution execution) {
@@ -38,10 +44,19 @@ public class InformDmaapClient implements JavaDelegate {
RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService.createMessageCorrelation("WorkflowMessage")
.processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult());
+ this.execution = execution;
}
@Autowired
public void setDmaapClient(DmaapClient dmaapClient) {
this.dmaapClient = dmaapClient;
}
+
+ @Override
+ public void onApplicationEvent(PnfNotificationEvent event) {
+ logger.info("Received application event for pnfCorrelationId: {}", event.getPnfCorrelationId());
+ RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
+ runtimeService.createMessageCorrelation("WorkflowMessage")
+ .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult();
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
index 3de0f38b70..2869111485 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
@@ -35,9 +35,11 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
+import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@@ -53,8 +55,11 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private volatile ScheduledThreadPoolExecutor executor;
private volatile boolean dmaapThreadListenerIsRunning;
+ private ApplicationEventPublisher applicationEventPublisher;
+
@Autowired
- public PnfEventReadyDmaapClient(Environment env) {
+ public PnfEventReadyDmaapClient(Environment env, ApplicationEventPublisher applicationEventPublisher) {
+ this.applicationEventPublisher = applicationEventPublisher;
httpClient = HttpClientBuilder.create().build();
pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>();
topicListenerDelayInSeconds = env.getProperty("pnf.dmaap.topicListenerDelayInSeconds", Integer.class);
@@ -130,13 +135,9 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
}
private void informAboutPnfReadyIfPnfCorrelationIdFound(String pnfCorrelationId) {
- Runnable runnable = unregister(pnfCorrelationId);
- if (runnable != null) {
- logger.debug("dmaap listener gets pnf ready event for pnfCorrelationId: {}", pnfCorrelationId);
- // runnable.run();
- runnable = null;
- }
+ unregister(pnfCorrelationId);
+ PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, pnfCorrelationId);
+ applicationEventPublisher.publishEvent(pnfNotificationEvent);
}
}
-
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
index 446c73dda1..96c3db0ccc 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
@@ -27,12 +27,14 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
+import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
public class InformDmaapClientTest {
+
@Before
public void setUp() throws Exception {
informDmaapClient = new InformDmaapClient();
@@ -71,6 +73,19 @@ public class InformDmaapClientTest {
inOrder.verify(messageCorrelationBuilder).correlateWithResult();
}
+ @Test
+ public void onApplicationEvent_validPnfNotificationEvent_expectedOutput() {
+
+ PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, "testPnfCorrelationId");
+
+ informDmaapClient.execute(delegateExecution);
+ informDmaapClient.onApplicationEvent(pnfNotificationEvent);
+
+ InOrder inOrder = inOrder(messageCorrelationBuilder);
+ inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey");
+ inOrder.verify(messageCorrelationBuilder).correlateWithResult();
+ }
+
private DelegateExecution mockDelegateExecution() {
DelegateExecution delegateExecution = mock(DelegateExecution.class);
when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID)))
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
index ca3373e8cb..9f31e2a5df 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -25,8 +25,10 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
@@ -47,9 +49,12 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.env.Environment;
@RunWith(MockitoJUnitRunner.class)
@@ -80,6 +85,9 @@ public class PnfEventReadyDmaapClientTest {
private Runnable threadMockToNotifyCamundaFlow;
private ScheduledThreadPoolExecutor executorMock;
+ @Mock
+ private ApplicationEventPublisher applicationEventPublisher;
+
@Before
public void init() throws NoSuchFieldException, IllegalAccessException {
when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT);
@@ -91,7 +99,7 @@ public class PnfEventReadyDmaapClientTest {
when(env.getProperty(eq("pnf.dmaap.consumerGroup"))).thenReturn(CONSUMER_GROUP);
when(env.getProperty(eq("pnf.dmaap.topicListenerDelayInSeconds"), eq(Integer.class)))
.thenReturn(TOPIC_LISTENER_DELAY_IN_SECONDS);
- testedObject = new PnfEventReadyDmaapClient(env);
+ testedObject = new PnfEventReadyDmaapClient(env, applicationEventPublisher);
testedObjectInnerClassThread = testedObject.new DmaapTopicListenerThread();
httpClientMock = mock(HttpClient.class);
threadMockToNotifyCamundaFlow = mock(Runnable.class);
@@ -123,7 +131,10 @@ public class PnfEventReadyDmaapClientTest {
assertEquals(captor1.getValue().getURI().getPath(),
"/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
- // verify(threadMockToNotifyCamundaFlow).run();
+ /**
+ * Two PNF returned from HTTP request.
+ */
+ verify(applicationEventPublisher, times(2)).publishEvent(any(PnfNotificationEvent.class));
verify(executorMock).shutdown();
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
index abab08bdf3..b0517ace3d 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
@@ -1,16 +1,21 @@
-/*
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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
*
- * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
- * Foundation. ================================================================================ 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
*
- * 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.
+ * 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=========================================================
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
package org.onap.so.bpmn.infrastructure.process;
@@ -25,10 +30,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.assertj.core.api.Assertions.fail;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
import com.google.protobuf.Struct;
-import com.google.protobuf.Value;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
import org.camunda.bpm.engine.runtime.Execution;
import org.camunda.bpm.engine.runtime.ProcessInstance;
@@ -114,6 +117,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest {
if (!execution.isSuspended() && !execution.isEnded()) {
try {
+
runtimeService.signal(execution.getId());
} catch (Exception e) {
logger.info(e.getMessage(), e);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
index c6ed1cca7a..968723c628 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -95,8 +94,6 @@ public class SDNCUnassignTasksTest extends BaseTaskTest {
assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
}
-
-
@Test
public void unassignServiceInstanceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -115,8 +112,6 @@ public class SDNCUnassignTasksTest extends BaseTaskTest {
assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
}
-
-
@Test
public void unassignVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -136,7 +131,6 @@ public class SDNCUnassignTasksTest extends BaseTaskTest {
assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
}
-
@Test
public void unassignVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
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 bc4f389469..c480bdfbd3 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
@@ -19,8 +19,11 @@
*/
package org.onap.so.apihandlerinfra;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+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;
@@ -32,7 +35,19 @@ 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.db.catalog.client.CatalogDbClient;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,11 +66,17 @@ public class WorkflowSpecificationsHandler {
@Autowired
private ResponseBuilder builder;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ private static final String ARTIFACT_TYPE_WORKFLOW = "workflow";
+
@Path("/{version:[vV]1}/workflows")
@GET
@ApiOperation(value = "Finds Workflow Specifications", response = Response.class)
@Transactional
- public Response queryFilters(@QueryParam("vnfModelVersionId") String vnfModelVersionId,
+
+ public Response queryWorkflowSpecifications(@QueryParam("vnfModelVersionId") String vnfModelVersionId,
@PathParam("version") String version) throws Exception {
String apiVersion = version.substring(1);
@@ -63,10 +84,8 @@ public class WorkflowSpecificationsHandler {
ObjectMapper mapper1 = new ObjectMapper();
mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- // Replace with Catalog DB Query
- WorkflowSpecifications workflowSpecifications = mapper1.readValue(
- new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))),
- WorkflowSpecifications.class);
+ List<Workflow> workflows = catalogDbClient.findWorkflowByModelUUID(vnfModelVersionId);
+ WorkflowSpecifications workflowSpecifications = mapWorkflowsToWorkflowSpecifications(workflows);
String jsonResponse = null;
try {
@@ -85,4 +104,119 @@ public class WorkflowSpecificationsHandler {
return builder.buildResponse(HttpStatus.SC_OK, "", jsonResponse, apiVersion);
}
+
+ protected WorkflowSpecifications mapWorkflowsToWorkflowSpecifications(List<Workflow> workflows) {
+ if (workflows == null || workflows.size() == 0) {
+ return null;
+ }
+ WorkflowSpecifications workflowSpecifications = new WorkflowSpecifications();
+ List<WorkflowSpecificationList> workflowSpecificationList = new ArrayList<WorkflowSpecificationList>();
+
+ for (Workflow workflow : workflows) {
+ WorkflowSpecificationList workflowSpecificationListItem = new WorkflowSpecificationList();
+ WorkflowSpecification workflowSpecification = new WorkflowSpecification();
+ workflowSpecification.setArtifactInfo(buildArtifactInfo(workflow));
+ workflowSpecification.setActivitySequence(buildActivitySequence(workflow));
+ workflowSpecification.setWorkflowInputParameters(buildWorkflowInputParameters(workflow));
+ workflowSpecificationListItem.setWorkflowSpecification(workflowSpecification);
+ workflowSpecificationList.add(workflowSpecificationListItem);
+ }
+ workflowSpecifications.setWorkflowSpecificationList(workflowSpecificationList);
+ return workflowSpecifications;
+ }
+
+ private ArtifactInfo buildArtifactInfo(Workflow workflow) {
+ ArtifactInfo artifactInfo = new ArtifactInfo();
+ artifactInfo.setArtifactType(ARTIFACT_TYPE_WORKFLOW);
+ artifactInfo.setArtifactUuid(workflow.getArtifactUUID());
+ artifactInfo.setArtifactName(workflow.getArtifactName());
+ if (workflow.getVersion() != null) {
+ artifactInfo.setArtifactVersion(workflow.getVersion().toString());
+ }
+ artifactInfo.setArtifactDescription(workflow.getDescription());
+ artifactInfo.setWorkflowName(workflow.getName());
+ artifactInfo.setOperationName(workflow.getOperationName());
+ artifactInfo.setWorkflowSource(workflow.getSource());
+ artifactInfo.setWorkflowResourceTarget(workflow.getResourceTarget());
+ return artifactInfo;
+ }
+
+ private List<ActivitySequence> buildActivitySequence(Workflow workflow) {
+ List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = workflow.getWorkflowActivitySpecSequence();
+ if (workflowActivitySpecSequences == null || workflowActivitySpecSequences.size() == 0) {
+ return null;
+ }
+ List<ActivitySequence> activitySequences = new ArrayList<ActivitySequence>();
+ for (WorkflowActivitySpecSequence workflowActivitySpecSequence : workflowActivitySpecSequences) {
+ if (workflowActivitySpecSequence != null) {
+ ActivitySpec activitySpec = workflowActivitySpecSequence.getActivitySpec();
+ if (activitySpec != null) {
+ ActivitySequence activitySequence = new ActivitySequence();
+ activitySequence.setName(activitySpec.getName());
+ activitySequence.setDescription(activitySpec.getDescription());
+ activitySequences.add(activitySequence);
+ }
+ }
+ }
+ return activitySequences;
+ }
+
+ private List<WorkflowInputParameter> buildWorkflowInputParameters(Workflow workflow) {
+ List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = workflow.getWorkflowActivitySpecSequence();
+ if (workflowActivitySpecSequences == null || workflowActivitySpecSequences.size() == 0) {
+ return null;
+ }
+ Map<String, WorkflowInputParameter> workflowInputParameterMap = new HashMap<String, WorkflowInputParameter>();
+ for (WorkflowActivitySpecSequence workflowActivitySpecSequence : workflowActivitySpecSequences) {
+ if (workflowActivitySpecSequence != null) {
+ ActivitySpec activitySpec = workflowActivitySpecSequence.getActivitySpec();
+ if (activitySpec != null) {
+ List<ActivitySpecUserParameters> activitySpecUserParameters =
+ activitySpec.getActivitySpecUserParameters();
+ if (activitySpecUserParameters != null && activitySpecUserParameters.size() != 0) {
+ for (ActivitySpecUserParameters activitySpecUserParameter : activitySpecUserParameters) {
+ UserParameters userParameter = activitySpecUserParameter.getUserParameters();
+ if (userParameter != null) {
+ WorkflowInputParameter workflowInputParameter =
+ buildWorkflowInputParameter(userParameter);
+ workflowInputParameterMap.put(userParameter.getName(), workflowInputParameter);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (workflowInputParameterMap.size() == 0) {
+ return null;
+ }
+ List<WorkflowInputParameter> workflowInputParameterList =
+ workflowInputParameterMap.values().stream().collect(Collectors.toList());
+ return workflowInputParameterList;
+ }
+
+ private WorkflowInputParameter buildWorkflowInputParameter(UserParameters userParameter) {
+ WorkflowInputParameter workflowInputParameter = new WorkflowInputParameter();
+ workflowInputParameter.setLabel(userParameter.getLabel());
+ workflowInputParameter.setInputType(userParameter.getType());
+ workflowInputParameter.setRequired(userParameter.getIsRequried());
+ workflowInputParameter.setSoFieldName(userParameter.getName());
+ workflowInputParameter.setSoPayloadLocation(userParameter.getPayloadLocation());
+ workflowInputParameter.setValidation(buildValidationList(userParameter));
+ return workflowInputParameter;
+ }
+
+ private List<Validation> buildValidationList(UserParameters userParameter) {
+ List<Validation> validationList = null;
+ if (userParameter.getMaxLength() != null || userParameter.getAllowableChars() != null) {
+ validationList = new ArrayList<Validation>();
+ Validation validation = new Validation();
+ if (userParameter.getMaxLength() != null) {
+ validation.setMaxLength(userParameter.getMaxLength().toString());
+ }
+ validation.setAllowableChars(userParameter.getAllowableChars());
+ validationList.add(validation);
+ }
+ return validationList;
+ }
}
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 7678de1a19..48abeacbc5 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
@@ -20,22 +20,38 @@
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 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.skyscreamer.jsonassert.JSONAssert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
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;
@@ -43,11 +59,16 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class WorkflowSpecificationsHandlerTest extends BaseTest {
+ @Autowired
+ WorkflowSpecificationsHandler workflowSpecificationsHandler;
+
+ @Value("${wiremock.server.port}")
+ private String wiremockPort;
private final String basePath = "onap/so/infra/workflowSpecifications/v1/workflows";
@Test
- public void getTasksTestByOriginalRequestId()
+ public void queryWorkflowSpecifications_Test_Success()
throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException {
HttpHeaders headers = new HttpHeaders();
@@ -55,26 +76,191 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest {
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+ wireMockServer.stubFor(get(urlMatching(
+ "/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("WorkflowSpecificationsQuery_Response.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("WorkflowActivitySpecSequence_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath))
.queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52");
ResponseEntity<String> response =
restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
- ObjectMapper mapper = new ObjectMapper();
+ 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/WorkflowSpecifications.json"))),
+ new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecifications.json"))),
WorkflowSpecifications.class);
+ WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
- assertThat(realResponse, sameBeanAs(expectedResponse));
+ 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));
}
+
+ @Test
+ public void mapWorkflowsToWorkflowSpecifications_Test_Success() throws Exception {
+ List<Workflow> workflows = new ArrayList<Workflow>();
+ Workflow workflow = new Workflow();
+ workflow.setArtifactUUID("ab6478e4-ea33-3346-ac12-ab121484a333");
+ workflow.setArtifactName("inPlaceSoftwareUpdate-1_0.bpmn");
+ workflow.setVersion(1.0);
+ workflow.setDescription("xyz xyz");
+ workflow.setName("inPlaceSoftwareUpdate");
+ workflow.setOperationName("inPlaceSoftwareUpdate");
+ workflow.setSource("sdc");
+ workflow.setResourceTarget("vnf");
+
+ UserParameters userParameter1 = new UserParameters();
+ userParameter1.setLabel("Operations Timeout");
+ userParameter1.setType("text");
+ userParameter1.setIsRequried(true);
+ userParameter1.setMaxLength(50);
+ userParameter1.setAllowableChars("someRegEx");
+ userParameter1.setName("operations_timeout");
+ userParameter1.setPayloadLocation("userParams");
+
+ UserParameters userParameter2 = new UserParameters();
+ userParameter2.setLabel("Existing Software Version");
+ userParameter2.setType("text");
+ userParameter2.setIsRequried(true);
+ userParameter2.setMaxLength(50);
+ userParameter2.setAllowableChars("someRegEx");
+ userParameter2.setName("existing_software_version");
+ userParameter2.setPayloadLocation("userParams");
+
+ UserParameters userParameter3 = new UserParameters();
+ userParameter3.setLabel("Cloud Owner");
+ userParameter3.setType("text");
+ userParameter3.setIsRequried(true);
+ userParameter3.setMaxLength(7);
+ userParameter3.setAllowableChars("someRegEx");
+ userParameter3.setName("cloudOwner");
+ userParameter3.setPayloadLocation("cloudConfiguration");
+
+ UserParameters userParameter4 = new UserParameters();
+ userParameter4.setLabel("Tenant/Project ID");
+ userParameter4.setType("text");
+ userParameter4.setIsRequried(true);
+ userParameter4.setMaxLength(36);
+ userParameter4.setAllowableChars("someRegEx");
+ userParameter4.setName("tenantId");
+ userParameter4.setPayloadLocation("cloudConfiguration");
+
+ UserParameters userParameter5 = new UserParameters();
+ userParameter5.setLabel("New Software Version");
+ userParameter5.setType("text");
+ userParameter5.setIsRequried(true);
+ userParameter5.setMaxLength(50);
+ userParameter5.setAllowableChars("someRegEx");
+ userParameter5.setName("new_software_version");
+ userParameter5.setPayloadLocation("userParams");
+
+ UserParameters userParameter6 = new UserParameters();
+ userParameter6.setLabel("Cloud Region ID");
+ userParameter6.setType("text");
+ userParameter6.setIsRequried(true);
+ userParameter6.setMaxLength(7);
+ userParameter6.setAllowableChars("someRegEx");
+ userParameter6.setName("lcpCloudRegionId");
+ userParameter6.setPayloadLocation("cloudConfiguration");
+
+
+ List<ActivitySpecUserParameters> activitySpecUserParameters = new ArrayList<ActivitySpecUserParameters>();
+
+ ActivitySpecUserParameters activitySpecUserParameter1 = new ActivitySpecUserParameters();
+ activitySpecUserParameter1.setUserParameters(userParameter1);
+ activitySpecUserParameters.add(activitySpecUserParameter1);
+
+ ActivitySpecUserParameters activitySpecUserParameter2 = new ActivitySpecUserParameters();
+ activitySpecUserParameter2.setUserParameters(userParameter2);
+ activitySpecUserParameters.add(activitySpecUserParameter2);
+
+ ActivitySpecUserParameters activitySpecUserParameter3 = new ActivitySpecUserParameters();
+ activitySpecUserParameter3.setUserParameters(userParameter3);
+ activitySpecUserParameters.add(activitySpecUserParameter3);
+
+
+ ActivitySpecUserParameters activitySpecUserParameter4 = new ActivitySpecUserParameters();
+ activitySpecUserParameter4.setUserParameters(userParameter4);
+ activitySpecUserParameters.add(activitySpecUserParameter4);
+
+ ActivitySpecUserParameters activitySpecUserParameter5 = new ActivitySpecUserParameters();
+ activitySpecUserParameter5.setUserParameters(userParameter5);
+ activitySpecUserParameters.add(activitySpecUserParameter5);
+
+ ActivitySpecUserParameters activitySpecUserParameter6 = new ActivitySpecUserParameters();
+ activitySpecUserParameter6.setUserParameters(userParameter6);
+ activitySpecUserParameters.add(activitySpecUserParameter6);
+
+ List<WorkflowActivitySpecSequence> workflowActivitySpecSequences =
+ new ArrayList<WorkflowActivitySpecSequence>();
+
+ ActivitySpec activitySpec1 = new ActivitySpec();
+ activitySpec1.setName("VNFQuiesceTrafficActivity");
+ activitySpec1.setDescription("Activity to QuiesceTraffic on VNF");
+ activitySpec1.setActivitySpecUserParameters(activitySpecUserParameters);
+ WorkflowActivitySpecSequence workflowActivitySpecSequence1 = new WorkflowActivitySpecSequence();
+ workflowActivitySpecSequence1.setActivitySpec(activitySpec1);
+ workflowActivitySpecSequences.add(workflowActivitySpecSequence1);
+
+ ActivitySpec activitySpec2 = new ActivitySpec();
+ activitySpec2.setName("VNFHealthCheckActivity");
+ activitySpec2.setDescription("Activity to HealthCheck VNF");
+ activitySpec2.setActivitySpecUserParameters(activitySpecUserParameters);
+ WorkflowActivitySpecSequence workflowActivitySpecSequence2 = new WorkflowActivitySpecSequence();
+ workflowActivitySpecSequence2.setActivitySpec(activitySpec2);
+ workflowActivitySpecSequences.add(workflowActivitySpecSequence2);
+
+ ActivitySpec activitySpec3 = new ActivitySpec();
+ activitySpec3.setName("FlowCompleteActivity");
+ activitySpec3.setDescription("Activity to Complete the BPMN Flow");
+ activitySpec3.setActivitySpecUserParameters(activitySpecUserParameters);
+ WorkflowActivitySpecSequence workflowActivitySpecSequence3 = new WorkflowActivitySpecSequence();
+ workflowActivitySpecSequence3.setActivitySpec(activitySpec3);
+ workflowActivitySpecSequences.add(workflowActivitySpecSequence3);
+
+ workflow.setWorkflowActivitySpecSequence(workflowActivitySpecSequences);
+ workflows.add(workflow);
+
+ WorkflowSpecifications workflowSpecifications =
+ workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows);
+ ObjectMapper mapper = new ObjectMapper();
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ String workflowSpecificationsJson = mapper.writeValueAsString(workflowSpecifications);
+ WorkflowSpecifications expectedResult = mapper.readValue(
+ new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecifications.json"))),
+ WorkflowSpecifications.class);
+ String expectedResultJson = mapper.writeValueAsString(expectedResult);
+
+ JSONAssert.assertEquals(expectedResultJson, workflowSpecificationsJson, false);
+ assertThat(expectedResult, sameBeanAs(workflowSpecifications).ignoring(WorkflowInputParameter.class));
+ }
+
+ private String getWiremockResponseForCatalogdb(String file) {
+ try {
+ File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
+ return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
+ "localhost:" + wiremockPort);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json
new file mode 100644
index 0000000000..3192865b52
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json
@@ -0,0 +1,432 @@
+{
+ "_embedded": {
+
+ "workflowActivitySpecSequence": [
+ {
+ "activitySpecId": null,
+ "workflowId": null,
+ "activitySpec": {
+ "name": "VNFQuiesceTrafficActivity",
+ "description": "Activity to QuiesceTraffic on VNF",
+ "version": null,
+ "created": null,
+ "workflowActivitySpecSequence": null,
+ "activitySpecActivitySpecCategories": null,
+ "activitySpecUserParameters": [
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "operations_timeout",
+ "payloadLocation": "userParams",
+ "label": "Operations Timeout",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "existing_software_version",
+ "payloadLocation": "userParams",
+ "label": "Existing Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "cloudOwner",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Owner",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "tenantId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Tenant/Project ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 36,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "new_software_version",
+ "payloadLocation": "userParams",
+ "label": "New Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "lcpCloudRegionId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Region ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ }
+ ],
+ "activitySpecActivitySpecParameters": null,
+ "id": null
+ },
+ "workflow": null,
+ "id": null,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+ }
+
+ }
+
+ },
+ {
+ "activitySpecId": null,
+ "workflowId": null,
+ "activitySpec": {
+ "name": "VNFHealthCheckActivity",
+ "description": "Activity to HealthCheck VNF",
+ "version": null,
+ "created": null,
+ "workflowActivitySpecSequence": null,
+ "activitySpecActivitySpecCategories": null,
+ "activitySpecUserParameters": [
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "operations_timeout",
+ "payloadLocation": "userParams",
+ "label": "Operations Timeout",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "existing_software_version",
+ "payloadLocation": "userParams",
+ "label": "Existing Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "cloudOwner",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Owner",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "tenantId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Tenant/Project ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 36,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "new_software_version",
+ "payloadLocation": "userParams",
+ "label": "New Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "lcpCloudRegionId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Region ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ }
+ ],
+ "activitySpecActivitySpecParameters": null,
+ "id": null
+ },
+ "workflow": null,
+ "id": null,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+ }
+
+ }
+ },
+ {
+ "activitySpecId": null,
+ "workflowId": null,
+ "activitySpec": {
+ "name": "FlowCompleteActivity",
+ "description": "Activity to Complete the BPMN Flow",
+ "version": null,
+ "created": null,
+ "workflowActivitySpecSequence": null,
+ "activitySpecActivitySpecCategories": null,
+ "activitySpecUserParameters": [
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "operations_timeout",
+ "payloadLocation": "userParams",
+ "label": "Operations Timeout",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "existing_software_version",
+ "payloadLocation": "userParams",
+ "label": "Existing Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "cloudOwner",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Owner",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "tenantId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Tenant/Project ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 36,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "new_software_version",
+ "payloadLocation": "userParams",
+ "label": "New Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "lcpCloudRegionId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Region ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ }
+ ],
+ "activitySpecActivitySpecParameters": null,
+ "id": null
+ },
+ "workflow": null,
+ "id": null,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+ }
+
+ }
+ }
+ ]
+
+}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json
index beca93bd70..5556c602be 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json
@@ -28,60 +28,60 @@
}
],
"workflowInputParameters": [
- {
- "label": "Cloud Owner",
+ {
+ "label": "Operations Timeout",
"inputType": "text",
"required": true,
"validation": [
{
- "maxLength": "7",
+ "maxLength": "50",
"allowableChars": "someRegEx"
}
],
- "soFieldName": "cloudOwner",
- "soPayloadLocation": "cloudConfiguration"
- },
+ "soFieldName": "operations_timeout",
+ "soPayloadLocation": "userParams"
+ },
{
- "label": "Cloud Region ID",
+ "label": "Existing Software Version",
"inputType": "text",
"required": true,
"validation": [
{
- "maxLength": "7",
+ "maxLength": "50",
"allowableChars": "someRegEx"
}
],
- "soFieldName": "lcpCloudRegionId",
- "soPayloadLocation": "cloudConfiguration"
- },
+ "soFieldName": "existing_software_version",
+ "soPayloadLocation": "userParams"
+ },
{
- "label": "Tenant/Project ID",
+ "label": "Cloud Owner",
"inputType": "text",
"required": true,
"validation": [
{
- "maxLength": "36",
+ "maxLength": "7",
"allowableChars": "someRegEx"
}
],
- "soFieldName": "tenantId",
+ "soFieldName": "cloudOwner",
"soPayloadLocation": "cloudConfiguration"
- },
+ },
{
- "label": "Operations Timeout",
+ "label": "Tenant/Project ID",
"inputType": "text",
"required": true,
"validation": [
{
- "maxLength": "50",
+ "maxLength": "36",
"allowableChars": "someRegEx"
}
],
- "soFieldName": "operations_timeout",
- "soPayloadLocation": "userParams"
- },
+ "soFieldName": "tenantId",
+ "soPayloadLocation": "cloudConfiguration"
+ },
{
- "label": "Existing Software Version",
+ "label": "New Software Version",
"inputType": "text",
"required": true,
"validation": [
@@ -90,27 +90,24 @@
"allowableChars": "someRegEx"
}
],
- "soFieldName": "existing_software_version",
+ "soFieldName": "new_software_version",
"soPayloadLocation": "userParams"
},
- {
- "label": "New Software Version",
+ {
+ "label": "Cloud Region ID",
"inputType": "text",
"required": true,
"validation": [
{
- "maxLength": "50",
+ "maxLength": "7",
"allowableChars": "someRegEx"
}
],
- "soFieldName": "new_software_version",
- "soPayloadLocation": "userParams"
- }
+ "soFieldName": "lcpCloudRegionId",
+ "soPayloadLocation": "cloudConfiguration"
+ }
]
}
- },
- {
- "workflowSpecification": {}
}
]
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json
new file mode 100644
index 0000000000..c12365649e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json
@@ -0,0 +1,468 @@
+{
+ "_embedded": {
+ "workflows" :[
+ {
+ "artifactUUID": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn",
+ "name": "inPlaceSoftwareUpdate",
+ "operationName": "inPlaceSoftwareUpdate",
+ "version": 1,
+ "description": "xyz xyz",
+ "body": null,
+ "resourceTarget": "vnf",
+ "source": "sdc",
+ "timeoutMinutes": null,
+ "artifactChecksum": null,
+ "created": null,
+ "vnfResourceWorkflow": null,
+ "workflowActivitySpecSequence": [
+ {
+ "activitySpecId": null,
+ "workflowId": null,
+ "activitySpec": {
+ "name": "VNFQuiesceTrafficActivity",
+ "description": "Activity to QuiesceTraffic on VNF",
+ "version": null,
+ "created": null,
+ "workflowActivitySpecSequence": null,
+ "activitySpecActivitySpecCategories": null,
+ "activitySpecUserParameters": [
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "operations_timeout",
+ "payloadLocation": "userParams",
+ "label": "Operations Timeout",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "existing_software_version",
+ "payloadLocation": "userParams",
+ "label": "Existing Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "cloudOwner",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Owner",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "tenantId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Tenant/Project ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 36,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "new_software_version",
+ "payloadLocation": "userParams",
+ "label": "New Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "lcpCloudRegionId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Region ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ }
+ ],
+ "activitySpecActivitySpecParameters": null,
+ "id": null
+ },
+ "workflow": null,
+ "id": null,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+ }
+
+ }
+
+ },
+ {
+ "activitySpecId": null,
+ "workflowId": null,
+ "activitySpec": {
+ "name": "VNFHealthCheckActivity",
+ "description": "Activity to HealthCheck VNF",
+ "version": null,
+ "created": null,
+ "workflowActivitySpecSequence": null,
+ "activitySpecActivitySpecCategories": null,
+ "activitySpecUserParameters": [
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "operations_timeout",
+ "payloadLocation": "userParams",
+ "label": "Operations Timeout",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "existing_software_version",
+ "payloadLocation": "userParams",
+ "label": "Existing Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "cloudOwner",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Owner",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "tenantId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Tenant/Project ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 36,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "new_software_version",
+ "payloadLocation": "userParams",
+ "label": "New Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "lcpCloudRegionId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Region ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ }
+ ],
+ "activitySpecActivitySpecParameters": null,
+ "id": null
+ },
+ "workflow": null,
+ "id": null,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+ }
+
+ }
+ },
+ {
+ "activitySpecId": null,
+ "workflowId": null,
+ "activitySpec": {
+ "name": "FlowCompleteActivity",
+ "description": "Activity to Complete the BPMN Flow",
+ "version": null,
+ "created": null,
+ "workflowActivitySpecSequence": null,
+ "activitySpecActivitySpecCategories": null,
+ "activitySpecUserParameters": [
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "operations_timeout",
+ "payloadLocation": "userParams",
+ "label": "Operations Timeout",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "existing_software_version",
+ "payloadLocation": "userParams",
+ "label": "Existing Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "cloudOwner",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Owner",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "tenantId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Tenant/Project ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 36,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "new_software_version",
+ "payloadLocation": "userParams",
+ "label": "New Software Version",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 50,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ },
+ {
+ "activitySpecId": null,
+ "userParametersId": null,
+ "activitySpec": null,
+ "userParameters": {
+ "name": "lcpCloudRegionId",
+ "payloadLocation": "cloudConfiguration",
+ "label": "Cloud Region ID",
+ "type": "text",
+ "description": null,
+ "isRequried": true,
+ "maxLength": 7,
+ "allowableChars": "someRegEx",
+ "created": null,
+ "activitySpecUserParameters": null,
+ "id": null
+ },
+ "id": null
+ }
+ ],
+ "activitySpecActivitySpecParameters": null,
+ "id": null
+ },
+ "workflow": null,
+ "id": null,
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence"
+ }
+
+ }
+ }
+ ],
+ "id": null,
+
+ "_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/1/workflowActivitySpecSequence"
+ }
+
+ }
+
+ }
+]
+},
+"_links": {
+ "self": {
+ "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"
+ },
+ "workflowActivitySpecSequence": {
+ "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/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 f75ccf0b2f..a2ca4a3814 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
@@ -190,6 +190,7 @@ public class CatalogDbClient {
private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId";
private String findPnfResourceCustomizationByModelUuid = "/findPnfResourceCustomizationByModelUuid";
private String findWorkflowByArtifactUUID = "/findByArtifactUUID";
+ private String findWorkflowByModelUUID = "/findWorkflowByModelUUID";
private String serviceURI;
private String vfModuleURI;
@@ -330,6 +331,7 @@ public class CatalogDbClient {
endpoint + PNF_RESOURCE_CUSTOMIZATION + SEARCH + findPnfResourceCustomizationByModelUuid;
findWorkflowByArtifactUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByArtifactUUID;
+ findWorkflowByModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByModelUUID;
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
@@ -872,4 +874,9 @@ public class CatalogDbClient {
return this.getSingleResource(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByArtifactUUID)
.queryParam(ARTIFACT_UUID, artifactUUID).build().toString()));
}
+
+ public List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByModelUUID)
+ .queryParam(VNF_RESOURCE_MODEL_UUID, vnfResourceModelUUID).build().toString()));
+ }
}
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 b73896ac5c..fb5f202cbc 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
@@ -20,11 +20,28 @@
package org.onap.so.db.catalog.data.repository;
+import java.util.List;
import org.onap.so.db.catalog.beans.Workflow;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "workflow", path = "workflow")
public interface WorkflowRepository extends JpaRepository<Workflow, String> {
+
Workflow findByArtifactUUID(String artifactUUID);
+
+ /**
+ * Used to fetch the @{link Workflow} by the Model UUID.
+ *
+ * This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on
+ * model UUID without projection.
+ *
+ * @param vnfResourceModelUUIDmodel UUID
+ * @return List of Workflow
+ */
+ @Query(value = "select b.* from vnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.VNF_RESOURCE_MODEL_UUID = ?1",
+ nativeQuery = true)
+ List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID);
}
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 d541627d0e..4f31e4b38c 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
@@ -18,12 +18,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
+import org.junit.Assert;
import org.junit.Test;
import org.onap.so.db.catalog.BaseTest;
-import org.onap.so.db.catalog.beans.PnfResource;
-import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.beans.Workflow;
-import org.onap.so.db.catalog.exceptions.NoEntityFoundException;
import org.springframework.beans.factory.annotation.Autowired;
public class WorkflowRepositoryTest extends BaseTest {
@@ -38,4 +36,14 @@ public class WorkflowRepositoryTest extends BaseTest {
assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName());
}
+ @Test
+ public void findByVnfResourceModelUUIDTest() throws Exception {
+ List<Workflow> workflows = workflowRepository.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
+
+ Assert.assertTrue(workflows != null);
+ Assert.assertTrue(workflows.size() != 0);
+
+ Assert.assertTrue("testingWorkflow".equals(workflows.get(0).getArtifactName()));
+ }
+
}
diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql
index ade183ee6a..825b541fda 100644
--- a/mso-catalog-db/src/test/resources/data.sql
+++ b/mso-catalog-db/src/test/resources/data.sql
@@ -741,3 +741,12 @@ insert into pnf_resource_customization_to_service(service_model_uuid, resource_m
insert into workflow(artifact_uuid, artifact_name, name, operation_name, version, description, body, resource_target, source) values
('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc');
+
+insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values
+('ff2ae348-214a-11e7-93ae-92361f002671', '1');
+
+insert into activity_spec(name, description, version) values
+('testActivity1', 'Test Activity 1', 1);
+
+insert into workflow_activity_spec_sequence(workflow_id, activity_spec_id, seq_no) values
+(1, 1, 1);
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index d5a73b0f07..92979f4f32 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -1234,6 +1234,138 @@ CREATE TABLE IF NOT EXISTS `vnf_resource_to_workflow` (
CONSTRAINT `fk_vnf_resource_to_workflow__workflow1` FOREIGN KEY (`WORKFLOW_ID`) REFERENCES `workflow` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE IF NOT EXISTS `activity_spec` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `NAME` VARCHAR(200) NOT NULL,
+ `DESCRIPTION` VARCHAR(1200) NOT NULL,
+ `VERSION` DOUBLE NOT NULL,
+ `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_activity_spec` (`NAME` ASC, `VERSION` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `user_parameters` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `NAME` VARCHAR(200) NOT NULL,
+ `PAYLOAD_LOCATION` VARCHAR(500) NULL,
+ `LABEL` VARCHAR(200) NOT NULL,
+ `TYPE` VARCHAR(200) NOT NULL,
+ `DESCRIPTION` VARCHAR(1200) NULL,
+ `IS_REQUIRED` TINYINT(1) NOT NULL,
+ `MAX_LENGTH` INT(11) NULL,
+ `ALLOWABLE_CHARS` VARCHAR(200) NULL,
+ `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_user_parameters` (`NAME` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `workflow_activity_spec_sequence` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `WORKFLOW_ID` INT(11) NOT NULL,
+ `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+ `SEQ_NO` INT(11) NOT NULL,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_workflow_activity_spec_sequence` (`WORKFLOW_ID` ASC, `ACTIVITY_SPEC_ID` ASC, `SEQ_NO` ASC),
+ INDEX `fk_workflow_activity_spec_sequence__activity_spec_idx` (`ACTIVITY_SPEC_ID` ASC),
+ INDEX `fk_workflow_activity_spec_sequence__workflow_actifact_uuid_idx` (`WORKFLOW_ID` ASC),
+ CONSTRAINT `fk_workflow_activity_spec_sequence__activity_spec1`
+ FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+ REFERENCES `activity_spec` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_workflow_activity_spec_sequence__workflow1`
+ FOREIGN KEY (`WORKFLOW_ID`)
+ REFERENCES `workflow` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_parameters` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `NAME` VARCHAR(200) NOT NULL,
+ `TYPE` VARCHAR(200) NOT NULL,
+ `DIRECTION` VARCHAR(200) NULL,
+ `DESCRIPTION` VARCHAR(1200) NULL,
+ `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_activity_spec_parameters` (`NAME` ASC, `DIRECTION` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_categories` (
+ `ID` INT(11) NOT NULL,
+ `NAME` VARCHAR(200) NOT NULL,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_activity_spec_categories` (`NAME` ASC))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_to_activity_spec_categories` (
+ `ID` INT(11) NOT NULL,
+ `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+ `ACTIVITY_SPEC_CATEGORIES_ID` INT(11) NOT NULL,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_activity_spec_to_activity_spec_categories` (`ACTIVITY_SPEC_ID` ASC, `ACTIVITY_SPEC_CATEGORIES_ID` ASC),
+ INDEX `fk_activity_spec_to_activity_spec_categories__activity_spec_idx` (`ACTIVITY_SPEC_CATEGORIES_ID` ASC),
+ INDEX `fk_activity_spec_to_activity_spec_categories__activity_spec_idx1` (`ACTIVITY_SPEC_ID` ASC),
+ CONSTRAINT `fk_activity_spec_to_activity_spec_categories__activity_spec1`
+ FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+ REFERENCES `activity_spec` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_activity_spec_to_activity_spec_categories__activity_spec_c1`
+ FOREIGN KEY (`ACTIVITY_SPEC_CATEGORIES_ID`)
+ REFERENCES `activity_spec_categories` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_to_activity_spec_parameters` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+ `ACTIVITY_SPEC_PARAMETERS_ID` INT(11) NOT NULL,
+ PRIMARY KEY (`ID`),
+ INDEX `fk_activity_spec_to_activity_spec_params__act_sp_param_id_idx` (`ACTIVITY_SPEC_PARAMETERS_ID` ASC),
+ UNIQUE INDEX `UK_activity_spec_to_activity_spec_parameters` (`ACTIVITY_SPEC_ID` ASC, `ACTIVITY_SPEC_PARAMETERS_ID` ASC),
+ INDEX `fk_activity_spec_to_activity_spec_parameters__act_spec_id_idx` (`ACTIVITY_SPEC_ID` ASC),
+ CONSTRAINT `fk_activity_spec_to_activity_spec_parameters__activity_spec_1`
+ FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+ REFERENCES `activity_spec` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_activity_spec_to_activity_spec_parameters__activ_spec_param1`
+ FOREIGN KEY (`ACTIVITY_SPEC_PARAMETERS_ID`)
+ REFERENCES `activity_spec_parameters` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS `activity_spec_to_user_parameters` (
+ `ID` INT(11) NOT NULL,
+ `ACTIVITY_SPEC_ID` INT(11) NOT NULL,
+ `USER_PARAMETERS_ID` INT(11) NOT NULL,
+ PRIMARY KEY (`ID`),
+ UNIQUE INDEX `UK_activity_spec_to_user_parameters` (`ACTIVITY_SPEC_ID` ASC, `USER_PARAMETERS_ID` ASC),
+ INDEX `fk_activity_spec_to_user_parameters__user_parameters1_idx` (`USER_PARAMETERS_ID` ASC),
+ INDEX `fk_activity_spec_to_user_parameters__activity_spec1_idx` (`ACTIVITY_SPEC_ID` ASC),
+ CONSTRAINT `fk_activity_spec_to_user_parameters__activity_spec1`
+ FOREIGN KEY (`ACTIVITY_SPEC_ID`)
+ REFERENCES `activity_spec` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_activity_spec_to_user_parameters__user_parameters1`
+ FOREIGN KEY (`USER_PARAMETERS_ID`)
+ REFERENCES `user_parameters` (`ID`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+