aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapters-rest-interface/.gitignore1
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql8
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql8
-rw-r--r--adapters/mso-openstack-adapters/.gitignore3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java4
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml4
-rw-r--r--adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml4
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java2
-rw-r--r--adapters/mso-vfc-adapter/src/test/resources/application-test.yaml4
-rw-r--r--asdc-controller/src/test/resources/application-test.yaml4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy53
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml3
-rw-r--r--bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java11
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetwork1802BB.bpmn92
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn6
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn80
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignNetwork1802BBTest.java57
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java56
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml3
-rw-r--r--cloudify-client/.gitignore1
-rw-r--r--common/.gitignore1
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java4
-rw-r--r--common/src/main/java/org/onap/so/client/RestRequest.java2
-rw-r--r--deployment-configs/.gitignore1
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/.gitignore1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java28
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java51
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java146
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java421
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java58
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java2
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java4
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java28
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java12
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/client/RequestsDbClient.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java)120
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml4
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java106
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java83
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java20
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java37
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java80
-rw-r--r--mso-catalog-db/src/test/resources/data.sql6
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql13
65 files changed, 953 insertions, 909 deletions
diff --git a/adapters/mso-adapters-rest-interface/.gitignore b/adapters/mso-adapters-rest-interface/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/adapters/mso-adapters-rest-interface/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql
new file mode 100644
index 0000000000..dbeba53acc
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql
@@ -0,0 +1,8 @@
+use catalogdb;
+
+CREATE TABLE IF NOT EXISTS `controller_selection_reference` (
+ `VNF_TYPE` VARCHAR(50) NOT NULL,
+ `CONTROLLER_NAME` VARCHAR(100) NOT NULL,
+ `ACTION_CATEGORY` VARCHAR(15) NOT NULL,
+ PRIMARY KEY (`VNF_TYPE`, `CONTROLLER_NAME`, `ACTION_CATEGORY`)
+ ) ENGINE = InnoDB DEFAULT CHARSET=latin1;
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql
new file mode 100644
index 0000000000..126710e879
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql
@@ -0,0 +1,8 @@
+use catalogdb;
+
+DELETE FROM building_block_detail WHERE BUILDING_BLOCK_NAME = 'AssignNetwork1802BB';
+DELETE FROM building_block_detail WHERE BUILDING_BLOCK_NAME = 'UnassignNetwork1802BB';
+
+UPDATE orchestration_flow_reference SET `FLOW_NAME`='UnassignNetworkBB' WHERE `COMPOSITE_ACTION`='Network-Delete' and `FLOW_NAME`='UnassignNetwork1802BB';
+UPDATE orchestration_flow_reference SET `FLOW_NAME`='AssignNetworkBB' WHERE `COMPOSITE_ACTION`='Network-Create' and `FLOW_NAME`='AssignNetwork1802BB';
+
diff --git a/adapters/mso-openstack-adapters/.gitignore b/adapters/mso-openstack-adapters/.gitignore
index 2af7cefb0a..3467f05c98 100644
--- a/adapters/mso-openstack-adapters/.gitignore
+++ b/adapters/mso-openstack-adapters/.gitignore
@@ -21,4 +21,5 @@ build/
nbbuild/
dist/
nbdist/
-.nb-gradle/ \ No newline at end of file
+.nb-gradle/
+/bin/
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
index d638e47e8c..fbafdd052e 100644
--- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
+++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
@@ -78,8 +78,8 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro
this.cloudConfig = cloudConfig;
}
- private CloudConfig loadCloudConfig(InputStream stream) throws JsonParseException, JsonMappingException, IOException {
- ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ private CloudConfig loadCloudConfig(InputStream stream) throws JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
R__CloudConfigMigration cloudConfigMigration =
mapper.readValue(stream, R__CloudConfigMigration.class);
CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig();
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml
index 2b4e7808b5..102b52985c 100644
--- a/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml
+++ b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml
@@ -6,6 +6,10 @@ server:
max-threads: 50
ssl-enable: false
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
site-name: localSite
spring:
diff --git a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml
index 6a5db78f8b..49582ec513 100644
--- a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml
@@ -6,6 +6,10 @@ server:
max-threads: 50
ssl-enable: false
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
site-name: localSite
infra-requests:
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java
index 10fa02a1d1..d53e467865 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java
@@ -26,10 +26,10 @@ import static org.junit.Assert.*;
import javax.ws.rs.core.Response;
-import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.vfc.MSOVfcApplication;
+import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
diff --git a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml
index 64de62c2d6..d558d247d7 100644
--- a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml
@@ -5,6 +5,10 @@ server:
max-threads: 50
ssl-enable: false
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
site-name: localSite
infra-requests:
diff --git a/asdc-controller/src/test/resources/application-test.yaml b/asdc-controller/src/test/resources/application-test.yaml
index 99ca630695..9cfc500618 100644
--- a/asdc-controller/src/test/resources/application-test.yaml
+++ b/asdc-controller/src/test/resources/application-test.yaml
@@ -51,6 +51,10 @@ management:
enabled: true
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
catalog:
db:
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index c7fcc5c5d3..35e68bb79f 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Intel Corp. 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.
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index 7c5ffca4ab..8ce633845b 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Intel Corp. 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.
@@ -82,20 +82,20 @@ class OofUtils {
//ServiceInstance Info
ServiceInstance serviceInstance = decomposition.getServiceInstance()
def serviceInstanceId = ""
- def serviceInstanceName = ""
+ def serviceName = ""
serviceInstanceId = execution.getVariable("serviceInstanceId")
- serviceInstanceName = execution.getVariable("serviceInstanceName")
+ serviceName = execution.getVariable("subscriptionServiceType")
if (serviceInstanceId == null || serviceInstanceId == "null") {
utils.log("DEBUG", "Unable to obtain Service Instance Id", isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
- "obtain Service Instance Id, execution.getVariable(\"serviceInstanceName\") is null")
+ "obtain Service Instance Id, execution.getVariable(\"serviceInstanceId\") is null")
}
- if (serviceInstanceName == null || serviceInstanceName == "null") {
- utils.log("DEBUG", "Unable to obtain Service Instance Name", isDebugEnabled)
+ if (serviceName == null || serviceName == "null") {
+ utils.log("DEBUG", "Unable to obtain Service Name", isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
- "obtain Service Instance Name, execution.getVariable(\"serviceInstanceName\") is null")
+ "obtain Service Name, execution.getVariable(\"subscriptionServiceType\") is null")
}
//Model Info
ModelInfo model = decomposition.getModelInfo()
@@ -144,24 +144,12 @@ class OofUtils {
utils.log("DEBUG", "Allotted Resource: " + resource.toString(),
isDebugEnabled)
def serviceResourceId = resource.getResourceId()
- def resourceModuleName = resource.getNfFunction()
- utils.log("DEBUG", "resourceModuleName: " + resourceModuleName,
- isDebugEnabled)
- def resourceModelInvariantId = "no-resourceModelInvariantId"
- def resourceModelVersionId = "no-resourceModelVersionId"
-
- List modelIdLst = execution.getVariable("homingModelIds")
- utils.log("DEBUG", "Incoming modelIdLst is: " + modelIdLst.toString(), isDebugEnabled)
- for (Map modelId : modelIdLst )
- if (resourceModuleName == modelId.resourceModuleName) {
- resourceModelInvariantId = modelId.resourceModelInvariantId
- resourceModelVersionId = modelId.resourceModelVersionId
- }
-
- def resourceModelName = "" //Optional
- def resourceModelVersion = "" //Optional
- def resourceModelType = "" //Optional
- def tenantId = "" //Optional
+ def resourceModelInvariantId = resource.getModelInfo().getModelInvariantUuid()
+ def resourceModelVersionId = resource.getModelInfo().getModelUuid()
+ def resourceModelName = resource.getModelInfo().getModelName()
+ def resourceModelVersion = resource.getModelInfo().getModelVersion()
+ def resourceModelType = resource.getModelInfo().getModelType()
+ def tenantId = execution.getVariable("tenantId")
def requiredCandidatesJson = ""
requiredCandidatesJson = createCandidateJson(
@@ -171,7 +159,7 @@ class OofUtils {
String demand =
" {\n" +
- " \"resourceModuleName\": \"${resourceModuleName}\",\n" +
+ " \"resourceModuleName\": \"${resourceModelName}\",\n" +
" \"serviceResourceId\": \"${serviceResourceId}\",\n" +
" \"tenantId\": \"${tenantId}\",\n" +
" \"resourceModelInfo\": {\n" +
@@ -191,21 +179,18 @@ class OofUtils {
isDebugEnabled)
ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()
def serviceResourceId = vnfResource.getResourceId()
- def resourceModuleName = vnfResource.getNfFunction()
- utils.log("DEBUG", "resourceModuleName: " + resourceModuleName,
- isDebugEnabled)
def resourceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid()
def resourceModelName = vnfResourceModelInfo.getModelName()
def resourceModelVersion = vnfResourceModelInfo.getModelVersion()
def resourceModelVersionId = vnfResourceModelInfo.getModelUuid()
def resourceModelType = vnfResourceModelInfo.getModelType()
- def tenantId = "" //Optional
+ def tenantId = execution.getVariable("tenantId")
def requiredCandidatesJson = ""
String placementDemand =
" {\n" +
- " \"resourceModuleName\": \"${resourceModuleName}\",\n" +
+ " \"resourceModuleName\": \"${resourceModelName}\",\n" +
" \"serviceResourceId\": \"${serviceResourceId}\",\n" +
" \"tenantId\": \"${tenantId}\",\n" +
" \"resourceModelInfo\": {\n" +
@@ -297,7 +282,7 @@ class OofUtils {
" },\n" +
" \"serviceInfo\": {\n" +
" \"serviceInstanceId\": \"${serviceInstanceId}\",\n" +
- " \"serviceName\": \"${serviceInstanceName}\",\n" +
+ " \"serviceName\": \"${serviceName}\",\n" +
" \"modelInfo\": {\n" +
" \"modelType\": \"${modelType}\",\n" +
" \"modelInvariantId\": \"${modelInvariantId}\",\n" +
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
index 715ddaa937..f039441738 100644
--- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
+++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
@@ -31,6 +31,9 @@ log:
vnfAdapterRestV1: 'true'
mso:
adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
completemsoprocess:
endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess
db:
diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java
index bbdaa94581..17ede2f2ff 100644
--- a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java
+++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java
@@ -51,7 +51,8 @@ public class RESTClientTest {
private String jsonResponseAsString;
@Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090));
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
+
@Before
public void before() throws Exception {
@@ -62,7 +63,7 @@ public class RESTClientTest {
jsonResponse = new JSONObject();
jsonResponse.put("response", "responseValue");
jsonResponseAsString = jsonResponse.toString();
- restClient = new RESTClient("http://localhost:28090/example", "localhost", 28090);
+ restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example", "localhost", wireMockRule.port());
}
@Test
@@ -79,9 +80,9 @@ public class RESTClientTest {
assertEquals(1, restClient.getParameters().size());
restClient.addAuthorizationHeader("token");
assertEquals("[token]", restClient.getHeaders().get("Authorization").toString());
- assertEquals("http://localhost:28090/example", restClient.getURL());
- restClient = new RESTClient("http://localhost:28090/example1");
- assertEquals("http://localhost:28090/example1", restClient.getURL());
+ assertEquals("http://localhost:" + wireMockRule.port() + "/example", restClient.getURL());
+ restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example1");
+ assertEquals("http://localhost:" + wireMockRule.port() + "/example1", restClient.getURL());
}
@Test
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetwork1802BB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetwork1802BB.bpmn
deleted file mode 100644
index cb4be0279e..0000000000
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetwork1802BB.bpmn
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
- <bpmn2:process id="AssignNetwork1802BB" name="AssignNetwork1802BB" isExecutable="true">
- <bpmn2:startEvent id="AssignNetworkBB_start" name="Start Flow">
- <bpmn2:outgoing>SequenceFlow_11op1ih</bpmn2:outgoing>
- </bpmn2:startEvent>
- <bpmn2:serviceTask id="ServiceTask_get_cloud_region" name="Process cloud region by version&#10;" camunda:expression="${AssignNetworkBBUtils.getCloudRegion(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn2:incoming>SequenceFlow_11op1ih</bpmn2:incoming>
- <bpmn2:outgoing>SequenceFlow_32</bpmn2:outgoing>
- </bpmn2:serviceTask>
- <bpmn2:serviceTask id="ServiceTask_assign_network_sdnc" name="Assign Network (SDNC)" camunda:expression="${SDNCAssignTasks.assignNetwork(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn2:incoming>SequenceFlow_32</bpmn2:incoming>
- <bpmn2:outgoing>SequenceFlow_0do51t8</bpmn2:outgoing>
- </bpmn2:serviceTask>
- <bpmn2:sequenceFlow id="SequenceFlow_32" name="" sourceRef="ServiceTask_get_cloud_region" targetRef="ServiceTask_assign_network_sdnc" />
- <bpmn2:sequenceFlow id="SequenceFlow_0do51t8" sourceRef="ServiceTask_assign_network_sdnc" targetRef="ServiceTask_assign_network_aai" />
- <bpmn2:serviceTask id="ServiceTask_assign_network_aai" name="Assign Network (AAI)" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusAssignedNetwork(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn2:incoming>SequenceFlow_0do51t8</bpmn2:incoming>
- <bpmn2:outgoing>SequenceFlow_0ln3hj3</bpmn2:outgoing>
- </bpmn2:serviceTask>
- <bpmn2:endEvent id="AssignNetworkBB_end" name="End Flow">
- <bpmn2:incoming>SequenceFlow_0ln3hj3</bpmn2:incoming>
- </bpmn2:endEvent>
- <bpmn2:sequenceFlow id="SequenceFlow_0ln3hj3" sourceRef="ServiceTask_assign_network_aai" targetRef="AssignNetworkBB_end" />
- <bpmn2:sequenceFlow id="SequenceFlow_11op1ih" sourceRef="AssignNetworkBB_start" targetRef="ServiceTask_get_cloud_region" />
- <bpmn2:textAnnotation id="TextAnnotation_0dnksb2"> <bpmn2:text>sets Cloud Region on BB execution for SDNC assign</bpmn2:text>
-</bpmn2:textAnnotation>
- <bpmn2:association id="Association_1rsqd3z" sourceRef="ServiceTask_get_cloud_region" targetRef="TextAnnotation_0dnksb2" />
- </bpmn2:process>
- <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
- <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" />
- <bpmndi:BPMNDiagram id="BPMNDiagram_1">
- <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AssignNetwork1802BB">
- <bpmndi:BPMNShape id="_BPMNShape_StartEvent_47" bpmnElement="AssignNetworkBB_start">
- <dc:Bounds x="1167" y="246" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1160" y="287" width="49" height="12" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="ServiceTask_1wo7ke9_di" bpmnElement="ServiceTask_get_cloud_region">
- <dc:Bounds x="1298" y="224" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="ServiceTask_1ofnl0p_di" bpmnElement="ServiceTask_assign_network_sdnc">
- <dc:Bounds x="1449" y="229" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_53" bpmnElement="SequenceFlow_32">
- <di:waypoint xsi:type="dc:Point" x="1398" y="264" />
- <di:waypoint xsi:type="dc:Point" x="1446" y="264" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1422" y="249" width="0" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_0do51t8_di" bpmnElement="SequenceFlow_0do51t8">
- <di:waypoint xsi:type="dc:Point" x="1499" y="309" />
- <di:waypoint xsi:type="dc:Point" x="1499" y="378" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1514" y="343.5" width="0" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="TextAnnotation_0dnksb2_di" bpmnElement="TextAnnotation_0dnksb2">
- <dc:Bounds x="1393" y="153" width="212" height="30" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="Association_1rsqd3z_di" bpmnElement="Association_1rsqd3z">
- <di:waypoint xsi:type="dc:Point" x="1397" y="233" />
- <di:waypoint xsi:type="dc:Point" x="1475" y="183" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_18yks1p_di" bpmnElement="ServiceTask_assign_network_aai">
- <dc:Bounds x="1449" y="378" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="EndEvent_083u1a5_di" bpmnElement="AssignNetworkBB_end">
- <dc:Bounds x="1481" y="512" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1476" y="552" width="45" height="12" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0ln3hj3_di" bpmnElement="SequenceFlow_0ln3hj3">
- <di:waypoint xsi:type="dc:Point" x="1499" y="458" />
- <di:waypoint xsi:type="dc:Point" x="1499" y="512" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1514" y="475" width="0" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_11op1ih_di" bpmnElement="SequenceFlow_11op1ih">
- <di:waypoint xsi:type="dc:Point" x="1203" y="264" />
- <di:waypoint xsi:type="dc:Point" x="1298" y="264" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1205.5" y="249" width="90" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
-</bpmn2:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn
index 79cbe68a3a..57c342455d 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn
@@ -23,13 +23,13 @@
<bpmn2:incoming>SequenceFlow_0do51t8</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0ln3hj3</bpmn2:outgoing>
</bpmn2:serviceTask>
- <bpmn2:exclusiveGateway id="networkFoundByName_ExclusiveGateway" name="skip if network found by name or to be created by SDNC" default="SequenceFlow_0gkr871">
+ <bpmn2:exclusiveGateway id="networkFoundByName_ExclusiveGateway" name="skip if network found by name" default="SequenceFlow_0gkr871">
<bpmn2:incoming>SequenceFlow_11op1ih</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_017131q</bpmn2:outgoing>
<bpmn2:outgoing>SequenceFlow_0gkr871</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_017131q" name="Yes" sourceRef="networkFoundByName_ExclusiveGateway" targetRef="ServiceTask_get_cloud_region">
- <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{AssignNetwork.skipNetworkCreationInAAI(execution.getVariable("gBuildingBlockExecution")) == true}]]></bpmn2:conditionExpression>
+ <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{AssignNetwork.networkFoundByName(execution.getVariable("gBuildingBlockExecution")) == true}]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="SequenceFlow_0gkr871" name="No" sourceRef="networkFoundByName_ExclusiveGateway" targetRef="ServiceTask_put_network_in_AAI" />
<bpmn2:endEvent id="AssignNetworkBB_end" name="End Flow">
@@ -111,7 +111,7 @@
<bpmndi:BPMNShape id="ExclusiveGateway_19hvq7h_di" bpmnElement="networkFoundByName_ExclusiveGateway" isMarkerVisible="true">
<dc:Bounds x="838" y="-112" width="50" height="50" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="821" y="-176" width="83" height="24" />
+ <dc:Bounds x="833" y="-169" width="85" height="48" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_017131q_di" bpmnElement="SequenceFlow_017131q">
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn
deleted file mode 100644
index 212e735dd1..0000000000
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn
+++ /dev/null
@@ -1,80 +0,0 @@
-<?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.8.2">
- <bpmn:process id="UnassignNetwork1802BB" name="UnassignNetwork1802BB" isExecutable="true">
- <bpmn:startEvent id="Start_UnassignNetworkBB" name="start">
- <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing>
- </bpmn:startEvent>
- <bpmn:serviceTask id="Task_SNDCUnAssign" name="Call SDNC Adapter Topology UnAssign" camunda:expression="${SDNCUnassignTasks.unassignNetwork(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_0le4vrj</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1ks8kmt</bpmn:outgoing>
- </bpmn:serviceTask>
- <bpmn:endEvent id="End_UnassignNetworkBB" name="end">
- <bpmn:incoming>SequenceFlow_1ks8kmt</bpmn:incoming>
- </bpmn:endEvent>
- <bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_UnassignNetworkBB" targetRef="Task_VfModuleRelatioship" />
- <bpmn:sequenceFlow id="SequenceFlow_1ks8kmt" sourceRef="Task_SNDCUnAssign" targetRef="End_UnassignNetworkBB" />
- <bpmn:serviceTask id="Task_VfModuleRelatioship" name="Veriyf &#39;vf-module&#39; relationship exists" camunda:expression="${UnassignNetworkBB.checkRelationshipRelatedTo(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)), &#34;vf-module&#34;)}">
- <bpmn:incoming>SequenceFlow_0zaz9o2</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0mxe1a7</bpmn:outgoing>
- </bpmn:serviceTask>
- <bpmn:sequenceFlow id="SequenceFlow_0mxe1a7" sourceRef="Task_VfModuleRelatioship" targetRef="Task_GetCloudRegionVersion" />
- <bpmn:sequenceFlow id="SequenceFlow_0le4vrj" sourceRef="Task_GetCloudRegionVersion" targetRef="Task_SNDCUnAssign" />
- <bpmn:serviceTask id="Task_GetCloudRegionVersion" name="Get Sdnc Cloud Region Version" camunda:expression="${UnassignNetworkBB.getCloudSdncRegion(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_0mxe1a7</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0le4vrj</bpmn:outgoing>
- </bpmn:serviceTask>
- </bpmn:process>
- <bpmndi:BPMNDiagram id="BPMNDiagram_1">
- <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UnassignNetwork1802BB">
- <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_UnassignNetworkBB">
- <dc:Bounds x="288" y="119" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="295" y="155" width="22" height="12" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="ServiceTask_0m0ikey_di" bpmnElement="Task_SNDCUnAssign">
- <dc:Bounds x="665" y="97" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="EndEvent_1h93h9d_di" bpmnElement="End_UnassignNetworkBB">
- <dc:Bounds x="817" y="119" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="826" y="159" width="18" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0zaz9o2_di" bpmnElement="SequenceFlow_0zaz9o2">
- <di:waypoint xsi:type="dc:Point" x="324" y="137" />
- <di:waypoint xsi:type="dc:Point" x="375" y="137" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="304.5" y="122" width="90" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_1ks8kmt_di" bpmnElement="SequenceFlow_1ks8kmt">
- <di:waypoint xsi:type="dc:Point" x="765" y="137" />
- <di:waypoint xsi:type="dc:Point" x="817" y="137" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="791" y="122" width="0" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_194x6el_di" bpmnElement="Task_VfModuleRelatioship">
- <dc:Bounds x="375" y="97" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0mxe1a7_di" bpmnElement="SequenceFlow_0mxe1a7">
- <di:waypoint xsi:type="dc:Point" x="475" y="137" />
- <di:waypoint xsi:type="dc:Point" x="524" y="137" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="500" y="122" width="0" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_0le4vrj_di" bpmnElement="SequenceFlow_0le4vrj">
- <di:waypoint xsi:type="dc:Point" x="624" y="137" />
- <di:waypoint xsi:type="dc:Point" x="665" y="137" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="645" y="122" width="0" height="0" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_1ev9w69_di" bpmnElement="Task_GetCloudRegionVersion">
- <dc:Bounds x="524" y="97" width="100" height="80" />
- </bpmndi:BPMNShape>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
-</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignNetwork1802BBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignNetwork1802BBTest.java
deleted file mode 100644
index 14cac8343e..0000000000
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignNetwork1802BBTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 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.bpmn.infrastructure.bpmn.subprocess;
-
-import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doThrow;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.runtime.ProcessInstance;
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Test;
-import org.onap.so.bpmn.BaseBPMNTest;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-
-
-public class AssignNetwork1802BBTest extends BaseBPMNTest{
- @Test
- @Deployment(resources = { "subprocess/AssignNetworkRollbackBB.bpmn"})
- public void sunnyDayAssignNetwork_Test() throws InterruptedException {
-
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("AssignNetwork1802BB",variables);
- assertThat(pi).isNotNull();
- assertThat(pi).isStarted().hasPassedInOrder("AssignNetworkBB_start","ServiceTask_get_cloud_region","ServiceTask_assign_network_sdnc","ServiceTask_assign_network_aai","AssignNetworkBB_end");
- assertThat(pi).isEnded();
- }
-
- @Test
- public void rainyDayAssignNetwork_Test() throws Exception {
-
- doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusAssignedNetwork(any(BuildingBlockExecution.class));
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("AssignNetwork1802BB", variables);
- assertThat(pi).isNotNull();
- assertThat(pi).isStarted()
- .hasPassedInOrder("AssignNetworkBB_start", "ServiceTask_get_cloud_region", "ServiceTask_assign_network_sdnc", "ServiceTask_assign_network_aai")
- .hasNotPassed("AssignNetworkBB_end");
- assertThat(pi).isEnded();
- }
-}
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java
deleted file mode 100644
index 2c5381de09..0000000000
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 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.bpmn.infrastructure.bpmn.subprocess;
-
-import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doThrow;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.runtime.ProcessInstance;
-import org.junit.Test;
-import org.onap.so.bpmn.BaseBPMNTest;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-
-public class UnassignNetwork1802BBTest extends BaseBPMNTest {
- @Test
- public void sunnyDayAssignNetwork_Test() throws InterruptedException {
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignNetwork1802BB",variables);
- assertThat(pi).isNotNull();
- assertThat(pi).isStarted().hasPassedInOrder("Start_UnassignNetworkBB","Task_VfModuleRelatioship","Task_GetCloudRegionVersion","Task_SNDCUnAssign","End_UnassignNetworkBB");
- assertThat(pi).isEnded();
- }
-
- @Test
- public void rainyDayAssignNetwork_Test() throws Exception {
- doThrow(new BpmnError("7000", "TESTING ERRORS")).when(unassignNetworkBB).checkRelationshipRelatedTo(any(BuildingBlockExecution.class), eq("vf-module"));
- ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignNetwork1802BB", variables);
- assertThat(pi).isNotNull();
- assertThat(pi).isStarted()
- .hasPassedInOrder("Start_UnassignNetworkBB", "Task_VfModuleRelatioship")
- .hasNotPassed("End_UnassignNetworkBB");
- assertThat(pi).isEnded();
- }
-} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
index 06c65020f5..7c9e000a44 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
@@ -21,10 +21,8 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,30 +33,9 @@ public class AssignNetwork {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
AssignNetwork.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
+
@Autowired
private ExtractPojosForBB extractPojosForBB;
-
- /**
- * Check if there are collection(s)
- * @param execution
- * @return boolean
- */
- public boolean hasCollection(BuildingBlockExecution execution) {
- boolean hasCollection = false;
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID,
- execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
- if (serviceInstance.getCollection() != null){
- hasCollection = true;
- msoLogger.debug("there are collections to create");
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- return hasCollection;
- }
/**
* Check if network was found by name
@@ -80,14 +57,4 @@ public class AssignNetwork {
}
return networkFound;
}
-
- /**
- * BPMN access method. Return flag if BPMN flow should skip AAI interaction
- * @param execution
- * @return TRUE if network collection was NOT present OR network WAS found by name
- */
- public boolean skipNetworkCreationInAAI(BuildingBlockExecution execution) {
-
- return !hasCollection(execution) || networkFoundByName(execution);
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
index a206140014..6e5bd314d8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
@@ -25,7 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -36,80 +35,33 @@ public class AssignNetworkTest extends BaseTaskTest {
@Autowired
private AssignNetwork assignNetwork;
- private ServiceInstance serviceInstance;
private L3Network network;
@Before
public void before() {
- serviceInstance = setServiceInstance();
network = setL3Network();
}
@Test
- public void hasCollectionTest() throws Exception {
- setServiceInstance();
- //collection present by default base test setup
- boolean hasCollection = assignNetwork.hasCollection(execution);
- assertEquals(true, hasCollection);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(false, skip);
- }
-
- @Test
- public void hasNoCollectionTest() throws Exception {
- //clear collection
+ public void networkNotFoundTest() throws Exception {
+ //network status to PRECREATED - when it was NOT found by name
try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
- serviceInstance.setCollection(null);
- boolean hasCollection = assignNetwork.hasCollection(execution);
- assertEquals(false, hasCollection);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(true, skip);
- }
-
- @Test
- public void hasNoCollectionNoNetworkTest() throws Exception {
- //clear collection and updated network status to PRECREATED - when it was NOT found by name
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
} catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
}
- serviceInstance.setCollection(null);
+
network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- boolean hasCollection = assignNetwork.hasCollection(execution);
boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(false, hasCollection);
assertEquals(false, networkFound);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(true, skip);
}
@Test
- public void hasNetworkNoCollectionTest() throws Exception {
- //clear collection and updated network status to INVENTORIED - when it was found by name
+ public void networkFoundTest() throws Exception {
try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
} catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
}
- serviceInstance.setCollection(null);
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- boolean hasCollection = assignNetwork.hasCollection(execution);
boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(false, hasCollection);
assertEquals(true, networkFound);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(true, skip);
}
-
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index ac8446cbb9..8a3ce7f099 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -31,6 +31,9 @@ log:
vnfAdapterRestV1: 'true'
mso:
adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
completemsoprocess:
endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess
db:
diff --git a/cloudify-client/.gitignore b/cloudify-client/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/cloudify-client/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/common/.gitignore b/common/.gitignore
index a791146dad..c2a96233ca 100644
--- a/common/.gitignore
+++ b/common/.gitignore
@@ -1 +1,2 @@
/tattletale-jar/
+/bin/
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java
index 79fd7df7ce..0f4bbea03c 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -153,6 +153,10 @@ public abstract class RestClient {
}
return builder;
}
+
+ protected WebTarget getWebTarget() {
+ return this.webTarget;
+ }
protected abstract void initializeHeaderMap(Map<String, String> headerMap);
diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java
index 985d7cc885..4788acfa7c 100644
--- a/common/src/main/java/org/onap/so/client/RestRequest.java
+++ b/common/src/main/java/org/onap/so/client/RestRequest.java
@@ -73,7 +73,7 @@ public class RestRequest implements Callable<Response> {
mapper.get().map(response);
} catch (NotFoundException e) {
if (this.client.props.mapNotFoundToEmpty() && "GET".equals(method)) {
- msoLogger.error(e);
+ msoLogger.debug("RestClient recieved not found on URL: " + this.client.getWebTarget().getUri());
return response;
} else {
throw e;
diff --git a/deployment-configs/.gitignore b/deployment-configs/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/deployment-configs/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java
index e920db2fd2..8dba63b44b 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java
@@ -41,5 +41,7 @@ public enum Action {
assignInstance,
unassignInstance,
compareModel,
- scaleInstance
+ scaleInstance,
+ deactivateAndCloudDelete,
+ scaleOut
}
diff --git a/mso-api-handlers/mso-api-handler-infra/.gitignore b/mso-api-handlers/mso-api-handler-infra/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index 923909e39b..8f8cf0898d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -61,6 +61,7 @@ import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoAlarmLogger;
import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestDetails;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index 66afcf3738..1a1b45ac8e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -62,10 +62,10 @@ import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType;
import org.onap.so.apihandlerinfra.vnfbeans.VnfInputs;
import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.InstanceDirection;
import org.onap.so.serviceinstancebeans.ModelInfo;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 014739d581..753b4c48d4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -52,6 +52,7 @@ import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoAlarmLogger;
import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.InstanceReferences;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java
index 910b9f70cb..cfe32a3833 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java
@@ -40,7 +40,7 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.Constants;
-import org.onap.so.apihandlerinfra.RequestsDbClient;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.Status;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
@@ -51,7 +51,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestReferences;
import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantSyncResponse;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
index a14554c8a1..3b7a326f3e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
@@ -44,7 +44,7 @@ import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.Constants;
import org.onap.so.apihandlerinfra.Messages;
-import org.onap.so.apihandlerinfra.RequestsDbClient;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
index b35b669208..b13008b3d3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
@@ -30,7 +30,7 @@ import javax.ws.rs.core.MultivaluedMap;
import org.apache.commons.lang3.StringUtils;
import org.onap.so.apihandlerinfra.Constants;
-import org.onap.so.apihandlerinfra.RequestsDbClient;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.Status;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
index 461acab96d..2427dd2734 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
@@ -32,8 +32,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.process.CreateVnfOperationalE
import org.onap.so.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
-import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDBHelper;
@@ -46,7 +44,7 @@ import org.springframework.stereotype.Component;
@Scope("prototype")
public class TenantIsolationRunnable {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class);
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class);
@Autowired
private RequestsDBHelper requestDb;
@@ -60,10 +58,6 @@ public class TenantIsolationRunnable {
private DeactivateVnfOperationalEnvironment deactivateVnfOpEnv;
@Autowired
private ActivateVnfStatusOperationalEnvironment activateVnfStatusOpEnv;
- @Autowired
- private OperationalEnvDistributionStatusRepository distributionStatusRepository;
- @Autowired
- private OperationalEnvServiceModelStatusRepository modelStatusRepository;
@Async
public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException {
@@ -83,11 +77,11 @@ public class TenantIsolationRunnable {
throw validateException;
}
} else if(Action.activate.equals(action)) {
- activateVnfOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository);
+ activateVnfOpEnv.execute(requestId, cor);
} else if(Action.deactivate.equals(action)) {
deactivateVnfOpEnv.execute(requestId, cor);
} else if(Action.distributionStatus.equals(action)) {
- activateVnfStatusOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository);
+ activateVnfStatusOpEnv.execute(requestId, cor);
} else {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
ValidateException validateException = new ValidateException.Builder("Invalid Action specified: " + action,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
index 903639c8f5..e89b5c8d42 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -21,13 +21,13 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
import java.util.List;
-import java.util.Optional;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
@@ -40,8 +40,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
-import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
-import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDBHelper;
@@ -53,7 +51,7 @@ import org.springframework.stereotype.Component;
@Component
public class ActivateVnfOperationalEnvironment {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class);
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class);
private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3;
private static final String DISTRIBUTION_STATUS_SENT = "SENT";
@@ -69,16 +67,16 @@ public class ActivateVnfOperationalEnvironment {
@Value("${mso.tenant.isolation.retry.count}")
private String sdcRetryCount;
+ @Autowired
+ RequestsDbClient client;
+
/**
* The Point-Of-Entry from APIH with VID request to send activate request
* @param requestId - String
* @param request - CloudOrchestrationRequest object
- * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
- * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
* @return void - nothing
*/
- public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository,
- OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{
+ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{
String operationalEnvironmentId = request.getOperationalEnvironmentId();
String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
@@ -96,7 +94,7 @@ public class ActivateVnfOperationalEnvironment {
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
- processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, distributionStatusRepository, modelStatusRepository);
+ processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
}
@@ -107,13 +105,11 @@ public class ActivateVnfOperationalEnvironment {
* @param operationalEnvironmentId - String
* @param serviceModelVersionIdList - List<ServiceModelList> list
* @param workloadContext - String
- * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
- * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
* @return jsonResponse - JSONObject object
*/
- public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, List<ServiceModelList> serviceModelVersionIdList,
- String workloadContext, OperationalEnvDistributionStatusRepository distributionStatusRepository,
- OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+ public void processActivateSDCRequest(String requestId, String operationalEnvironmentId,
+ List<ServiceModelList> serviceModelVersionIdList,
+ String workloadContext) throws ApiException {
JSONObject jsonResponse = null;
int retryCount = 0;
@@ -137,7 +133,7 @@ public class ActivateVnfOperationalEnvironment {
recoveryAction,
retryCount,
workloadContext);
- modelStatusRepository.save(serviceModelStatus);
+ client.save(serviceModelStatus);
String distributionId = "";
@@ -154,7 +150,7 @@ public class ActivateVnfOperationalEnvironment {
requestId,
DISTRIBUTION_STATUS_SENT,
"");
- distributionStatusRepository.save(distStatus);
+ client.save(distStatus);
} else {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
index 6a9bec5abb..6eb5157568 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
@@ -28,6 +28,7 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
@@ -38,8 +39,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
-import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
-import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDBHelper;
@@ -72,17 +71,16 @@ public class ActivateVnfStatusOperationalEnvironment {
private RequestsDBHelper requestDb;
@Autowired
private SDCClientHelper sdcClientHelper;
+ @Autowired
+ private RequestsDbClient client;
/**
* The Point-Of-Entry from APIH with activate status from SDC
* @param requestId - String
* @param request - CloudOrchestrationRequest - object
- * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository - object
- * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository - object
* @return void - nothing
*/
- public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository,
- OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
String operationalEnvironmentId = "";
@@ -91,18 +89,18 @@ public class ActivateVnfStatusOperationalEnvironment {
Distribution sdcStatus = request.getDistribution();
// Distribution, Query for operationalEnvironmentId, serviceModelVersionId
- this.queryDistributionDbResponse = distributionStatusRepository.findOne(sdcDistributionId);
+ this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId);
operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId();
// ServiceModel, Query for dbRequestId, recoveryAction, retryCountString
- this.queryServiceModelResponse = modelStatusRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId());
+ this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId());
this.origRequestId = this.queryServiceModelResponse.getRequestId();
- processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse, distributionStatusRepository, modelStatusRepository);
+ processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse);
// After EVERY status processed, need to query the status of all service modelId
// to determine the OVERALL status if "COMPLETE" or "FAILURE":
- checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId, modelStatusRepository);
+ checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId);
}
@@ -112,13 +110,10 @@ public class ActivateVnfStatusOperationalEnvironment {
* @param sdcStatus - Distribution object
* @param queryDistributionDbResponse - OperationalEnvDistributionStatus object
* @param queryServiceModelResponse - OperationalEnvServiceModelStatus object
- * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
- * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
* @return void - nothing
*/
public void processActivateSDCStatus(String sdcDistributionId, Distribution sdcStatus, OperationalEnvDistributionStatus queryDistributionDbResponse,
- OperationalEnvServiceModelStatus queryServiceModelResponse, OperationalEnvDistributionStatusRepository distributionStatusRepository,
- OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+ OperationalEnvServiceModelStatus queryServiceModelResponse) throws ApiException {
String sdcStatusValue = sdcStatus.getStatus().toString();
String recoveryAction = queryServiceModelResponse.getRecoveryAction();
@@ -131,13 +126,13 @@ public class ActivateVnfStatusOperationalEnvironment {
dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse,
sdcStatusValue,
"");
- distributionStatusRepository.save(updateDistStatusOk);
+ client.save(updateDistStatusOk);
// should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!)
OperationalEnvServiceModelStatus updateRetryCountZeroAndStatusOk =
dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse,
sdcStatusValue,
RETRY_COUNT_ZERO);
- modelStatusRepository.save(updateRetryCountZeroAndStatusOk);
+ client.save(updateRetryCountZeroAndStatusOk);
} else {
// "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY"
@@ -145,8 +140,7 @@ public class ActivateVnfStatusOperationalEnvironment {
// RESEND / RETRY serviceModelVersionId to SDC
- JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus,
- distributionStatusRepository, modelStatusRepository);
+ JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus);
} else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP'
@@ -168,13 +162,13 @@ public class ActivateVnfStatusOperationalEnvironment {
dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse,
modifiedStatus,
RETRY_COUNT_ZERO);
- modelStatusRepository.save(updateRetryCountZeroAndStatus);
+ client.save(updateRetryCountZeroAndStatus);
// should update 1 row, modified status
OperationalEnvDistributionStatus updateDistStatus =
dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse,
modifiedStatus,
errorReason);
- distributionStatusRepository.save(updateDistStatus);
+ client.save(updateDistStatus);
} else {
// RETRY & Count = 0 (do nothing!)
}
@@ -187,15 +181,11 @@ public class ActivateVnfStatusOperationalEnvironment {
* @param queryDistributionDbResponse - OperationalEnvDistributionStatus object
* @param queryServiceModelResponse - OperationalEnvServiceModelStatus object
* @param sdcStatus - Distribution object
- * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
- * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
* @return JSONObject object
*/
public JSONObject callSDClientForRetry(OperationalEnvDistributionStatus queryDistributionDbResponse,
OperationalEnvServiceModelStatus queryServiceModelResponse,
- Distribution sdcStatus,
- OperationalEnvDistributionStatusRepository distributionStatusRepository,
- OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+ Distribution sdcStatus) throws ApiException {
JSONObject jsonResponse = null;
@@ -218,7 +208,7 @@ public class ActivateVnfStatusOperationalEnvironment {
originalRequestId,
DISTRIBUTION_STATUS_SENT,
"");
- distributionStatusRepository.save(insertNewDistributionId);
+ client.save(insertNewDistributionId);
// update retryCount (less 1) for the serviceModelServiceId
retryCount = retryCount - 1;
@@ -227,14 +217,14 @@ public class ActivateVnfStatusOperationalEnvironment {
dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse,
DISTRIBUTION_STATUS_SENT,
retryCount);
- modelStatusRepository.save(updateRetryCountAndStatus);
+ client.save(updateRetryCountAndStatus);
// should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!).
OperationalEnvDistributionStatus updateStatus =
dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse,
DISTRIBUTION_STATUS_ERROR,
sdcStatus.getErrorReason());
- distributionStatusRepository.save(updateStatus);
+ client.save(updateStatus);
} else {
String dbErrorMessage = "Failure calling SDC: statusCode: " + statusCode +
"; messageId: " + jsonResponse.get("messageId") +
@@ -255,12 +245,11 @@ public class ActivateVnfStatusOperationalEnvironment {
* The Method to check the overall status of the Activation for an operationalEnvironmentId
* @param operationalEnvironmentId - string
* @param origRequestId - string
- * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
* @return void - nothing
*/
- public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId, OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{
+ public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId) throws ApiException{
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = modelStatusRepository.findAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId);
+ List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = client.getAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId);
String status = "Waiting";
int count = 0;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java
index edd1b1a10e..8fdb43f20c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java
@@ -41,7 +41,7 @@ public class ConfigurationParametersValidation implements ValidationRule{
String requestScope = info.getRequestScope();
Actions action = info.getAction();
- if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && configParams.isEmpty()){
+ if(configParams.isEmpty() && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut){
throw new ValidationException("configuration parameters");
}
return info;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
index a63b778a1f..5932f6d206 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
@@ -187,7 +187,7 @@ private final ObjectMapper mapper = new ObjectMapper();
OperationStatus status = new OperationStatus();
status.setOperationId("operationId");
status.setServiceId("9b9f02c0-298b-458a-bc9c-be3692e4f35e");
- stubFor(get(urlPathEqualTo("/operationStatusRepository/search/findOneByServiceIdAndOperationId"))
+ stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(status))
.withStatus(HttpStatus.SC_OK)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index de7f560020..582bc12077 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -31,6 +31,7 @@ import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
index 3c991ef0c5..c36eb2b063 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
@@ -25,70 +25,81 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
-import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
-import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
-import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
-import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
-import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
-import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
- @Autowired
- private OperationalEnvDistributionStatusRepository distributionDbRepository;
- @Autowired
- private OperationalEnvServiceModelStatusRepository serviceModelDbRepository;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
@Autowired
private ActivateVnfOperationalEnvironment activateVnf;
@Autowired
- private InfraActiveRequestsRepository infraActiveRequestsRepository;
- @Autowired
private AAIClientHelper clientHelper;
- String requestId = "TEST_requestId";
- String operationalEnvironmentId = "EMOE-001";
- CloudOrchestrationRequest request = new CloudOrchestrationRequest();
- String workloadContext = "PVT";
+ private final String requestId = "TEST_requestId";
+ private final String operationalEnvironmentId = "1dfe7154-eae0-44f2-8e7a-8e5e7882e55d";
+ private final CloudOrchestrationRequest request = new CloudOrchestrationRequest();
+ private final String workloadContext = "PVT";
String recoveryActionRetry = "RETRY";
- String serviceModelVersionId = "TEST_serviceModelVersionId";
+ private final String serviceModelVersionId = "TEST_serviceModelVersionId";
int retryCount = 3;
- String sdcDistributionId = "TEST_distributionId";
- String statusSent = "SENT";
-
- @After
- public void after() throws Exception {
- distributionDbRepository.deleteAll();
- serviceModelDbRepository.deleteAll();
+ private final String sdcDistributionId = "TEST_distributionId";
+ private final String statusSent = "SENT";
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @Before
+ public void init(){
+ stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ .withRequestBody(equalTo("{\"requestId\":\"TEST_requestId\",\"operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":3,\"workloadContext\":\"PVT\",\"createTime\":null,\"modifyTime\":null}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestId\",\"distributionIdStatus\":\"SENT\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
}
+
@Test
- public void getAAIOperationalEnvironmentTest() throws Exception {
+ public void getAAIOperationalEnvironmentTest() {
- AAIOperationalEnvironment aaiOpEnv = null;
+ AAIOperationalEnvironment aaiOpEnv;
stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
@@ -104,7 +115,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
@Test
public void executionTest() throws Exception {
- List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
+ List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>();
ServiceModelList serviceModelList1 = new ServiceModelList();
serviceModelList1.setRecoveryAction(RecoveryAction.retry);
serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
@@ -130,22 +141,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
-
-
- activateVnf.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
-
- // insert record, status sent
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusSent, distStatus.getDistributionIdStatus());
-
- // insert record, status sent
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
-
+ activateVnf.execute(requestId, request);
}
@Test
@@ -159,7 +155,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
jsonObject.put("distributionId", distributionId);
// prepare request detail
- List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
+ List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>();
ServiceModelList serviceModelList1 = new ServiceModelList();
serviceModelList1.setRecoveryAction(RecoveryAction.retry);
serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
@@ -168,25 +164,11 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
- activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext,
- distributionDbRepository, serviceModelDbRepository);
-
- // insert record, status sent
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusSent, distStatus.getDistributionIdStatus());
-
- // insert record, status sent
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
-
+ activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
}
- @Test
- public void processActivateSDCRequestTest_409() throws Exception {
+ @Test
+ public void processActivateSDCRequestTest_409() throws ApiException, JsonProcessingException {
// ERROR in asdc
JSONObject jsonMessages = new JSONObject();
@@ -200,7 +182,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
jsonErrorResponse.put("requestError", jsonServException);
// prepare request detail
- List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
+ List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>();
ServiceModelList serviceModelList1 = new ServiceModelList();
serviceModelList1.setRecoveryAction(RecoveryAction.retry);
serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
@@ -209,30 +191,20 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestId);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
-
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_CONFLICT)));
-
- try {
- activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext,
- distributionDbRepository, serviceModelDbRepository);
-
- } catch (Exception ex) {
-
- // insert record, status sent
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
-
- }
-
- infraActiveRequestsRepository.delete(requestId);
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\""))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ thrown.expect(ValidateException.class);
+
+ activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
index 3dcac0da18..eba90496ba 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
@@ -21,22 +21,27 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
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.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
-import org.junit.After;
-import org.junit.Ignore;
import org.junit.Rule;
+import org.junit.After;
import org.junit.Test;
+import org.junit.Ignore;
import org.junit.rules.ExpectedException;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.BaseTest;
@@ -54,13 +59,12 @@ import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRe
import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
@Autowired
- private OperationalEnvDistributionStatusRepository distributionDbRepository;
- @Autowired
- private OperationalEnvServiceModelStatusRepository serviceModelDbRepository;
- @Autowired
private ActivateVnfStatusOperationalEnvironment activateVnfStatus;
@Autowired
private InfraActiveRequestsRepository infraActiveRequestsRepository;
@@ -69,30 +73,26 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
@Rule
public ExpectedException thrown = ExpectedException.none();
- private String requestId = "TEST_requestId";
- private String requestIdOrig = "TEST_requestIdOrig";
- private String operationalEnvironmentId = "TEST_operationalEnvironmentId";
- private CloudOrchestrationRequest request = new CloudOrchestrationRequest();
- private String workloadContext = "TEST_workloadContext";
- private String recoveryActionRetry = "RETRY";
- private String recoveryActionAbort = "ABORT";
- private String recoveryActionSkip = "SKIP";
- private String serviceModelVersionId = "TEST_serviceModelVersionId";
- private String serviceModelVersionId1 = "TEST_serviceModelVersionId1";
- private int retryCountThree = 3;
- private int retryCountTwo = 2;
- private int retryCountZero = 0;
- private String sdcDistributionId = "TEST_distributionId";
- private String sdcDistributionId1 = "TEST_distributionId1";
- private String statusOk = Status.DISTRIBUTION_COMPLETE_OK.toString();
- private String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
- private String statusSent = "SENT";
-
- @After
- public void after() throws Exception {
- distributionDbRepository.deleteAll();
- serviceModelDbRepository.deleteAll();
- }
+ private final String requestId = "TEST_requestId";
+ private final String requestIdOrig = "TEST_requestIdOrig";
+ private final String operationalEnvironmentId = "TEST_operationalEnvironmentId";
+ private final CloudOrchestrationRequest request = new CloudOrchestrationRequest();
+ private final String workloadContext = "TEST_workloadContext";
+ private final String recoveryActionRetry = "RETRY";
+ private final String recoveryActionAbort = "ABORT";
+ private final String recoveryActionSkip = "SKIP";
+ private final String serviceModelVersionId = "TEST_serviceModelVersionId";
+ private final String serviceModelVersionId1 = "TEST_serviceModelVersionId1";
+ private final int retryCountThree = 3;
+ private final int retryCountTwo = 2;
+ private final int retryCountZero = 0;
+ private final String sdcDistributionId = "TEST_distributionId";
+ private final String sdcDistributionId1 = "TEST_distributionId1";
+ private final String statusOk = Status.DISTRIBUTION_COMPLETE_OK.toString();
+ private final String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
+ private final String statusSent = "SENT";
+
+ private final ObjectMapper mapper = new ObjectMapper();
@Test
public void checkOrUpdateOverallStatusTest_Ok() throws Exception {
@@ -106,7 +106,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountZero);
serviceModelDb.setServiceModelVersionDistrStatus(statusOk);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
serviceModelDb.setRequestId(requestIdOrig);
serviceModelDb.setServiceModelVersionId(serviceModelVersionId1);
@@ -115,27 +114,27 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountZero);
serviceModelDb.setServiceModelVersionDistrStatus(statusOk);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
-
+
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
+
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
- activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository);
+ activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig);
// overall is success
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
}
@Test
- public void checkOrUpdateOverallStatusTest_Error() throws Exception {
+ public void checkOrUpdateOverallStatusTest_Error() throws JsonProcessingException {
OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
serviceModelDb.setRequestId(requestIdOrig);
@@ -145,29 +144,28 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountZero);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
+
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
try {
- activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository);
+ activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig);
}catch(ApiException e){
assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
}
- // overall is failure
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
}
@Test
@@ -181,9 +179,12 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountTwo);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
- activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository);
+ activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig);
// do nothing, waiting for more
assertNull(infraActiveRequestsRepository.findOne(requestIdOrig));
@@ -200,7 +201,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusSent);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
distributionDb.setDistributionId(sdcDistributionId);
@@ -209,9 +209,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
distributionDb.setDistributionIdStatus(statusSent);
distributionDb.setServiceModelVersionId(serviceModelVersionId);
distributionDb.setDistributionIdErrorReason(null);
- distributionDbRepository.saveAndFlush(distributionDb);
-
-
// prepare distribution obj
Distribution distribution = new Distribution();
@@ -223,32 +220,30 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
-
- activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
-
- // status ok
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusOk, distStatus.getDistributionIdStatus());
- assertEquals("", distStatus.getDistributionIdErrorReason());
-
- // status ok
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
- assertEquals(statusOk, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(new Integer(retryCountZero), servStatus.getRetryCount());
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(distributionDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"RETRY\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ activateVnfStatus.execute(requestId, request);
}
@Test
@@ -262,7 +257,10 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
distributionDb.setDistributionId(sdcDistributionId);
@@ -271,7 +269,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
distributionDb.setDistributionIdStatus(statusError);
distributionDb.setServiceModelVersionId(serviceModelVersionId);
distributionDb.setDistributionIdErrorReason(null);
- distributionDbRepository.saveAndFlush(distributionDb);
+
@@ -291,37 +289,34 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(distributionDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\",\"distributionIdErrorReason\":\"Unable to process.\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId1\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"SENT\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
- activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
-
- // old distributionId, status error
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusError, distStatus.getDistributionIdStatus());
- assertEquals("Unable to process.", distStatus.getDistributionIdErrorReason());
-
- // new distributionId, status sent
- OperationalEnvDistributionStatus newDistStatus = distributionDbRepository.findOne(sdcDistributionId1);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, newDistStatus.getOperationalEnvId());
- assertEquals(statusSent, newDistStatus.getDistributionIdStatus());
- assertEquals("", newDistStatus.getDistributionIdErrorReason());
-
- // count is less 1, status sent
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
- assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(new Integer(retryCountTwo), servStatus.getRetryCount());
-
- // no update
- assertNull(infraActiveRequestsRepository.findOne(requestIdOrig));
-
+ activateVnfStatus.execute(requestId, request);
}
@Test
- public void executionTest_ERROR_Status_And_RETRY_And_RetryZero() throws Exception {
+ public void executionTest_ERROR_Status_And_RETRY_And_RetryZero() throws JsonProcessingException {
OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
serviceModelDb.setRequestId(requestIdOrig);
@@ -331,7 +326,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountZero);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
distributionDb.setDistributionId(sdcDistributionId);
@@ -340,7 +334,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
distributionDb.setDistributionIdStatus(statusError);
distributionDb.setServiceModelVersionId(serviceModelVersionId);
distributionDb.setDistributionIdErrorReason(null);
- distributionDbRepository.saveAndFlush(distributionDb);
@@ -359,44 +352,41 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
+
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(distributionDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
try {
- activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+ activateVnfStatus.execute(requestId, request);
}catch(ApiException e){
assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
}
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusError, distStatus.getDistributionIdStatus());
- assertEquals(null, distStatus.getDistributionIdErrorReason());
-
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
- assertEquals(statusError, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(new Integer(retryCountZero), servStatus.getRetryCount());
-
- // Retry count is zero, no more retry. all retry failed.
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
}
@Test
- public void executionTest_ERROR_Status_And_RETRY_And_ErrorSdc() throws Exception {
+ public void executionTest_ERROR_Status_And_RETRY_And_ErrorSdc() throws JsonProcessingException {
OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
serviceModelDb.setRequestId(requestIdOrig);
@@ -406,7 +396,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
distributionDb.setDistributionId(sdcDistributionId);
@@ -415,7 +404,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
distributionDb.setDistributionIdStatus(statusError);
distributionDb.setServiceModelVersionId(serviceModelVersionId);
distributionDb.setDistributionIdErrorReason(null);
- distributionDbRepository.saveAndFlush(distributionDb);
@@ -441,41 +429,33 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(distributionDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("operationalEnvId\":\"TEST_operationalEnvironmentId\""))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonMessages.toString()).withStatus(HttpStatus.SC_CONFLICT)));
try {
- activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+ activateVnfStatus.execute(requestId, request);
}catch(ApiException e){
assertThat(e.getMessage(), startsWith("Failure calling SDC: statusCode: "));
assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
}
- // status as-is / no changes
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusError, distStatus.getDistributionIdStatus());
- assertEquals(null, distStatus.getDistributionIdErrorReason());
-
- // status as-is / no changes
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
- assertEquals(statusError, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(new Integer(retryCountThree), servStatus.getRetryCount());
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
- assertTrue(infraActiveRequest.getStatusMessage().contains("Undefined Error Message!"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
-
}
@Test
@@ -489,8 +469,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
-
+
OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
distributionDb.setDistributionId(sdcDistributionId);
distributionDb.setRequestId(requestIdOrig);
@@ -498,36 +477,48 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
distributionDb.setDistributionIdStatus(statusError);
distributionDb.setServiceModelVersionId(serviceModelVersionId);
distributionDb.setDistributionIdErrorReason(null);
- distributionDbRepository.saveAndFlush(distributionDb);
-
-
// prepare distribution obj
+ OperationalEnvDistributionStatus distributionStatus = new OperationalEnvDistributionStatus(sdcDistributionId,operationalEnvironmentId,serviceModelVersionId);
+ distributionStatus.setDistributionIdStatus(Status.DISTRIBUTION_COMPLETE_ERROR.name());
+
Distribution distribution = new Distribution();
distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
request.setDistribution(distribution);
request.setDistributionId(sdcDistributionId);
request.setOperationalEnvironmentId(operationalEnvironmentId);
-
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
- activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(distributionDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"SKIP\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ activateVnfStatus.execute(requestId, request);
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
-
}
@Test
- public void executionTest_ERROR_Status_And_ABORT() throws Exception {
+ public void executionTest_ERROR_Status_And_ABORT() throws JsonProcessingException {
OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
serviceModelDb.setRequestId(requestIdOrig);
@@ -537,7 +528,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- serviceModelDbRepository.saveAndFlush(serviceModelDb);
OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
distributionDb.setDistributionId(sdcDistributionId);
@@ -546,7 +536,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
distributionDb.setDistributionIdStatus(statusError);
distributionDb.setServiceModelVersionId(serviceModelVersionId);
distributionDb.setDistributionIdErrorReason(null);
- distributionDbRepository.saveAndFlush(distributionDb);
@@ -560,23 +549,36 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- infraActiveRequestsRepository.saveAndFlush(iar);
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceModelDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(distributionDb))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ .withRequestBody(containing("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\""))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ .withRequestBody(containing("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_ERROR\""))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
try {
- activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
- }catch(ApiException e){
- assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
- assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
- assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
- }
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
- assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
-
- // cleanup
- infraActiveRequestsRepository.delete(requestIdOrig);
+ activateVnfStatus.execute(requestId, request);
+ }catch(ApiException e) {
+ assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
+ assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
+ assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ }
}
@@ -617,24 +619,11 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
- JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution,
- distributionDbRepository, serviceModelDbRepository);
+ JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution);
assertEquals("TEST_distributionId1", jsonResponse.get("distributionId"));
assertEquals("Success", jsonResponse.get("message"));
assertEquals("202", jsonResponse.get("statusCode"));
- // insert new record, status sent
- OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId1);
- assertNotNull(distStatus);
- assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
- assertEquals(statusSent, distStatus.getDistributionIdStatus());
-
- // insert new record, status sent
- OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
- assertNotNull(servStatus);
- assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
- assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
-
- }
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
index d64cf6106a..0ace9d5445 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
@@ -20,16 +20,12 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
-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.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.apihandler.common.ErrorNumbers;
@@ -44,19 +40,20 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
public class CreateEcompOperationalEnvironmentTest extends BaseTest{
@Autowired
private CreateEcompOperationalEnvironment createEcompOpEn;
- @Autowired
- private InfraActiveRequestsRepository infraActiveRequestsRepository;
-
+ private final ObjectMapper mapper = new ObjectMapper();
+
public CloudOrchestrationRequest getCloudOrchestrationRequest() {
CloudOrchestrationRequest request = new CloudOrchestrationRequest();
RequestDetails reqDetails = new RequestDetails();
@@ -75,7 +72,7 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
}
@Test
- public void testProcess() throws ApiException {
+ public void testProcess() throws ApiException, JsonProcessingException {
stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
stubFor(post(urlPathMatching("/events/.*"))
@@ -87,18 +84,20 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- infraActiveRequestsRepository.saveAndFlush(iar);
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/123"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("{\"requestId\":\"123\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL, operationalEnvironmentId - operationalEnvId; Success Message: SUCCESSFULLY Created ECOMP OperationalEnvironment.\",\"progress\":100"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
createEcompOpEn.execute("123", getCloudOrchestrationRequest());
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOneByRequestId("123");
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS"));
- assertTrue(infraActiveRequest.getRequestStatus().equals("COMPLETE"));
}
@Test
- public void testProcessException() {
+ public void testProcessException() throws JsonProcessingException {
stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
stubFor(post(urlPathMatching("/events/.*"))
@@ -113,18 +112,20 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- infraActiveRequestsRepository.saveAndFlush(iar);
-
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/123"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("{\"requestId\":\"123\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE, operationalEnvironmentId - operationalEnvId; Error message: empty"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
try {
createEcompOpEn.execute("123", getCloudOrchestrationRequest());
}catch(ApiException e){
assertThat(e, sameBeanAs((ApiException) expectedException).ignoring("cause"));
}
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOneByRequestId("123");
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
- assertTrue(infraActiveRequest.getRequestStatus().equals("FAILED"));
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
index 8fe40f31a4..1dfafce40c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
@@ -20,21 +20,15 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
-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.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import java.util.UUID;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
@@ -51,6 +45,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
public class CreateVnfOperationalEnvironmentTest extends BaseTest{
@@ -59,9 +56,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
@Autowired
private CreateVnfOperationalEnvironment createVnfOpEnv;
- @Autowired
- private InfraActiveRequestsRepository infraActiveRequestsRepository;
-
+
@Before
public void testSetUp() throws Exception {
ObjectMapper mapper = new ObjectMapper();
@@ -70,7 +65,6 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
String jsonServiceEndpoints = getFileContentsAsString("__files/vnfoperenv/endpoints.json");
serviceEndpoints = mapper.readValue(jsonServiceEndpoints, ServiceEndPointList.class);
}
-
@Test
public void testGetEcompManagingEnvironmentId() throws Exception {
createVnfOpEnv.setRequest(request);
@@ -84,7 +78,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
}
@Test
- public void testGetEnvironmentName() throws Exception {
+ public void testGetEnvironmentName() {
createVnfOpEnv.setRequest(request);
List<Property> props = serviceEndpoints.getServiceEndPointList().get(0).getProperties();
assertEquals("DEV", createVnfOpEnv.getEnvironmentName(props));
@@ -120,7 +114,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
}
@Test
- public void testExecute() throws ApiException{
+ public void testExecute() throws ApiException, JsonProcessingException {
stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning"))
@@ -136,11 +130,16 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- infraActiveRequestsRepository.saveAndFlush(iar);
+ ObjectMapper mapper = new ObjectMapper();
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
createVnfOpEnv.execute(requestId, request);
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS"));
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
index a9be10c3f4..5b0e1f6bfd 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
@@ -20,19 +20,14 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
-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.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpStatus;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -45,6 +40,9 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.springframework.beans.factory.annotation.Autowired;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
@Rule
@@ -52,13 +50,20 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
@Autowired
private DeactivateVnfOperationalEnvironment deactivate;
- @Autowired
- private InfraActiveRequestsRepository infraActiveRequestsRepository;
-
+
private CloudOrchestrationRequest request = new CloudOrchestrationRequest();
private String operationalEnvironmentId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
private String requestId = "ff3514e3-5a33-55df-13ab-12abad84e7fe";
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Before
+ public void init(){
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
@Test
public void testDeactivateOperationalEnvironment() throws Exception {
request.setOperationalEnvironmentId(operationalEnvironmentId);
@@ -79,14 +84,11 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- infraActiveRequestsRepository.saveAndFlush(iar);
-
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
deactivate.execute(requestId, request);
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
-
}
@Test
@@ -110,8 +112,15 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- infraActiveRequestsRepository.saveAndFlush(iar);
-
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ .withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+
deactivate.execute(requestId, request);
}
@@ -131,13 +140,12 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- infraActiveRequestsRepository.saveAndFlush(iar);
+ stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(iar))
+ .withStatus(HttpStatus.SC_OK)));
deactivate.execute(requestId, request);
-
- InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
- assertNotNull(infraActiveRequest);
- assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS"));
}
@Test
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java
index f3e92ed16a..603f9bb494 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java
@@ -22,9 +22,10 @@ package org.onap.so.db.request.data.repository;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "archivedInfraRequests", path = "archivedInfraRequests")
public interface ArchivedInfraRequestsRepository extends JpaRepository<ArchivedInfraRequests, String> {
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java
index 22a1604bdd..16e10e3d5b 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java
@@ -26,7 +26,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-@RepositoryRestResource(collectionResourceRel = "operationStatusRepository", path = "operationStatusRepository")
+@RepositoryRestResource(collectionResourceRel = "operationStatus", path = "operationStatus")
public interface OperationStatusRepository extends JpaRepository<OperationStatus, OperationStatusId> {
OperationStatus findOneByServiceIdAndOperationId(@Param("SERVICE_ID") String serviceId, @Param("OPERATION_ID") String operationId);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java
index 799e5ad147..e89755d565 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java
@@ -25,10 +25,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.transaction.annotation.Transactional;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "operationalEnvDistributionStatus", path = "operationalEnvDistributionStatus")
public interface OperationalEnvDistributionStatusRepository extends JpaRepository<OperationalEnvDistributionStatus, String> {
@Modifying
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java
index ee2baedf61..bcad9ce6d5 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java
@@ -28,32 +28,16 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.transaction.annotation.Transactional;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "operationalEnvServiceModelStatus", path = "operationalEnvServiceModelStatus")
public interface OperationalEnvServiceModelStatusRepository extends JpaRepository<OperationalEnvServiceModelStatus, OperationalEnvServiceModelStatusId>{
public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndRequestId(String operationalEnvId, String requestId);
- public List<OperationalEnvServiceModelStatus> findAllByOperationalEnvIdAndRequestId(String operationalEnvId, String requestId);
- public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(String operationalEnvId, String serviceModelVersionId);
+ public List<OperationalEnvServiceModelStatus> findAllByOperationalEnvIdAndRequestId(@Param("OPERATIONAL_ENV_ID") String operationalEnvId,
+ @Param("REQUEST_ID") String requestId);
+ public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(@Param("OPERATIONAL_ENV_ID") String operationalEnvId,
+ @Param("SERVICE_MODEL_VERSION_ID") String serviceModelVersionId);
- @Modifying
- @Transactional
- @Query("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :asdcStatus, retryCount = :retryCount where "
- + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId")
- public int setServiceModelVersionDistrStatusAndRetryCountFor(@Param("asdcStatus") String serviceModelVersionDistrStatus,
- @Param("retryCount") int retryCount,
- @Param("operationalEnvId") String operationalEnvId,
- @Param("serviceModelVersionId") String serviceModelVersionId);
-
- @Modifying
- @Transactional
- @Query("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :asdcStatus, retryCount = :retryCount where "
- + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId and requestId = :requestId")
- public int setServiceModelVersionDistrStatusAndRetryCountFor(@Param("asdcStatus") String serviceModelVersionDistrStatus,
- @Param("retryCount") int retryCount,
- @Param("operationalEnvId") String operationalEnvId,
- @Param("serviceModelVersionId") String serviceModelVersionId,
- @Param("requestId") String requestId);
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java
index 2d77f7589e..b93bf7840b 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java
@@ -25,9 +25,10 @@ import java.util.List;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import org.onap.so.db.request.beans.ResourceOperationStatusId;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "resourceOperationStatus", path = "resourceOperationStatus")
public interface ResourceOperationStatusRepository extends JpaRepository<ResourceOperationStatus, ResourceOperationStatusId> {
List<ResourceOperationStatus> findByServiceIdAndOperationId(String serviceId, String operationId);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java
index 11923512a5..179d40ad23 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java
@@ -22,9 +22,10 @@ package org.onap.so.db.request.data.repository;
import org.onap.so.db.request.beans.SiteStatus;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "siteStatus", path = "siteStatus")
public interface SiteStatusRepository extends JpaRepository<SiteStatus, String> {
SiteStatus findOneBySiteName(String siteName);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java
index 8310d79a5b..138ec0fb4d 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java
@@ -25,9 +25,10 @@ import java.util.List;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatusId;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "watchdogComponentDistributionStatus", path = "watchdogComponentDistributionStatus")
public interface WatchdogComponentDistributionStatusRepository extends JpaRepository<WatchdogComponentDistributionStatus, WatchdogComponentDistributionStatusId> {
public List<WatchdogComponentDistributionStatus> findByDistributionId(String distributionId);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java
index 6e37181380..fde8485e6d 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java
@@ -22,9 +22,10 @@ package org.onap.so.db.request.data.repository;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "watchdogDistributionStatus", path = "watchdogDistributionStatus")
public interface WatchdogDistributionStatusRepository extends JpaRepository<WatchdogDistributionStatus, String> {
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java
index b83481b88b..b9585d495e 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java
@@ -23,9 +23,10 @@ package org.onap.so.db.request.data.repository;
import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookupId;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
-@Repository
+@RepositoryRestResource(collectionResourceRel = "watchdogServiceModVerIdLookup", path = "watchdogServiceModVerIdLookup")
public interface WatchdogServiceModVerIdLookupRepository extends JpaRepository<WatchdogServiceModVerIdLookup, WatchdogServiceModVerIdLookupId> {
public WatchdogServiceModVerIdLookup findOneByDistributionId(String distributionId);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java
index 6eb00ea1e9..562e54ca6e 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java
@@ -23,8 +23,8 @@ package org.onap.so.requestsdb;
import java.sql.Timestamp;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.client.RequestsDbClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -37,7 +37,7 @@ public class RequestsDBHelper {
private String methodName = "";
private String classMethodMessage = "";
@Autowired
- private InfraActiveRequestsRepository infraActiveRequestsRepository;
+ private RequestsDbClient requestsDbClient;
/**
* This util method is to update the InfraRequest table to Complete
* @param msg - string, unique message for each caller
@@ -51,7 +51,7 @@ public class RequestsDBHelper {
classMethodMessage = className + " " + methodName;
msoLogger.debug("Begin of " + classMethodMessage);
- InfraActiveRequests request = infraActiveRequestsRepository.findOneByRequestId(requestId);
+ InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
request.setRequestStatus("COMPLETE");
request.setStatusMessage("SUCCESSFUL, operationalEnvironmentId - " + operationalEnvironmentId + "; Success Message: " + msg);
@@ -66,7 +66,7 @@ public class RequestsDBHelper {
}
Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
request.setEndTime(endTimeStamp);
- infraActiveRequestsRepository.save(request);
+ requestsDbClient.save(request);
msoLogger.debug("End of " + classMethodMessage);
@@ -85,7 +85,7 @@ public class RequestsDBHelper {
classMethodMessage = className + " " + methodName;
msoLogger.debug("Begin of " + classMethodMessage);
- InfraActiveRequests request = infraActiveRequestsRepository.findOneByRequestId(requestId);
+ InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
request.setRequestStatus("FAILED");
request.setStatusMessage("FAILURE, operationalEnvironmentId - " + operationalEnvironmentId + "; Error message: " + msg);
request.setProgress(100L);
@@ -99,7 +99,7 @@ public class RequestsDBHelper {
}
Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
request.setEndTime(endTimeStamp);
- infraActiveRequestsRepository.save(request);
+ requestsDbClient.save(request);
msoLogger.debug("End of " + classMethodMessage);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/client/RequestsDbClient.java
index 380ee2c6ad..8e291aa15b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/client/RequestsDbClient.java
@@ -18,11 +18,19 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.apihandlerinfra;
+package org.onap.so.requestsdb.client;
import org.apache.http.HttpStatus;
import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
+import org.onap.so.db.request.beans.ArchivedInfraRequests;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
+import org.onap.so.db.request.beans.WatchdogDistributionStatus;
+import org.onap.so.db.request.beans.SiteStatus;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -42,18 +50,25 @@ import uk.co.blackpepper.bowman.Configuration;
import javax.annotation.PostConstruct;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
-@Component("RequestDbClient")
+@Component
public class RequestsDbClient {
private static final String SERVICE_ID = "SERVICE_ID";
private static final String OPERATION_ID = "OPERATION_ID";
-
- private Client<InfraActiveRequests> infraActiveRequestClient;
- private Client<OperationStatus> operationStatusClient;
+ private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENVIRONMENT_ID";
+ private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID";
+ private static final String REQUEST_ID = "REQUEST_ID";
+
+ private final Client<InfraActiveRequests> infraActiveRequestClient;
+ private final Client<OperationStatus> operationStatusClient;
+ private final Client<OperationalEnvDistributionStatus> distributionStatusClient;
+ private final Client<OperationalEnvServiceModelStatus> serviceModelStatusClient;
@Value("${mso.adapters.requestDb.endpoint}")
private String endpoint;
@@ -62,7 +77,8 @@ public class RequestsDbClient {
private String msoAdaptersAuth;
private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/";
- private static final String OPERATION_STATUS_REPOSITORY_SEARCH = "/operationStatusRepository/search";
+ private static final String OPERATION_STATUS_SEARCH = "/operationStatus/search";
+ private static final String OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH = "/operationalEnvServiceModelStatus/search";
private String checkVnfIdStatus = "/infraActiveRequests/checkVnfIdStatus/";
@@ -71,13 +87,22 @@ public class RequestsDbClient {
private String checkInstanceNameDuplicate = "/infraActiveRequests/checkInstanceNameDuplicate";
private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId";
+
+ private String operationalEnvDistributionStatusURI = "/operationalEnvDistributionStatus/";
private String cloudOrchestrationFiltersFromInfraActive = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive";
+ private String findOneByOperationalEnvIdAndServiceModelVersionIdURI = "/findOneByOperationalEnvIdAndServiceModelVersionId";
+
+ private String findAllByOperationalEnvIdAndRequestIdURI = "/findAllByOperationalEnvIdAndRequestId";
+
private HttpHeaders headers;
@Autowired
private RestTemplate restTemplate;
+ @Autowired
+ ClassURLMapper classURLMapper;
+
@PostConstruct
public void init() {
@@ -86,7 +111,10 @@ public class RequestsDbClient {
checkVnfIdStatus = endpoint + checkVnfIdStatus;
checkInstanceNameDuplicate = endpoint + checkInstanceNameDuplicate;
cloudOrchestrationFiltersFromInfraActive = endpoint + cloudOrchestrationFiltersFromInfraActive;
- findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_REPOSITORY_SEARCH + findOneByServiceIdAndOperationIdURI;
+ findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_SEARCH + findOneByServiceIdAndOperationIdURI;
+ operationalEnvDistributionStatusURI = endpoint + operationalEnvDistributionStatusURI;
+ findOneByOperationalEnvIdAndServiceModelVersionIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findOneByOperationalEnvIdAndServiceModelVersionIdURI;
+ findAllByOperationalEnvIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findAllByOperationalEnvIdAndRequestIdURI;
headers = new HttpHeaders();
headers.set("Authorization", msoAdaptersAuth);
}
@@ -98,7 +126,8 @@ public class RequestsDbClient {
})).build().buildClientFactory();
infraActiveRequestClient = clientFactory.create(InfraActiveRequests.class);
operationStatusClient = clientFactory.create(OperationStatus.class);
-
+ distributionStatusClient = clientFactory.create(OperationalEnvDistributionStatus.class);
+ serviceModelStatusClient = clientFactory.create(OperationalEnvServiceModelStatus.class);
}
public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap){
URI uri = getUri(cloudOrchestrationFiltersFromInfraActive);
@@ -147,13 +176,53 @@ public class RequestsDbClient {
.build());
}
+ public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(String operationalEnvironmentId, String serviceModelVersionId) {
+ return this.getSingleOperationalEnvServiceModelStatus(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdURI)
+ .queryParam(OPERATIONAL_ENVIRONMENT_ID,operationalEnvironmentId)
+ .queryParam(SERVICE_MODEL_VERSION_ID,serviceModelVersionId)
+ .build());
+ }
+
+ public List<OperationalEnvServiceModelStatus> getAllByOperationalEnvIdAndRequestId(String operationalEnvironmentId, String requestId){
+ return this.getMultipleOperationalEnvServiceModelStatus(UriBuilder.fromUri(findAllByOperationalEnvIdAndRequestIdURI)
+ .queryParam(OPERATIONAL_ENVIRONMENT_ID,operationalEnvironmentId)
+ .queryParam(REQUEST_ID,requestId)
+ .build());
+ }
+
+ public OperationalEnvDistributionStatus getDistributionStatusById(String distributionId){
+ return this.getSingleOperationalEnvDistributionStatus(UriBuilder.fromUri(operationalEnvDistributionStatusURI+distributionId).build());
+ }
+
+ private OperationalEnvServiceModelStatus getSingleOperationalEnvServiceModelStatus(URI uri){
+ return serviceModelStatusClient.get(uri);
+ }
+
+ private List<OperationalEnvServiceModelStatus> getMultipleOperationalEnvServiceModelStatus(URI uri){
+ Iterable <OperationalEnvServiceModelStatus> iterable = serviceModelStatusClient.getAll(uri);
+ List<OperationalEnvServiceModelStatus> serviceModelStatuses = new ArrayList<>();
+ Iterator<OperationalEnvServiceModelStatus> statusIterator = iterable.iterator();
+ statusIterator.forEachRemaining(serviceModelStatuses::add);
+ return serviceModelStatuses;
+ }
+
public void save(InfraActiveRequests infraActiveRequests) {
URI uri = getUri(infraActiveRequestURI);
HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(infraActiveRequests, headers);
restTemplate.postForLocation(uri, entity);
}
+
+ public <T> void save(T object){
+ URI uri = getUri(endpoint+classURLMapper.getURI(object.getClass()));
+ HttpEntity<T> entity = new HttpEntity<>(object, headers);
+ restTemplate.postForLocation(uri, entity);
+ }
+
+ private OperationalEnvDistributionStatus getSingleOperationalEnvDistributionStatus(URI uri){
+ return distributionStatusClient.get(uri);
+ }
- protected InfraActiveRequests getSingleInfraActiveRequests(URI uri) {
+ private InfraActiveRequests getSingleInfraActiveRequests(URI uri) {
return infraActiveRequestClient.get(uri);
}
@@ -161,11 +230,11 @@ public class RequestsDbClient {
infraActiveRequestClient.put(request);
}
- public OperationStatus getSingleOperationStatus(URI uri){
+ private OperationStatus getSingleOperationStatus(URI uri){
return operationStatusClient.get(uri);
}
- protected URI getUri(String uri) {
+ private URI getUri(String uri) {
return URI.create(uri);
}
@@ -173,4 +242,31 @@ public class RequestsDbClient {
public RestTemplate restTemplate() {
return new RestTemplate( new HttpComponentsClientHttpRequestFactory());
}
+
+ @Component
+ static class ClassURLMapper {
+ private static final Map <Class,String> classURLMap = new HashMap<>();
+
+ ClassURLMapper() {
+ classURLMap.put(ArchivedInfraRequests.class,"/archivedInfraRequests/");
+ classURLMap.put(InfraActiveRequests.class,"/infraActiveRequests/");
+ classURLMap.put(OperationalEnvDistributionStatus.class,"/operationalEnvDistributionStatus/");
+ classURLMap.put(OperationalEnvServiceModelStatus.class,"/operationalEnvServiceModelStatus/");
+ classURLMap.put(OperationStatus.class,"/operationStatus/");
+ classURLMap.put(ResourceOperationStatus.class,"/resourceOperationStatus/");
+ classURLMap.put(SiteStatus.class,"/siteStatus/");
+ classURLMap.put(WatchdogComponentDistributionStatus.class,"/watchdogComponentDistributionStatus/");
+ classURLMap.put(WatchdogDistributionStatus.class,"/watchdogDistributionStatus/");
+ classURLMap.put(WatchdogServiceModVerIdLookup.class,"/watchdogServiceModVerIdLookup/");
+ }
+
+ <T> String getURI(Class<T> className) {
+ Class actualClass = classURLMap.keySet()
+ .stream()
+ .filter(requestdbClass -> requestdbClass.isAssignableFrom(className))
+ .findFirst()
+ .get();
+ return classURLMap.get(actualClass);
+ }
+ }
}
diff --git a/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml b/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml
index c8e90c3d8b..62ae4794f5 100644
--- a/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml
@@ -6,6 +6,10 @@ server:
max-threads: 50
ssl-enable: false
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
site-name: localDevEnv
logPath: logs
# H2
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java
new file mode 100644
index 0000000000..de0dd39edc
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java
@@ -0,0 +1,106 @@
+package org.onap.so.db.catalog.beans;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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=========================================================
+ */
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.Table;
+
+import com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+
+@IdClass(ControllerSelectionReferenceId.class)
+@Entity
+@Table(name = "CONTROLLER_SELECTION_REFERENCE")
+public class ControllerSelectionReference implements Serializable {
+
+ private static final long serialVersionUID = -608098800737567188L;
+
+ @BusinessKey
+ @Id
+ @Column(name = "VNF_TYPE")
+ private String vnfType;
+
+ @BusinessKey
+ @Id
+ @Column(name = "CONTROLLER_NAME")
+ private String controllerName;
+
+ @BusinessKey
+ @Id
+ @Column(name = "ACTION_CATEGORY")
+ private String actionCategory;
+
+
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+ public String getControllerName() {
+ return controllerName;
+ }
+ public void setControllerName(String controllerName) {
+ this.controllerName = controllerName;
+ }
+ public String getActionCategory() {
+ return actionCategory;
+ }
+ public void setActionCategory(String actionCategory) {
+ this.actionCategory = actionCategory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("vnfType", vnfType).append("controllerName", controllerName)
+ .append("actionCategory", actionCategory).toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof ControllerSelectionReference)) {
+ return false;
+ }
+ ControllerSelectionReference castOther = (ControllerSelectionReference) other;
+ return new EqualsBuilder().append(vnfType, castOther.vnfType).append(controllerName, castOther.controllerName)
+ .append(actionCategory, castOther.actionCategory).isEquals();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(vnfType).append(controllerName).append(actionCategory).toHashCode();
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java
new file mode 100644
index 0000000000..e6ee349be6
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.db.catalog.beans;
+
+import java.io.Serializable;
+
+import com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+
+
+public class ControllerSelectionReferenceId implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @BusinessKey
+ private String vnfType;
+ @BusinessKey
+ private String controllerName;
+ @BusinessKey
+ private String actionCategory;
+
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof ControllerSelectionReferenceId)) {
+ return false;
+ }
+ ControllerSelectionReferenceId castOther = (ControllerSelectionReferenceId) other;
+ return new EqualsBuilder().append(vnfType, castOther.vnfType).append(controllerName, castOther.controllerName)
+ .append(actionCategory, castOther.actionCategory).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(vnfType).append(controllerName).append(actionCategory).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("vnfType", vnfType).append("controllerName", controllerName)
+ .append("actionCategory", actionCategory).toString();
+ }
+
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+ public String getControllerName() {
+ return controllerName;
+ }
+ public void setControllerName(String controllerName) {
+ this.controllerName = controllerName;
+ }
+ public String getActionCategory() {
+ return actionCategory;
+ }
+ public void setActionCategory(String actionCategory) {
+ this.actionCategory = actionCategory;
+ }
+
+
+}
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 3b1535d66e..e43fc1796d 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
@@ -23,6 +23,7 @@ package org.onap.so.db.catalog.client;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.OrchestrationAction;
@@ -102,6 +103,8 @@ public class CatalogDbClient {
private Client<CloudifyManager> cloudifyManagerClient;
+ protected Client<ControllerSelectionReference> controllerSelectionReferenceClient;
+
@Value("${mso.catalog.db.spring.endpoint}")
private String endpoint;
@@ -145,6 +148,7 @@ public class CatalogDbClient {
cloudIdentityClient = clientFactory.create(CloudIdentity.class);
cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
+ controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) {
@@ -296,6 +300,18 @@ public class CatalogDbClient {
.build());
}
+ public ControllerSelectionReference getControllerSelectionReferenceByVnfType(String vnfType) {
+ return this.getSingleControllerSelectionReference(UriBuilder
+ .fromUri(endpoint + "/controllerSelectionReference/search/findControllerSelectionReferenceByVnfType")
+ .queryParam("VNF_TYPE", vnfType).build());
+
+ }
+
+ public ControllerSelectionReference getControllerSelectionReferenceByVnfTypeAndActionCategory(String vnfType, String actionCategory) {
+ return this.getSingleControllerSelectionReference(UriBuilder
+ .fromUri(endpoint + "/controllerSelectionReference/search/findControllerSelectionReferenceByVnfTypeAndActionCategory")
+ .queryParam("VNF_TYPE", vnfType).queryParam("ACTION_CATEGORY", actionCategory).build());
+ }
private CollectionNetworkResourceCustomization getSingleCollectionNetworkResourceCustomization(URI uri) {
return collectionNetworkResourceCustomizationClient.get(uri);
@@ -355,6 +371,10 @@ public class CatalogDbClient {
return cloudifyManagerClient.get(uri);
}
+ private ControllerSelectionReference getSingleControllerSelectionReference(URI uri) {
+ return controllerSelectionReferenceClient.get(uri);
+ }
+
public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) {
return this.getSingleService(
UriBuilder.fromUri(findByModelVersionAndModelInvariantUUIDURI)
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java
new file mode 100644
index 0000000000..ad1bbc3f68
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.db.catalog.data.repository;
+
+
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+ @RepositoryRestResource(collectionResourceRel = "controllerSelectionReference", path = "controllerSelectionReference")
+ public interface ControllerSelectionReferenceRepository extends JpaRepository<ControllerSelectionReference, String> {
+
+ public ControllerSelectionReference findControllerSelectionReferenceByVnfType(@Param("VNF_TYPE") String vnfType);
+
+ public ControllerSelectionReference findControllerSelectionReferenceByVnfTypeAndActionCategory(@Param("VNF_TYPE") String vnfType,
+ @Param("ACTION_CATEGORY") String actionCategory);
+
+ } \ No newline at end of file
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java
new file mode 100644
index 0000000000..f793fd79e3
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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.db.catalog;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.TestApplication;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.db.catalog.data.repository.ControllerSelectionReferenceRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class ControllerSelectionReferenceTest {
+
+ @Autowired
+ private ControllerSelectionReferenceRepository controllerSelectionReferenceRepository;
+
+
+ @Test
+ public void Find_ControllerNameByVnfType_Test() {
+ String vnfType = "vLoadBalancerMS/vLoadBalancerMS 0";
+ String controllerName = "APPC";
+ ControllerSelectionReference controller = controllerSelectionReferenceRepository.findControllerSelectionReferenceByVnfType(vnfType);
+ assertEquals(vnfType, controller.getVnfType());
+ assertEquals(controllerName, controller.getControllerName());
+ }
+
+ @Test
+ public void Find_ControllerNameByVnfTypeAndAction_Test() {
+ String vnfType = "vLoadBalancerMS/vLoadBalancerMS 0";
+ String controllerName = "APPC";
+ String actionCategory = "ConfigScaleOut";
+ ControllerSelectionReference controller =
+ controllerSelectionReferenceRepository.findControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
+ assertEquals(vnfType, controller.getVnfType());
+ assertEquals(controllerName, controller.getControllerName());
+ assertEquals(actionCategory, controller.getActionCategory());
+ }
+
+ @Test
+ public final void controllerDataTest() {
+ ControllerSelectionReference controller = new ControllerSelectionReference();
+
+ controller.setVnfType("vnfType");
+ assertTrue(controller.getVnfType().equalsIgnoreCase("vnfType"));
+
+ controller.setControllerName("controllerName");
+ assertTrue(controller.getControllerName().equalsIgnoreCase("controllerName"));
+
+ controller.setActionCategory("actionCategory");
+ assertTrue(controller.getActionCategory().equalsIgnoreCase("actionCategory"));
+ }
+}
diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql
index e16ca0fe8f..58bde0e532 100644
--- a/mso-catalog-db/src/test/resources/data.sql
+++ b/mso-catalog-db/src/test/resources/data.sql
@@ -642,9 +642,11 @@ VALUES
('CUSTOM', 'PENDING_DELETE', 'CUSTOM', 'CONTINUE'),
('CUSTOM', 'PRECREATED', 'CUSTOM', 'CONTINUE');
-
INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08');
INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
-INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28'); \ No newline at end of file
+INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
+
+INSERT INTO `controller_selection_reference` (`VNF_TYPE`, `CONTROLLER_NAME`, `ACTION_CATEGORY`) VALUES
+('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'ConfigScaleOut');
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 8ff04ea038..8a4b1f2103 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -822,6 +822,13 @@ create table if not exists model (
FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE IF NOT EXISTS `controller_selection_reference` (
+ `VNF_TYPE` VARCHAR(50) NOT NULL,
+ `CONTROLLER_NAME` VARCHAR(100) NOT NULL,
+ `ACTION_CATEGORY` VARCHAR(15) NOT NULL,
+ PRIMARY KEY (`VNF_TYPE`, `CONTROLLER_NAME`, `ACTION_CATEGORY`)
+) ;
+
ALTER TABLE `vnf_recipe`
CHANGE COLUMN `VNF_TYPE` `NF_ROLE` VARCHAR(200) NULL DEFAULT NULL ;
@@ -841,7 +848,6 @@ CREATE TABLE IF NOT EXISTS `identity_services` (
PRIMARY KEY (`ID`)
) ;
-
CREATE TABLE IF NOT EXISTS `cloudify_managers` (
`ID` varchar(50) NOT NULL,
`CLOUDIFY_URL` varchar(200) DEFAULT NULL,
@@ -854,9 +860,6 @@ CREATE TABLE IF NOT EXISTS `cloudify_managers` (
PRIMARY KEY (`ID`)
) ;
-
-
-
CREATE TABLE IF NOT EXISTS `cloud_sites` (
`ID` varchar(50) NOT NULL,
`REGION_ID` varchar(11) DEFAULT NULL,
@@ -872,4 +875,4 @@ CREATE TABLE IF NOT EXISTS `cloud_sites` (
PRIMARY KEY (`ID`),
KEY `FK_cloud_sites_identity_services` (`IDENTITY_SERVICE_ID`),
CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`)
-) ; \ No newline at end of file
+) ;