aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java36
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java26
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn6
-rw-r--r--bpmn/so-bpmn-tasks/pom.xml30
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java56
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java29
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java64
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java103
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java60
-rw-r--r--bpmn/so-bpmn-tasks/src/main/resources/naming-service/swagger.json325
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java71
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java57
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java105
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml3
26 files changed, 1270 insertions, 140 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java
index 343bd95eaa..781eba3332 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java
@@ -101,6 +101,8 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> {
private ModelInfoNetwork modelInfoNetwork;
@JsonProperty("aggregate-routes")
private List<AggregateRoute> aggregateRoutes = new ArrayList<>();
+ @JsonProperty("vpn-binding")
+ private List<VpnBinding> vpnBindings = new ArrayList<>();
public ModelInfoNetwork getModelInfoNetwork() {
return modelInfoNetwork;
@@ -261,6 +263,10 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> {
return aggregateRoutes;
}
+ public List<VpnBinding> getVpnBindings(){
+ return vpnBindings;
+ }
+
@Override
public boolean equals(final Object other) {
if (!(other instanceof L3Network)) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
index 4662db23a1..9709ccece0 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
@@ -30,5 +30,6 @@ public enum ResourceKey {
CONFIGURATION_ID,
NETWORK_COLLECTION_ID,
VPN_ID,
- VPN_BONDING_LINK_ID;
+ VPN_BONDING_LINK_ID,
+ INSTANCE_GROUP_ID;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 5296d5995f..7edf39df14 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -609,8 +609,9 @@ public class BBInputSetup implements JavaDelegate {
.getVnfcInstanceGroupCustomizations();
for (VnfcInstanceGroupCustomization vnfcInstanceGroupCust : vnfcInstanceGroups) {
InstanceGroup instanceGroup = this.createInstanceGroup();
- instanceGroup.setModelInfoInstanceGroup(this.mapperLayer
- .mapCatalogInstanceGroupToInstanceGroup(null, vnfcInstanceGroupCust.getInstanceGroup()));
+ org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = bbInputSetupUtils.getCatalogInstanceGroup(vnfcInstanceGroupCust.getModelUUID());
+ instanceGroup.setModelInfoInstanceGroup(this.mapperLayer
+ .mapCatalogInstanceGroupToInstanceGroup(null, catalogInstanceGroup));
instanceGroup.getModelInfoInstanceGroup().setFunction(vnfcInstanceGroupCust.getFunction());
instanceGroup.setDescription(vnfcInstanceGroupCust.getDescription());
genericVnf.getInstanceGroups().add(instanceGroup);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
index 0398c87d69..d5b5cde99b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
@@ -290,7 +290,7 @@ public class BuildingBlockTestDataSetup{
customer.setSubscriberType("testSubscriberType" + customerCounter);
customer.setServiceSubscription(buildServiceSubscription());
-
+
return customer;
}
@@ -341,50 +341,50 @@ public class BuildingBlockTestDataSetup{
customer.setServiceSubscription(buildServiceSubscription());
gBBInput.setCustomer(customer);
-
+
return customer;
}
-
+
public Collection setCollection() {
Collection collection = new Collection();
collection.setId("testId");
-
+
ServiceInstance serviceInstance = null;
-
+
try {
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
} catch(BBObjectNotFoundException e) {
serviceInstance = setServiceInstance();
}
-
+
serviceInstance.setCollection(collection);
-
+
return collection;
}
-
+
public InstanceGroup setInstanceGroup() {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId("testId");
instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
-
+
Collection collection = null;
-
+
try {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
collection = serviceInstance.getCollection();
-
+
if (collection == null) {
collection = setCollection();
}
} catch(BBObjectNotFoundException e) {
collection = setCollection();
}
-
+
collection.setInstanceGroup(instanceGroup);
-
+
return instanceGroup;
}
-
+
public VpnBinding buildVpnBinding() {
vpnBindingCounter++;
@@ -664,12 +664,12 @@ public class BuildingBlockTestDataSetup{
modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
modelInfo.setModelInstanceName("testAllottedInstanceName" + uniqueIdentifier);
-
+
ar.setModelInfoAllottedResource(modelInfo);
-
+
return ar;
}
-
+
public Configuration setConfiguration () {
Configuration config = new Configuration();
config.setConfigurationId("testConfigurationId");
@@ -679,7 +679,7 @@ public class BuildingBlockTestDataSetup{
modelInfoConfig.setModelInvariantId("modelInvariantId");
modelInfoConfig.setPolicyName("policyName");
config.setModelInfoConfiguration(modelInfoConfig);
-
+
List<Configuration> configurations = new ArrayList<>();
configurations.add(config);
ServiceInstance serviceInstance = new ServiceInstance();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index e32362d1b0..b36d6d43f8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -99,6 +99,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -1203,6 +1204,31 @@ public class BBInputSetupTest {
}
@Test
+ public void testMapVnfcCollectionInstanceGroup() {
+ VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
+ GenericVnf genericVnf = new GenericVnf();
+ ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+ Service service = Mockito.mock(Service.class);
+ List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
+ vnfcInstanceGroupCust.setModelUUID("modelUUID");
+ vnfcInstanceGroupCust.setFunction("function");
+ vnfcInstanceGroupCust.setDescription("description");
+ vnfcInstanceGroups.add(vnfcInstanceGroupCust);
+ org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
+ instanceGroup.setModelUUID("modelUUID");
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ modelInfoInstanceGroup.setModelUUID("modelUUID");
+ doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
+ doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
+ doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
+ doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
+
+ SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
+
+ assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
+ }
+ @Test
public void testPopulateGenericVnfWhereVnfTypeIsNull()
throws JsonParseException, JsonMappingException, IOException {
org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
index f29044456c..52f879b0ad 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
@@ -117,6 +117,9 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
} catch (IOException e) {
logger.error("Exception caught during sending rest request to dmaap for listening event topic", e);
}
+ finally {
+ getRequest.reset();
+ }
}
private List<String> getCorrelationIdListFromResponse(HttpResponse response) throws IOException {
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn
index 17f6c66e4a..6084f570ce 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn
@@ -189,7 +189,7 @@ dcsi.postDecomposeService(execution)]]></bpmn:script>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="content-type">application/soap+xml</camunda:entry>
- <camunda:entry key="Authorization">Basic QlBFTENsaWVudDpwYXNzd29yZDEk</camunda:entry>
+ <camunda:entry key="Authorization">${UrnPropertiesReader.getVariable("mso.adapters.requestDb.auth", execution)}</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="payload">${CVFMI_updateServiceOperStatusRequest}</camunda:inputParameter>
@@ -206,12 +206,12 @@ dcsi.postDecomposeService(execution)]]></bpmn:script>
<bpmn:scriptTask id="ScriptTask_0f3tjbn" name="prepare update service operation status" scriptFormat="groovy">
<bpmn:incoming>SequenceFlow_0h5c1bd</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1ab3vex</bpmn:outgoing>
- <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.*
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
execution.setVariable("progress", "100")
execution.setVariable("result", "finished")
execution.setVariable("operationContent", "No actual resoure in service instance")
def csi= new DoDeleteE2EServiceInstance()
-csi.prepareUpdateServiceOperationStatus(execution)]]></bpmn:script>
+csi.prepareUpdateServiceOperationStatus(execution)</bpmn:script>
</bpmn:scriptTask>
<bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0hrkmxb" name="End Delete Process">
<bpmn:outgoing>SequenceFlow_0h5c1bd</bpmn:outgoing>
diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml
index 63a65cdc24..d66c97f81a 100644
--- a/bpmn/so-bpmn-tasks/pom.xml
+++ b/bpmn/so-bpmn-tasks/pom.xml
@@ -44,6 +44,36 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-codegen-maven-plugin</artifactId>
+ <version>2.3.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <inputSpec>${project.basedir}/src/main/resources/naming-service/swagger.json</inputSpec>
+ <apiPackage>org.onap.namingservice.api</apiPackage>
+ <modelPackage>org.onap.namingservice.model</modelPackage>
+ <invokerPackage>org.onap.namingservice.invoker</invokerPackage>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <inputSpec>${project.basedir}/src/main/resources/swagger.json</inputSpec>
+ <language>java</language>
+ <configOptions>
+ <sourceFolder>src/gen/java/main</sourceFolder>
+ <serializableModel>true</serializableModel>
+ </configOptions>
+ <output>${project.build.directory}/generated-sources</output>
+ <generateApis>false</generateApis>
+ <library>jersey2</library>
+ <generateSupportingFiles>false</generateSupportingFiles>
+ </configuration>
+ </plugin>
</plugins>
</build>
<dependencyManagement>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
new file mode 100644
index 0000000000..cb4ac5c9d9
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.bpmn.infrastructure.namingservice.tasks;
+
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+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.client.orchestration.NamingServiceResources;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NamingServiceCreateTasks {
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private NamingServiceResources namingServiceResources;
+
+ public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID));
+ String policyInstanceName = execution.getVariable("policyInstanceName");
+ String nfNamingCode = execution.getVariable("nfNamingCode");
+ String generatedInstanceGroupName = "";
+ try {
+ generatedInstanceGroupName = namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
new file mode 100644
index 0000000000..ddea2724bc
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.bpmn.infrastructure.namingservice.tasks;
+
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+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.client.orchestration.NamingServiceResources;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NamingServiceDeleteTasks {
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private NamingServiceResources namingServiceResources;
+
+ public void deleteInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, execution.getLookupMap().get(ResourceKey.INSTANCE_GROUP_ID));
+
+ try {
+ namingServiceResources.deleteInstanceGroupName(instanceGroup);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
index 13639daa44..ab4a7f8a2c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
@@ -24,6 +24,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
@@ -31,17 +32,14 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.SDNCNetworkResources;
import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
import org.onap.so.client.orchestration.SDNCVfModuleResources;
import org.onap.so.client.orchestration.SDNCVnfResources;
-import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.client.orchestration.SDNCNetworkResources;
-
@Component
public class SDNCUnassignTasks {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCUnassignTasks.class);
@@ -61,12 +59,7 @@ public class SDNCUnassignTasks {
public void unassignServiceInstance(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
-
- if (serviceInstance.getOrchestrationStatus() == OrchestrationStatus.INVENTORIED) {
- return; // If INVENTORIED then SDNC unassign is not necessary
- }
-
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
String sdncUnassignResponse = sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext);
@@ -81,13 +74,7 @@ public class SDNCUnassignTasks {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
-
- if (OrchestrationStatus.INVENTORIED == vfModule.getOrchestrationStatus() || OrchestrationStatus.PENDING_CREATE == vfModule.getOrchestrationStatus()) {
- return; // If INVENTORIED or PENDING_CREATE then SDNC unassign is not necessary
- }
-
execution.setVariable("sdncVfModuleRollback", false);
-
String response = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
execution.setVariable("SDNCResponse", response);
execution.setVariable("sdncVfModuleRollback", true);
@@ -101,11 +88,6 @@ public class SDNCUnassignTasks {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
-
- if (OrchestrationStatus.INVENTORIED == vnf.getOrchestrationStatus() || OrchestrationStatus.CREATED == vnf.getOrchestrationStatus()) {
- return; // If INVENTORIED or CREATED then SDNC unassign is not necessary
- }
-
RequestContext requestContext = gBBInput.getRequestContext();
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
@@ -121,11 +103,6 @@ public class SDNCUnassignTasks {
public void unassignNetwork(BuildingBlockExecution execution) throws Exception {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
-
- if (OrchestrationStatus.INVENTORIED == network.getOrchestrationStatus()) {
- return; // If INVENTORIED then SDNC unassign is not necessary
- }
-
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
Customer customer = gBBInput.getCustomer();
RequestContext requestContext = gBBInput.getRequestContext();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java
new file mode 100644
index 0000000000..f91ad44f2b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java
@@ -0,0 +1,64 @@
+package org.onap.so.client.namingservice;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.namingservice.model.NameGenDeleteRequest;
+import org.onap.namingservice.model.NameGenDeleteResponse;
+import org.onap.namingservice.model.NameGenRequest;
+import org.onap.namingservice.model.NameGenResponse;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+
+
+@Component
+public class NamingClient{
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NamingClient.class);
+ private static final String ENDPOINT = "mso.naming.endpoint";
+ private static final String AUTH = "mso.naming.auth";
+
+ @Autowired
+ private RestTemplate restTemplate;
+ @Autowired
+ private Environment env;
+ @Autowired
+ private NamingClientResponseValidator namingClientResponseValidator;
+
+ public String postNameGenRequest(NameGenRequest request) throws BadResponseException {
+ String targetUrl = env.getProperty(ENDPOINT);
+ HttpHeaders headers = setHeaders(env.getProperty(AUTH));
+ msoLogger.info("Sending postNameGenRequest to url: " + targetUrl);
+ HttpEntity<NameGenRequest> requestEntity = new HttpEntity<>(request, headers);
+ ResponseEntity<NameGenResponse> response = restTemplate.postForEntity(targetUrl, requestEntity, NameGenResponse.class);
+ return namingClientResponseValidator.validateNameGenResponse(response);
+ }
+
+ public String deleteNameGenRequest(NameGenDeleteRequest request) throws BadResponseException {
+ String targetUrl = env.getProperty(ENDPOINT);
+ HttpHeaders headers = setHeaders(env.getProperty(AUTH));
+ msoLogger.info("Sending deleteNameGenRequest to url: " + targetUrl);
+ HttpEntity<NameGenDeleteRequest> requestEntity = new HttpEntity<>(request, headers);
+ ResponseEntity<NameGenDeleteResponse> response = restTemplate.exchange(targetUrl, HttpMethod.DELETE, requestEntity, NameGenDeleteResponse.class);
+ return namingClientResponseValidator.validateNameGenDeleteResponse(response);
+ }
+
+ private HttpHeaders setHeaders(String auth) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ List<MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ headers.add(HttpHeaders.AUTHORIZATION, auth);
+ return headers;
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
new file mode 100644
index 0000000000..ab0639574c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
@@ -0,0 +1,103 @@
+package org.onap.so.client.namingservice;
+
+import java.util.List;
+
+import org.apache.http.HttpStatus;
+import org.onap.namingservice.model.NameGenDeleteResponse;
+import org.onap.namingservice.model.NameGenResponse;
+import org.onap.namingservice.model.NameGenResponseError;
+import org.onap.namingservice.model.Respelement;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NamingClientResponseValidator {
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NamingClientResponseValidator.class);
+ private static final String INSTANCE_GROUP_NAME = "instance-group-name";
+ private static final String NO_RESPONSE_FROM_NAMING_SERVICE = "Error did not receive a response from Naming Service.";
+ private static final String NULL_RESPONSE_FROM_NAMING_SERVICE = "Error received a null response from Naming Service.";
+ private static final String NAMING_SERVICE_ERROR = "Error from Naming Service: %s";
+
+ public String validateNameGenResponse(ResponseEntity<NameGenResponse> response) throws BadResponseException {
+ if (response == null) {
+ msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, NO_RESPONSE_FROM_NAMING_SERVICE, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NO_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
+ int responseCode = response.getStatusCodeValue();
+ String generatedName = "";
+ NameGenResponse responseBody = response.getBody();
+ if (responseBody == null) {
+ msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NULL_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
+ if (isHttpCodeSuccess(responseCode)) {
+ msoLogger.info("Successful Response from Naming Service");
+ List<Respelement> respList = responseBody.getElements();
+
+ if (respList != null) {
+ for (int i=0; i < respList.size(); i++) {
+ Respelement respElement = respList.get(i);
+ if (respElement != null) {
+ String resourceName = respElement.getResourceName();
+ if (INSTANCE_GROUP_NAME.equals(resourceName)) {
+ generatedName = respElement.getResourceValue();
+ break;
+ }
+ }
+ }
+ }
+ return generatedName;
+ } else {
+ NameGenResponseError error = responseBody.getError();
+ String errorMessageString = NAMING_SERVICE_ERROR;
+ if (error != null) {
+ errorMessageString = error.getMessage();
+ }
+ String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
+ msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, errorMessage, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.DataError, errorMessage);
+ throw new BadResponseException(errorMessage);
+ }
+ }
+
+ public String validateNameGenDeleteResponse(ResponseEntity<NameGenDeleteResponse> response) throws BadResponseException {
+ if (response == null) {
+ msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, NO_RESPONSE_FROM_NAMING_SERVICE, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NO_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
+ int responseCode = response.getStatusCodeValue();
+ String responseMessage = "";
+ NameGenDeleteResponse responseBody = response.getBody();
+ if (responseBody == null) {
+ msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NULL_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
+ if (isHttpCodeSuccess(responseCode)) {
+ msoLogger.info("Successful Response from Naming Service");
+ return responseMessage;
+ } else {
+ String errorMessageString = NAMING_SERVICE_ERROR;
+
+ String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
+ msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, errorMessage, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.DataError, errorMessage);
+ throw new BadResponseException(errorMessage);
+ }
+ }
+
+ private boolean isHttpCodeSuccess(int code) {
+ return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0;
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java
new file mode 100644
index 0000000000..c3f216e288
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java
@@ -0,0 +1,38 @@
+package org.onap.so.client.namingservice;
+
+import java.util.List;
+
+import org.onap.namingservice.model.Deleteelement;
+import org.onap.namingservice.model.Element;
+import org.onap.namingservice.model.NameGenDeleteRequest;
+import org.onap.namingservice.model.NameGenRequest;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NamingRequestObjectBuilder{
+
+ public Element elementMapper(String instanceGroupId, String policyInstanceName, String namingType, String nfNamingCode, String instanceGroupName){
+ Element element = new Element();
+ element.setExternalKey(instanceGroupId);
+ element.setPolicyInstanceName(policyInstanceName);
+ element.setNamingType(namingType);
+ element.setResourceName(instanceGroupName);
+ element.setNamingIngredientsZeroOrMore(nfNamingCode);
+ return element;
+ }
+ public Deleteelement deleteElementMapper(String instanceGroupId){
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroupId);
+ return deleteElement;
+ }
+ public NameGenRequest nameGenRequestMapper(List<Element> elements){
+ NameGenRequest nameGenRequest = new NameGenRequest();
+ nameGenRequest.setElements(elements);
+ return nameGenRequest;
+ }
+ public NameGenDeleteRequest nameGenDeleteRequestMapper(List<Deleteelement> deleteElements){
+ NameGenDeleteRequest nameGenDeleteRequest = new NameGenDeleteRequest();
+ nameGenDeleteRequest.setElements(deleteElements);
+ return nameGenDeleteRequest;
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java
index e13a765cf2..a96f01c3d0 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,10 +38,10 @@ import org.springframework.stereotype.Component;
public class AAIConfigurationResources {
@Autowired
private InjectionHelper injectionHelper;
-
+
@Autowired
private AAIObjectMapper aaiObjectMapper;
-
+
/**
* A&AI call to create configuration
*
@@ -142,24 +142,32 @@ public class AAIConfigurationResources {
*
* @param configurationId
* @param vpnId
+ *
*/
public void connectConfigurationToVpnBinding(String configurationId, String vpnId) {
AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
AAIResourceUri vpnBindingURI = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId);
injectionHelper.getAaiClient().connect(configurationURI, vpnBindingURI);
}
-
+
public void connectConfigurationToVfModule(String configurationId, String vfModuleId, String vnfId){
AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
injectionHelper.getAaiClient().connect(configurationURI, vfModuleURI);
}
-
+
public void connectConfigurationToVnfc(String configurationId, String vnfcName){
AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName);
injectionHelper.getAaiClient().connect(configurationURI, vnfcURI);
}
+
+ public void connectConfigurationToL3Network(String configurationId, String networkId){
+ AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId);
+ injectionHelper.getAaiClient().connect(configurationURI, networkURI);
+ }
+
/**
* method to delete Configuration details in A&AI
*
@@ -188,7 +196,7 @@ public class AAIConfigurationResources {
return injectionHelper.getAaiClient()
.get(org.onap.aai.domain.yang.Configuration.class, AAIUriFactory.createResourceFromExistingURI(AAIObjectType.CONFIGURATION, UriBuilder.fromPath(relatedLink).build()));
}
-
+
public void updateOrchestrationStatusConfiguration(Configuration configuration, OrchestrationStatus orchestrationStatus) {
AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
configuration.setOrchestrationStatus(orchestrationStatus);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
index a4c705b0c7..46b18f5e32 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,22 +47,22 @@ import org.springframework.stereotype.Component;
public class AAINetworkResources {
@Autowired
private InjectionHelper injectionHelper;
-
+
@Autowired
private AAIObjectMapper aaiObjectMapper;
-
+
public void updateNetwork(L3Network network) {
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network);
injectionHelper.getAaiClient().update(networkURI, aaiL3Network);
}
-
+
public void updateSubnet(L3Network network, Subnet subnet) {
AAIResourceUri subnetURI = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, network.getNetworkId(), subnet.getSubnetId());
org.onap.aai.domain.yang.Subnet aaiSubnet = aaiObjectMapper.mapSubnet(subnet);
injectionHelper.getAaiClient().update(subnetURI, aaiSubnet);
}
-
+
public void createNetworkConnectToServiceInstance(L3Network network, ServiceInstance serviceInstance) {
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
@@ -76,11 +76,11 @@ public class AAINetworkResources {
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
injectionHelper.getAaiClient().delete(networkURI);
}
-
+
public Optional<VpnBinding> getVpnBinding(AAIResourceUri netBindingUri) {
- return injectionHelper.getAaiClient().get(netBindingUri).asBean(VpnBinding.class);
+ return injectionHelper.getAaiClient().get(netBindingUri.depth(Depth.TWO)).asBean(VpnBinding.class);
}
-
+
public Optional<NetworkPolicy> getNetworkPolicy(AAIResourceUri netPolicyUri) {
return injectionHelper.getAaiClient().get(netPolicyUri).asBean(NetworkPolicy.class);
}
@@ -88,85 +88,85 @@ public class AAINetworkResources {
public Optional<RouteTableReference> getRouteTable(AAIResourceUri rTableUri) {
return injectionHelper.getAaiClient().get(rTableUri).asBean(RouteTableReference.class);
}
-
+
public Optional<org.onap.aai.domain.yang.L3Network> queryNetworkById(L3Network l3network) {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK,l3network.getNetworkId()).depth(Depth.ALL);
AAIResultWrapper aaiWrapper = injectionHelper.getAaiClient().get(uri);
return aaiWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
- }
-
+ }
+
public AAIResultWrapper queryNetworkWrapperById(L3Network l3network) {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK,l3network.getNetworkId()).depth(Depth.ALL);
return injectionHelper.getAaiClient().get(uri);
}
-
+
public void createNetworkInstanceGroup(InstanceGroup instanceGroup) {
AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
injectionHelper.getAaiClient().create(instanceGroupURI, aaiInstanceGroup);
}
-
+
public void createNetworkCollection(Collection networkCollection) {
AAIResourceUri networkCollectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
networkCollection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(networkCollection);
injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection);
}
-
+
public void connectNetworkToTenant(L3Network l3network, CloudRegion cloudRegion) {
- AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
+ AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
injectionHelper.getAaiClient().connect(tenantURI, networkURI);
}
-
+
public void connectNetworkToCloudRegion(L3Network l3network, CloudRegion cloudRegion) {
- AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
injectionHelper.getAaiClient().connect(cloudRegionURI, networkURI);
}
-
+
public void connectNetworkToNetworkCollectionInstanceGroup(L3Network l3network, InstanceGroup instanceGroup) {
AAIResourceUri netwrokCollectionInstanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
injectionHelper.getAaiClient().connect(netwrokCollectionInstanceGroupURI, networkURI);
}
-
+
public void connectNetworkToNetworkCollectionServiceInstance(L3Network l3network, ServiceInstance networkCollectionServiceInstance) {
AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
injectionHelper.getAaiClient().connect(networkCollectionServiceInstanceUri, networkURI);
}
-
+
public void connectNetworkCollectionInstanceGroupToNetworkCollection(InstanceGroup instanceGroup, Collection networkCollection) {
AAIResourceUri networkCollectionUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
AAIResourceUri netwrokCollectionInstanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
injectionHelper.getAaiClient().connect(networkCollectionUri, netwrokCollectionInstanceGroupURI);
}
-
+
public void connectInstanceGroupToCloudRegion(InstanceGroup instanceGroup, CloudRegion cloudRegion) {
- AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
injectionHelper.getAaiClient().connect(instanceGroupURI, cloudRegionURI, AAIEdgeLabel.USES);
}
-
+
public void connectNetworkCollectionToServiceInstance(Collection networkCollection, ServiceInstance networkCollectionServiceInstance) {
AAIResourceUri networkCollectionUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
injectionHelper.getAaiClient().connect(networkCollectionUri, networkCollectionServiceInstanceUri);
}
-
+
public void deleteCollection(Collection collection) {
AAIResourceUri collectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
injectionHelper.getAaiClient().delete(collectionURI);
}
-
+
public void deleteNetworkInstanceGroup(InstanceGroup instanceGroup) {
AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
injectionHelper.getAaiClient().delete(instanceGroupURI);
}
-
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
new file mode 100644
index 0000000000..8b443a165b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.client.orchestration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.namingservice.model.Element;
+import org.onap.namingservice.model.Deleteelement;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.namingservice.NamingClient;
+import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NamingServiceResources {
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NamingServiceResources.class);
+ private static final String NAMING_TYPE = "instanceGroup";
+
+ @Autowired
+ private NamingClient namingClient;
+
+ @Autowired
+ private NamingRequestObjectBuilder namingRequestObjectBuilder;
+
+ public String generateInstanceGroupName(InstanceGroup instanceGroup, String policyInstanceName, String nfNamingCode) throws BadResponseException {
+ Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName, NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName());
+ List<Element> elements = new ArrayList<Element>();
+ elements.add(element);
+ return(namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements)));
+ }
+
+ public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException {
+ Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId());
+ List<Deleteelement> deleteElements = new ArrayList<Deleteelement>();
+ deleteElements.add(deleteElement);
+ return(namingClient.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements)));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/resources/naming-service/swagger.json b/bpmn/so-bpmn-tasks/src/main/resources/naming-service/swagger.json
new file mode 100644
index 0000000000..b86ffbc6b0
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/resources/naming-service/swagger.json
@@ -0,0 +1,325 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "version": "2018.08.01",
+ "title": "networkelementnamegenprodtest Service"
+ },
+ "basePath": "/web",
+ "paths": {
+ "/service/v1/addPolicy": {
+ "post": {
+ "summary": "Respond Hello <name>!",
+ "description": "Returns a JSON object with a string to say hello. Uses 'world' if a name is not specified",
+ "operationId": "addPolicyToDB",
+ "produces": [
+ "application/json"
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object"
+ }
+ }
+ },
+ "404": {
+ "description": "Service not available"
+ },
+ "500": {
+ "description": "Unexpected Runtime error"
+ }
+ }
+ }
+ },
+ "/service/v1/genNetworkElementName": {
+ "post": {
+ "summary": "Generates name",
+ "description": "Generates network element name based on a naming policy1 ",
+ "operationId": "generateNetworkElementName",
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/NameGenRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/NameGenResponse"
+ }
+ },
+ "404": {
+ "description": "Service not available"
+ },
+ "500": {
+ "description": "Unexpected Runtime error"
+ }
+ }
+ },
+ "delete": {
+ "summary": "Release an existing name by external key",
+ "description": "Release network element name ",
+ "operationId": "releaseNetworkElementName",
+ "produces": [
+ "application/json"
+ ],"parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/NameGenDeleteRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/NameGenDeleteResponse"
+ }
+ },
+ "404": {
+ "description": "Service not available"
+ },
+ "500": {
+ "description": "Unexpected Runtime error"
+ }
+ }
+ }
+ },
+ "/service/v1/getpolicyresponse/{policyName}": {
+ "get": {
+ "summary": "Respond Hello <name>!",
+ "description": "Returns a JSON object with a string to say hello. Uses 'world' if a name is not specified",
+ "operationId": "getPolicyResponse",
+ "produces": [
+ "application/json"
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object"
+ }
+ }
+ },
+ "404": {
+ "description": "Service not available"
+ },
+ "500": {
+ "description": "Unexpected Runtime error"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "HelloWorld": {
+ "type": "object",
+ "properties": {
+ "message": {
+ "type": "string"
+ }
+ }
+ },
+ "NameGenRequest": {
+ "title": "NameGenRequest",
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "required": [
+ "elements"
+ ],
+ "properties": {
+ "elements": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/element"
+ }
+ }
+ },
+ "additionalProperties": false,
+ "definitions": {
+ "element": {
+ "type": "object",
+ "required": [
+ "resource-name",
+ "external-key",
+ "policy-instance-name",
+ "naming-type"
+ ],
+ "properties": {
+ "resource-name": {
+ "type": "string",
+ "description": "Name of the resource"
+ },
+ "resource-value": {
+ "type": "string",
+ "description": "Optional. If given, request will be considered as update request"
+ },
+ "external-key": {
+ "type": "string",
+ "description": "Key identifier for generated name. This will be used in release/update request"
+ },
+ "policy-instance-name": {
+ "type": "string",
+ "description": "Name of the policy to be used for name generation"
+ },
+ "naming-type": {
+ "type": "string",
+ "description": "Naming type of the resource"
+ }
+ },
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "NameGenResponse": {
+ "type": "object",
+ "description":"Response with generated names for each naming type. Either elements(one or more) or an error block will be present",
+ "properties": {
+ "elements" : {
+ "type":"array",
+ "items": { "$ref": "#/definitions/respelement" }
+ },
+ "error" : {
+ "type":"object",
+ "required": ["errorId", "message"],
+ "properties":{
+ "errorId":{"type":"string" , "description":"error code"},
+ "message": {"type":"string", "description":"error message"}
+ }
+ }
+ }
+ },
+ "element": {
+ "type": "object",
+ "required": [
+ "resource-name",
+ "external-key",
+ "policy-instance-name",
+ "naming-type"
+ ],
+ "properties": {
+ "resource-name": {
+ "type": "string",
+ "description": "Name of the resource"
+ },
+ "resource-value": {
+ "type": "string",
+ "description": "Optional. If given, request will be considered as update request"
+ },
+ "external-key": {
+ "type": "string",
+ "description": "Key identifier for generated name. This will be used in release/update request"
+ },
+ "policy-instance-name": {
+ "type": "string",
+ "description": "Name of the policy to be used for name generation"
+ },
+ "naming-type": {
+ "type": "string",
+ "description": "Naming type of the resource"
+ },
+ "${naming-ingredients(zero or more)}": {
+ "type": "string",
+ "description": "values to subsitute in the naming recipe"
+ }
+ },
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "respelement": {
+ "type":"object",
+ "required": [ "resource-name","resource-value","external-key"],
+ "properties": {
+ "resource-value": {
+ "type": "string",
+ "description": "Optional. If given, request will be considered as update request"
+ },
+ "resource-name": {
+ "type": "string",
+ "description": "Name of the resource"
+ },
+ "external-key": {
+ "type": "string",
+ "description": "Key identifier for generated name. This will be used in release/update request"
+ }
+ }
+ },
+ "NameGenDeleteRequest": {
+ "title": "NameGenRequest",
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "required": [
+ "elements"
+ ],
+ "properties": {
+ "elements": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/deleteelement"
+ }
+ }
+ }
+ },
+ "deleteelement": {
+ "type": "object",
+ "required": [ "external-key" ],
+ "properties": {
+ "external-key": {
+ "type": "string",
+ "description": "External key of the name that is being released"
+ }
+ }
+ },"NameGenDeleteResponse": {
+ "title": "NameGenRequest",
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "required": [
+ "elements"
+ ],
+ "properties": {
+ "elements": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/deleteresponseelement"
+ }
+ }
+ }
+ },
+ "deleteresponseelement": {
+ "type": "object",
+ "required": [ "resource-value","resource_name","external-key" ],
+ "properties": {
+ "resource-value": {
+ "type": "string",
+ "description": "Name that is being release"
+ },
+ "resource-name": {
+ "type": "string",
+ "description": "Resource Name"
+ },
+ "external-key": {
+ "type": "string",
+ "description": "External key of the name that is being released"
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index 95201d555d..21b89c3731 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -44,6 +44,7 @@ import org.onap.so.client.orchestration.AAIVfModuleResources;
import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.client.orchestration.AAIVolumeGroupResources;
import org.onap.so.client.orchestration.AAIVpnBindingResources;
+import org.onap.so.client.orchestration.NamingServiceResources;
import org.onap.so.client.orchestration.NetworkAdapterResources;
import org.onap.so.client.orchestration.SDNCNetworkResources;
import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
@@ -111,6 +112,9 @@ public abstract class BaseTaskTest extends TestDataSetup {
@Mock
protected AAIInstanceGroupResources aaiInstanceGroupResources;
+
+ @Mock
+ protected NamingServiceResources namingServiceResources;
@Mock
protected ApplicationControllerAction appCClient;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
new file mode 100644
index 0000000000..41739f37e6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.bpmn.infrastructure.namingservice.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+
+public class NamingServiceCreateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private NamingServiceCreateTasks namingServiceCreateTasks = new NamingServiceCreateTasks();
+
+ private InstanceGroup instanceGroup;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ instanceGroup = setInstanceGroup();
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID), any())).thenReturn(instanceGroup);
+ }
+
+ @Test
+ public void createInstanceGroupTest() throws Exception {
+ String policyInstanceName = "policyInstanceName";
+ String nfNamingCode = "nfNamingCode";
+ String generatedName = "generatedInstanceGroupName";
+ execution.setVariable(policyInstanceName, policyInstanceName);
+ execution.setVariable(nfNamingCode, nfNamingCode);
+ doReturn(generatedName).when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
+
+ namingServiceCreateTasks.createInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
+ assertEquals(instanceGroup.getInstanceGroupName(), generatedName);
+ }
+
+ @Test
+ public void createInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BBObjectNotFoundException.class);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID),eq("notfound"));
+ String policyInstanceName = "policyInstanceName";
+ String nfNamingCode = "nfNamingCode";
+ execution.setVariable(policyInstanceName, policyInstanceName);
+ execution.setVariable(nfNamingCode, nfNamingCode);
+ doReturn("").when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
+ namingServiceCreateTasks.createInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
+
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
new file mode 100644
index 0000000000..97dcc617ac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.bpmn.infrastructure.namingservice.tasks;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+
+public class NamingServiceDeleteTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks();
+
+ private InstanceGroup instanceGroup;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ instanceGroup = setInstanceGroup();
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID), any())).thenReturn(instanceGroup);
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+
+ doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
+
+ namingServiceDeleteTasks.deleteInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
+ }
+
+ @Test
+ public void deleteInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BBObjectNotFoundException.class);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID),eq("notfound"));
+ doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
+ namingServiceDeleteTasks.deleteInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
index da8ea8f58c..07f03b592b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
@@ -88,16 +88,7 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer, requestContext);
}
- @Test
- public void unassignServiceInstanceTest_inventoried() throws Exception {
- doReturn("test").when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
-
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignServiceInstance(execution);
-
- verify(sdncServiceInstanceResources, times(0)).unassignServiceInstance(serviceInstance, customer, requestContext);
- }
+
@Test
public void unassignServiceInstanceExceptionTest() throws Exception {
@@ -118,26 +109,9 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
assertEquals("response", execution.getVariable("SDNCResponse"));
}
- @Test
- public void unassignVfModuleTest_inventoried() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(0)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertNull(execution.getVariable("SDNCResponse"));
- }
- @Test
- public void unassignVfModuleTest_pendingCreate() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_CREATE);
-
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(0)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertNull(execution.getVariable("SDNCResponse"));
- }
-
@Test
public void unassignVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -157,25 +131,6 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
assertTrue(execution.getVariable("sdncUnassignVnfResponse").equals("response"));
}
- @Test
- public void unassignVnfTest_inventoried() throws Exception {
- genericVnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignVnf(execution);
-
- verify(sdncVnfResources, times(0)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertNull(execution.getVariable("sdncUnassignVnfResponse"));
- }
-
- @Test
- public void unassignVnfTest_created() throws Exception {
- genericVnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- sdncUnassignTasks.unassignVnf(execution);
-
- verify(sdncVnfResources, times(0)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertNull(execution.getVariable("sdncUnassignVnfResponse"));
- }
@Test
public void unassignVnfExceptionTest() throws Exception {
@@ -201,14 +156,4 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
assertEquals("response", execution.getVariable("SDNCUnAssignNetworkResponse"));
assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
}
-
- @Test
- public void unassignNetworkTest_inventoried() throws Exception {
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignNetwork(execution);
-
- verify(sdncNetworkResources, times(0)).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertNull(execution.getVariable("SDNCUnAssignNetworkResponse"));
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
new file mode 100644
index 0000000000..70036e7480
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
@@ -0,0 +1,84 @@
+package org.onap.so.client.namingservice;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.namingservice.model.NameGenDeleteResponse;
+import org.onap.namingservice.model.NameGenResponse;
+import org.onap.namingservice.model.Respelement;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.client.exception.BadResponseException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+public class NamingClientResponseValidatorTest extends TestDataSetup {
+
+ private NamingClientResponseValidator responseValidator = new NamingClientResponseValidator();
+ private String instanceGroupName = "generatedInstanceGroupName";
+
+ @Test
+ public void validateNameGenResponseSuccessTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+ Respelement respElement = new Respelement();
+ respElement.setResourceName("instance-group-name");
+ respElement.setResourceValue(instanceGroupName);
+ List<Respelement> respList = new ArrayList<Respelement>();
+ respList.add(respElement);
+ name.setElements(respList);
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenResponse(resp);
+
+ assertEquals(actual, "generatedInstanceGroupName");
+ }
+
+ @Test
+ public void validateNameGenResponseNoNameGeneratedTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+ Respelement respElement = new Respelement();
+ respElement.setResourceName("instance-group");
+ respElement.setResourceValue(instanceGroupName);
+ List<Respelement> respList = new ArrayList<Respelement>();
+ respList.add(respElement);
+ name.setElements(respList);
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenResponse(resp);
+
+ assertEquals(actual, "");
+ }
+
+ @Test
+ public void validateNameGenResponseBadStatusTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
+
+ expectedException.expect(BadResponseException.class);
+ responseValidator.validateNameGenResponse(resp);
+ }
+
+ @Test
+ public void validateNameGenDeleteResponseSuccessTest() throws BadResponseException {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenDeleteResponse(resp);
+
+ assertEquals(actual, "");
+ }
+
+ @Test
+ public void validateNameGenDeleteResponseBadStatusTest() throws BadResponseException {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
+
+ expectedException.expect(BadResponseException.class);
+ responseValidator.validateNameGenDeleteResponse(resp);
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
new file mode 100644
index 0000000000..0a2dc1e4fa
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
@@ -0,0 +1,85 @@
+package org.onap.so.client.namingservice;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.namingservice.model.Deleteelement;
+import org.onap.namingservice.model.Element;
+import org.onap.namingservice.model.NameGenDeleteRequest;
+import org.onap.namingservice.model.NameGenRequest;
+import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
+
+public class NamingRequestObjectBuilderTest {
+
+ private NamingRequestObjectBuilder mapper = new NamingRequestObjectBuilder();
+ private String instanceGroupId = "95cbbe59-1017-4c13-b4e8-d824e54def3e";
+ private String policyInstanceName = "MSO_Policy.Config_MS_VNFInstanceGroup";
+ private String namingType = "InstanceGroup";
+ private String nfNamingCode = "NamingCode";
+ private String instanceGroupName = "InstanceGroupName";
+
+ @Test
+ public void elementMapperTest(){
+ // Expected element
+ Element expected = new Element();
+ expected.setExternalKey(instanceGroupId);
+ expected.setPolicyInstanceName(policyInstanceName);
+ expected.setNamingType(namingType);
+ expected.setResourceName(instanceGroupName);
+ expected.setNamingIngredientsZeroOrMore(nfNamingCode);
+
+ // Actual element
+ Element actual = mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+ @Test
+ public void deleteElementMapperTest(){
+ // Expected Deleteelement
+ Deleteelement expected = new Deleteelement();
+ expected.setExternalKey(instanceGroupId);
+
+ // Actual Deleteelement
+ Deleteelement actual = mapper.deleteElementMapper(instanceGroupId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+ @Test
+ public void nameGenRequestMapper(){
+ // Expected NameGenRequest
+ NameGenRequest expected = new NameGenRequest();
+ List<Element> elements = new ArrayList<>();
+ Element element = new Element();
+ element.setExternalKey(instanceGroupId);
+ element.setPolicyInstanceName(policyInstanceName);
+ element.setNamingType(namingType);
+ element.setResourceName(instanceGroupName);
+ element.setNamingIngredientsZeroOrMore(nfNamingCode);
+ elements.add(element);
+ expected.setElements(elements);
+
+ //Actual NameGenRequest
+ NameGenRequest actual = mapper.nameGenRequestMapper(elements);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+ @Test
+ public void nameGenDeleteRequestMapper(){
+ // Expected NameGenDeleteRequest
+ NameGenDeleteRequest expected = new NameGenDeleteRequest();
+ List<Deleteelement> deleteElements = new ArrayList<>();
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroupId);
+ deleteElements.add(deleteElement);
+ expected.setElements(deleteElements);
+
+ // Actual NameGenDeleteRequest
+ NameGenDeleteRequest actual = mapper.nameGenDeleteRequestMapper(deleteElements);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
new file mode 100644
index 0000000000..629e98abb2
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============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.client.orchestration;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.namingservice.model.Deleteelement;
+import org.onap.namingservice.model.Element;
+import org.onap.namingservice.model.NameGenDeleteRequest;
+import org.onap.namingservice.model.NameGenDeleteResponse;
+import org.onap.namingservice.model.NameGenRequest;
+import org.onap.namingservice.model.NameGenResponse;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.client.namingservice.NamingClient;
+import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class NamingServiceResourcesTest extends TestDataSetup{
+ @InjectMocks
+ private NamingServiceResources namingServiceResources = new NamingServiceResources();
+
+ private InstanceGroup instanceGroup;
+
+ @Mock
+ protected NamingRequestObjectBuilder MOCK_namingRequestObjectBuilder;
+
+ @Mock
+ protected NamingClient MOCK_namingClient;
+
+ @Before
+ public void before() {
+ instanceGroup = buildInstanceGroup();
+ }
+
+ @Test
+ public void generateInstanceGroupNameTest() throws Exception {
+ NameGenResponse name = new NameGenResponse();
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+ Element element = new Element();
+
+ NameGenRequest req = new NameGenRequest();
+ doReturn(element).when(MOCK_namingRequestObjectBuilder).elementMapper(isA(String.class), isA(String.class),
+ isA(String.class), isA(String.class), isA(String.class));
+ doReturn("generatedInstanceGroupName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
+
+ String generatedName = namingServiceResources.generateInstanceGroupName(instanceGroup, "policyInstanceName", "nfNamingCode");
+
+ verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
+ assertEquals(generatedName, "generatedInstanceGroupName");
+ }
+
+ @Test
+ public void deleteInstanceGroupNameTest() throws Exception {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroup.getId());
+ NameGenDeleteRequest req = new NameGenDeleteRequest();
+ doReturn(deleteElement).when(MOCK_namingRequestObjectBuilder).deleteElementMapper(isA(String.class));
+ doReturn("").when(MOCK_namingClient).deleteNameGenRequest(isA(NameGenDeleteRequest.class));
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
+
+ namingServiceResources.deleteInstanceGroupName(instanceGroup);
+
+ verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
+
+ }
+
+
+}
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 4ecdc721f0..7ecb5aa9eb 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -41,6 +41,9 @@ pnf:
consumerId: consumerId
topicListenerDelayInSeconds: 5
mso:
+ naming:
+ endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
adapters:
requestDb:
auth: Basic YnBlbDptc28tZGItMTUwNyE=