use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class GenericCDSProcessingBBTest method setUp.
@Before
public void setUp() {
buildingBlockExecution = createBuildingBlockExecution();
executeBuildingBlock = new ExecuteBuildingBlock();
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class CnfHealthCheckTasks method processAsyncResponse.
public void processAsyncResponse(BuildingBlockExecution execution) {
// Value from CNF Async Handler activity
String asyncResponse = execution.getVariable("asyncCallbackResponse");
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 "));
LOGGER.debug("action: {}", action);
if (asyncResponse.contains("error")) {
exceptionUtil.buildAndThrowWorkflowException(execution, 500, asyncResponse, ONAPComponents.SO);
}
if (STATUS_CHECK_SCOPE.equals(action)) {
StatusCheckResponse statusCheckResponse = new StatusCheckResponse();
try {
statusCheckResponse = mapper.readValue(asyncResponse, StatusCheckResponse.class);
} catch (JsonProcessingException e) {
LOGGER.error("Error in parsing JSON response");
}
LOGGER.debug("statusCheckResponse: {}", statusCheckResponse);
List<StatusCheckInstanceResponse> listOfStatusInstanceResponse = statusCheckResponse.getInstanceResponse();
for (StatusCheckInstanceResponse statusCheckInstanceResponse : listOfStatusInstanceResponse) {
if (!statusCheckInstanceResponse.isStatus()) {
exceptionUtil.buildAndThrowWorkflowException(execution, 500, asyncResponse, ONAPComponents.SO);
}
}
String statusCheckResponseJson = "";
try {
statusCheckResponseJson = mapper.writeValueAsString(statusCheckResponse);
} catch (JsonProcessingException e) {
LOGGER.error("Error in PARSING statusCheckResponse");
}
execution.setVariable("StatusMessage", statusCheckResponseJson);
} else if (HEALTH_CHECK_SCOPE.equals(action)) {
HealthcheckResponse healthCheckResponse = new HealthcheckResponse();
try {
healthCheckResponse = mapper.readValue(asyncResponse, HealthcheckResponse.class);
} catch (JsonProcessingException e) {
LOGGER.error("Error in parsing JSON");
}
List<HealthcheckInstanceResponse> listOfHealthcheckInstanceResponses = healthCheckResponse.getInstanceResponse();
for (HealthcheckInstanceResponse healthcheckInstanceResponse : listOfHealthcheckInstanceResponses) {
if ("Failed".equalsIgnoreCase(healthcheckInstanceResponse.getStatus()) || "Unknown".equalsIgnoreCase(healthcheckInstanceResponse.getStatus())) {
exceptionUtil.buildAndThrowWorkflowException(execution, 500, asyncResponse, ONAPComponents.SO);
}
}
String healthCheckResponseJson = "";
try {
healthCheckResponseJson = mapper.writeValueAsString(healthCheckResponse);
} catch (JsonProcessingException e) {
LOGGER.error("Error in PARSING statusCheckResponse");
}
execution.setVariable("StatusMessage", healthCheckResponseJson);
LOGGER.debug("healthCheckResponse: {}", healthCheckResponse);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock 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.servicedecomposition.entities.ExecuteBuildingBlock 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.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class BBInputSetupTest method testGBBMacroNoUserParamsVrfConfiguration.
@Test
public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception {
String resourceId = "123";
String vnfType = "vnfType";
String requestAction = "createInstance";
Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacroVrf.json"), RequestDetails.class);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("AssignVrfConfigurationBB");
buildingBlock.setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
RelatedInstance relatedVpnBinding = new RelatedInstance();
relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
RelatedInstance relatedLocalNetwork = new RelatedInstance();
relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
aaiVpnBinding.setVpnId("vpnBindingId");
org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
aaiLocalNetwork.setNetworkId("localNetworkId");
Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = Optional.of(new org.onap.aai.domain.yang.VpnBinding());
aaiAICVpnBindingOp.get().setVpnId("AICVpnBindingId");
ServiceProxy proxy = new ServiceProxy();
proxy.setType("transport");
proxy.setServiceInstance(new ServiceInstance());
proxy.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance());
proxy.getServiceInstance().getModelInfoServiceInstance().setModelUuid("sourceServiceModelUUID");
doReturn(relatedVpnBinding).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, ModelType.vpnBinding);
doReturn(relatedLocalNetwork).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, ModelType.network);
doReturn(aaiVpnBinding).when(SPY_bbInputSetupUtils).getAAIVpnBinding(relatedVpnBinding.getInstanceId());
doReturn(aaiLocalNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(relatedLocalNetwork.getInstanceId());
doReturn(aaiAICVpnBindingOp).when(SPY_bbInputSetupUtils).getAICVpnBindingFromNetwork(aaiLocalNetwork);
doReturn(proxy).when(SPY_bbInputSetup).getServiceProxy(service);
Configuration configuration = new Configuration();
configuration.setConfigurationId("configurationId");
gBB.getServiceInstance().getConfigurations().add(configuration);
List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
configurationCustList.add(configurationCust);
doNothing().when(SPY_bbInputSetup).populateConfiguration(any(BBInputSetupParameter.class));
gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(BBInputSetupParameter.class));
assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId");
assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId");
assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), "AICVpnBindingId");
assertEquals(gBB.getServiceInstance().getServiceProxies().get(0).getType(), "transport");
}
Aggregations