summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java41
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml4
3 files changed, 44 insertions, 5 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
index 3672df4dba..0486c529c6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
@@ -35,6 +35,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import org.onap.aai.domain.yang.ComposedResource;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+
@Component
public class CreateChildServiceBB {
@@ -73,7 +81,6 @@ public class CreateChildServiceBB {
log.info("Sending Create Service Request: \n{}", sir.toString());
buildingBlockExecution.setVariable(CHILD_SVC_REQ_CORRELATION_ID,
sir.getRequestDetails().getRequestInfo().getCorrelator());
-
ServiceInstancesResponse response = apiHandlerClient.createServiceInstance(sir);
buildingBlockExecution.setVariable(CHILD_SVC_REQ_ID, response.getRequestReferences().getRequestId());
buildingBlockExecution.setVariable(CHILD_SVC_INSTANCE_ID, response.getRequestReferences().getInstanceId());
@@ -83,6 +90,38 @@ public class CreateChildServiceBB {
}
}
+ /*
+ * This method is to create Relation between Parent & Child Services with Node as Composed Resource.
+ *
+ */
+
+ public void updateRelations(BuildingBlockExecution buildingBlockExecution) throws Exception {
+
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+
+ String childSvcInstanceId = buildingBlockExecution.getVariable(CHILD_SVC_INSTANCE_ID);
+ String parentSvcInstanceId = lookupMap.get(ResourceKey.SERVICE_INSTANCE_ID);
+
+ ComposedResource composedResource = new ComposedResource();
+ composedResource.setId(UUID.randomUUID().toString());
+
+ AAIResourcesClient client = new AAIResourcesClient();
+
+ AAIResourceUri composedResourceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(buildingBlockExecution.getGeneralBuildingBlock().getCustomer().getGlobalCustomerId())
+ .serviceSubscription(buildingBlockExecution.getGeneralBuildingBlock().getRequestContext()
+ .getSubscriptionServiceType())
+ .serviceInstance(parentSvcInstanceId).composedResource(composedResource.getId()));
+
+ client.create(composedResourceURI, composedResource);
+
+ AAIResourceUri childURI =
+ AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(childSvcInstanceId));
+
+ client.connect(composedResourceURI, childURI);
+
+ }
+
public void handleFailure(final BuildingBlockExecution buildingBlockExecution) {
Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
String childSvcInstanceName = lookupMap.get(ResourceKey.CHILD_SERVICE_INSTANCE_NAME);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index cedaef0bfd..aeef976fb4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -34,7 +34,6 @@ import static org.onap.so.bpmn.infrastructure.service.composition.ServiceComposi
import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
-
import java.sql.Timestamp;
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.RuntimeService;
@@ -315,8 +314,7 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
- verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR,
- "Rollback has been completed successfully.");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "Rollback has been completed successfully.");
verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
parentCorrelationId);
}
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 b64fc3318b..d3f5696c16 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -84,7 +84,9 @@ mso:
workflow:
message:
endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50