use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.
the class GenericCDSProcessingBBTest method testExecutionObjectCreationForVnf.
@Test
public void testExecutionObjectCreationForVnf() throws Exception {
// given
ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
controllerContext.setExecution(buildingBlockExecution);
controllerContext.setControllerActor("CDS");
controllerContext.setControllerScope("vnf");
setScopeAndAction(VNF_SCOPE, DEPLOY_ACTION_FOR_CDS);
AbstractCDSPropertiesBean cdsBean = prepareCDSBean();
doReturn(cdsBean).when(generatePayloadForCds).buildCdsPropertiesBean(buildingBlockExecution);
doNothing().when(cdsDispather).constructExecutionServiceInputObjectBB(buildingBlockExecution);
doNothing().when(cdsDispather).sendRequestToCDSClientBB(buildingBlockExecution);
// when
Boolean isUnderstandable = controllerRunnable.understand(controllerContext);
Boolean isReady = controllerRunnable.ready(controllerContext);
controllerRunnable.prepare(controllerContext);
controllerRunnable.run(controllerContext);
// verify
assertEquals(isUnderstandable, true);
assertEquals(isReady, true);
AbstractCDSPropertiesBean executionObject = buildingBlockExecution.getVariable(EXECUTION_OBJECT);
assertNotNull(executionObject);
assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
assertEquals(BLUEPRINT_NAME, executionObject.getBlueprintName());
assertEquals(BLUEPRINT_VERSION, executionObject.getBlueprintVersion());
assertEquals(TEST_MSO_REQUEST_ID, executionObject.getRequestId());
assertNotNull(executionObject.getRequestObject());
}
use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.
the class CnfHealthCheckTasks method prepareCnfAdaperRequest.
public void prepareCnfAdaperRequest(BuildingBlockExecution execution) {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
GenericVnf genericVnf = serviceInstance.getVnfs().get(0);
List<VfModule> listOfVfModules = genericVnf.getVfModules();
List<String> listOfHeatStackIds = listOfVfModules.stream().map(x -> x.getHeatStackId()).collect(Collectors.toList());
LOGGER.debug("listOfHeatStackIds from prepareCnfAdaperRequest: {}", listOfHeatStackIds);
// Prepare values to pass in execution variable for CNF Adapter async Handling
String requestId = execution.getVariable("mso-request-id");
execution.setVariable("messageType", CNF_ADAPTER_MESSAGE_TYPE);
execution.setVariable("correlator", requestId);
execution.setVariable("timeout", "PT30M");
// Replace with environment values
String callBackUrl = "http://so-bpmn-infra.onap:8081/mso/WorkflowMessage/" + CNF_ADAPTER_MESSAGE_TYPE + "/" + requestId;
HealthcheckInstanceRequest request = new HealthcheckInstanceRequest();
try {
request = createStatusCheckRequest(listOfHeatStackIds, callBackUrl);
} catch (JsonProcessingException e) {
exceptionUtil.buildAndThrowWorkflowException(execution, 6822, e);
}
LOGGER.debug("request: {}", request);
String requestPayload = "";
try {
requestPayload = mapper.writeValueAsString(request);
} catch (JsonProcessingException e) {
LOGGER.error("Error in JSON");
}
execution.setVariable("cnfRequestPayload", requestPayload);
ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
// Replace values with environment values
String uri = "http://so-cnf-adapter:8090";
String apiPath = "";
if (STATUS_CHECK_SCOPE.equals(action)) {
apiPath = uri + "/api/cnf-adapter/v1/statuscheck/";
} else if (HEALTH_CHECK_SCOPE.equals(action)) {
apiPath = uri + "/api/cnf-adapter/v1/healthcheck/";
}
LOGGER.debug("apiPath: {}", apiPath);
execution.setVariable("apiPath", apiPath);
}
use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.
the class HomingListenerTest method runWithHoming.
@Test
public void runWithHoming() {
// given
DelegateExecution execution = new DelegateExecutionFake();
execution.setVariable("homing", true);
execution.setVariable(CALLED_HOMING, false);
BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(execution);
ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
// when
new HomingListener().run(null, executeBuildingBlock, buildingBlockExecution);
// then
assertThat(executeBuildingBlock.isHoming()).isTrue();
assertThat((boolean) buildingBlockExecution.getVariable(CALLED_HOMING)).isTrue();
}
use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.
the class OrchestrationStatusValidatorUnitTest method skipValidationTest.
@Test
public void skipValidationTest() {
BuildingBlockDetail bbDetail = new BuildingBlockDetail();
bbDetail.setBuildingBlockName("customBB");
bbDetail.setResourceType(ResourceType.NO_VALIDATE);
bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
execution.setVariable("flowToBeCalled", "customBB");
execution.setVariable("aLaCarte", false);
validator.validateOrchestrationStatus(execution);
assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
}
use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.
the class MultiStageSkipListenerTest method testTrigger.
@Test
public void testTrigger() {
BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
execution.setVariable(BBConstants.G_ALACARTE, true);
assertTrue("should be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution));
execution.setVariable(BBConstants.G_ALACARTE, false);
assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution));
execution.setVariable(BBConstants.G_ALACARTE, true);
assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB2", true, execution));
execution.setVariable("multiStageDesign", true);
assertTrue("should be triggered", multiStageSkipListener.shouldRunFor(execution));
execution.setVariable("multiStageDesign", false);
assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
execution.setVariable("multiStageDesign", null);
assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
}
Aggregations