Search in sources :

Example 71 with ExecuteBuildingBlock

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();
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) Before(org.junit.Before)

Example 72 with 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);
    }
}
Also used : HealthcheckInstanceResponse(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceResponse) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) StatusCheckInstanceResponse(org.onap.so.client.adapter.cnf.entities.StatusCheckInstanceResponse) HealthcheckResponse(org.onap.so.client.adapter.cnf.entities.HealthcheckResponse) ArrayList(java.util.ArrayList) List(java.util.List) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) StatusCheckResponse(org.onap.so.client.adapter.cnf.entities.StatusCheckResponse)

Example 73 with ExecuteBuildingBlock

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);
}
Also used : ONAPComponents(org.onap.logging.filter.base.ONAPComponents) HealthcheckInstanceResponse(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceResponse) StatusCheckInstanceResponse(org.onap.so.client.adapter.cnf.entities.StatusCheckInstanceResponse) HealthcheckInstanceRequest(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceRequest) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StatusCheckResponse(org.onap.so.client.adapter.cnf.entities.StatusCheckResponse) ArrayList(java.util.ArrayList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Logger(org.slf4j.Logger) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) HealthcheckResponse(org.onap.so.client.adapter.cnf.entities.HealthcheckResponse) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) HealthcheckInstance(org.onap.so.client.adapter.cnf.entities.HealthcheckInstance) List(java.util.List) Component(org.springframework.stereotype.Component) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Optional(java.util.Optional) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) HealthcheckInstanceRequest(org.onap.so.client.adapter.cnf.entities.HealthcheckInstanceRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 74 with ExecuteBuildingBlock

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();
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) Test(org.junit.Test)

Example 75 with ExecuteBuildingBlock

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");
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ModelInfoServiceProxy(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) Test(org.junit.Test)

Aggregations

ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)147 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)86 List (java.util.List)65 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)63 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)61 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)49 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)45 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)45 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)41 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)40 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)40 File (java.io.File)38 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)38 RelationshipList (org.onap.aai.domain.yang.RelationshipList)38 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)37 Service (org.onap.so.db.catalog.beans.Service)35 HashMap (java.util.HashMap)27 VfModule (org.onap.aai.domain.yang.VfModule)25 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)24