aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorMnushkin, Dmitry <dmitry.mnushkin@att.com>2019-06-06 15:34:19 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-06 15:44:00 -0400
commit0b9b0b6b91d9926218786c93438d903f554b4a4f (patch)
tree74f017815f9ec4a6f7c30d9dab0b9e619306e904 /bpmn
parent62b2e47808fe1adcbac31dbcdf992617b7f0bd4d (diff)
Enhance naming service support
correct sourcing for service-model-name in NamingMS remove zone ID from NamingMS input for service name follow up removal of autowired on NamingRequestObject Change-Id: Icba2e32c07ee0c7d7739ce21bd547e3030c1e271 Issue-ID: SO-1976 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java42
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java12
4 files changed, 13 insertions, 79 deletions
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
index df22cfdc26..155455e654 100644
--- 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
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.namingservice.tasks;
-
import java.util.List;
import java.util.Optional;
import org.onap.aai.domain.yang.Zone;
@@ -89,7 +88,6 @@ public class NamingServiceCreateTasks {
namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- namingRequestObject.setZoneIdValue(this.getRelatedZoneId(execution));
String generatedWanTransportServiceName = "";
try {
@@ -122,44 +120,4 @@ public class NamingServiceCreateTasks {
}
serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName);
}
-
- protected String getRelatedZoneId(BuildingBlockExecution execution) {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- String cloudRegionId = gBBInput.getCloudRegion().getLcpCloudRegionId();
- String cloudOwner = gBBInput.getCloudRegion().getCloudOwner();
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, cloudRegionId);
- AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
- Optional<Relationships> relationshipsOp = this.getRelationshipsFromWrapper(vnfcResultsWrapper);
- Zone aaiZone = getRelatedZone(relationshipsOp);
- if (aaiZone == null) {
- String errMsg = "No relationships for Cloud Region in AAI to extract zone id";
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errMsg);
- }
- return aaiZone.getZoneId();
- }
-
- protected Optional<Relationships> getRelationshipsFromWrapper(AAIResultWrapper wrapper) {
- Optional<Relationships> relationshipsOp;
- relationshipsOp = wrapper.getRelationships();
- if (relationshipsOp.isPresent()) {
- return relationshipsOp;
- }
- return Optional.empty();
- }
-
- protected org.onap.aai.domain.yang.Zone getRelatedZone(Optional<Relationships> relationshipsOp) {
- Zone aaiZone = null;
- if (relationshipsOp.isPresent()) {
- Relationships relationships = relationshipsOp.get();
- if (!relationships.getAll().isEmpty()) {
- List<AAIResultWrapper> zones = relationships.getByType(AAIObjectType.ZONE);
- AAIResultWrapper zoneWrapper = zones.get(0);
- Optional<Zone> aaiZoneOp = zoneWrapper.asBean(Zone.class);
- if (aaiZoneOp.isPresent()) {
- aaiZone = aaiZoneOp.get();
- }
- }
- }
- return aaiZone;
- }
}
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
index 3f62a61518..44e5e0e707 100644
--- 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
@@ -106,7 +106,7 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest {
String generatedName = "generatedWanTransportServiceName";
doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any());
NamingServiceCreateTasks spy = Mockito.spy(namingServiceCreateTasks);
- doReturn("testZoneId").when(spy).getRelatedZoneId(any());
+
spy.createWanTransportServiceName(execution);
verify(namingServiceResources, times(1)).generateServiceInstanceName(any());
assertEquals(generatedName, serviceInstance.getServiceInstanceName());
@@ -124,37 +124,4 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest {
verify(namingServiceResources, times(1)).generateServiceInstanceName(any());
assertEquals(generatedName, serviceInstance.getServiceInstanceName());
}
-
- @Test
- public void getRelatedZoneIdTest() throws Exception {
-
- String zoneId = "zoneId";
- Zone zone = new Zone();
- zone.setZoneId(zoneId);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner("testCloudOwner");
- cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- gBBInput.setCloudRegion(cloudRegion);
-
- AAIResultWrapper cloudRegionWrapper =
- new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion));
-
- Relationships relationships = Mockito.mock(Relationships.class);
- relationships.getAll().add(cloudRegionWrapper);
- Optional<Relationships> relationshipsOp = Optional.of(relationships);
-
- doReturn(cloudRegionWrapper).when(MOCK_bbInputSetupUtils).getAAIResourceDepthOne(any());
-
- NamingServiceCreateTasks spy = Mockito.spy(namingServiceCreateTasks);
-
- doReturn(relationshipsOp).when(spy).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
- doReturn(zone).when(spy).getRelatedZone(any());
- spy.setBbInputSetupUtils(MOCK_bbInputSetupUtils);
-
- String returnedZoneId = spy.getRelatedZoneId(execution);
-
- assertEquals(zoneId, returnedZoneId);
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java
index 49f858d2ce..7c50b2031d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java
@@ -35,7 +35,6 @@ public class NamingRequestObjectTest {
private String resourceName = "resourceName";
private String serviceModelName = "serviceModelName";
private String modelVersion = "modelVersion";
- private String zoneId = "zoneId";
@Test
public void namingRequestObjectTest() {
@@ -68,7 +67,6 @@ public class NamingRequestObjectTest {
expected.put(NamingServiceConstants.NS_RESOURCE_NAME, resourceName);
expected.put(NamingServiceConstants.NS_SERVICE_MODEL_NAME, serviceModelName);
expected.put(NamingServiceConstants.NS_MODEL_VERSION, modelVersion);
- expected.put(NamingServiceConstants.NS_ZONE_ID, zoneId);
NamingRequestObject namingRequestObject = new NamingRequestObject();
namingRequestObject.setExternalKeyValue(externalKey);
@@ -77,7 +75,6 @@ public class NamingRequestObjectTest {
namingRequestObject.setResourceNameValue(resourceName);
namingRequestObject.setModelVersionValue(modelVersion);
namingRequestObject.setServiceModelNameValue(serviceModelName);
- namingRequestObject.setZoneIdValue(zoneId);
HashMap<String, String> actual = namingRequestObject.getNamingRequestObjectMap();
assertThat(actual, sameBeanAs(expected));
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
index 1f5b42b94e..c60e749a29 100644
--- 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
@@ -123,4 +123,16 @@ public class NamingServiceResourcesTest extends TestDataSetup {
verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
assertEquals("generatedServiceInstanceName", generatedName);
}
+
+ @Test
+ public void deleteServiceInstanceNameTest() throws Exception {
+ NameGenDeleteRequest req = new NameGenDeleteRequest();
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
+
+ NamingRequestObject nrObject = new NamingRequestObject();
+ nrObject.setExternalKeyValue("testExternalKey");
+ nrObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
+ namingServiceResources.deleteServiceInstanceName(nrObject);
+ verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
+ }
}