Search in sources :

Example 16 with AbstractCDSPropertiesBean

use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.

the class GeneratePayloadForCdsTest method testBuildCdsPropertiesBeanCreateService.

@Test
public void testBuildCdsPropertiesBeanCreateService() throws Exception {
    // given
    final String servicePayload = "{\"create-request\":{\"resolution-key\":\"test-service-instance\",\"create-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\"}}}";
    setScopeAndAction(SERVICE_SCOPE, SERVICE_ACTION);
    doReturn(Optional.of(servicePayload)).when(serviceCDSRequestProvider).buildRequestPayload(SERVICE_ACTION);
    // when
    AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
    // verify
    assertNotNull(propertyBean);
    String payload = propertyBean.getRequestObject();
    assertThat(servicePayload.equals(payload));
    assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
    assertThat(propertyBean.getOriginatorId().equals("SO"));
    assertNotNull(propertyBean.getSubRequestId());
    assertThat(propertyBean.getActionName().equals(SERVICE_ACTION));
    assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) Test(org.junit.Test)

Example 17 with AbstractCDSPropertiesBean

use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.

the class GenericCDSProcessingBB method prepare.

@Override
public void prepare(ControllerContext<BuildingBlockExecution> context) {
    BuildingBlockExecution buildingBlockExecution = context.getExecution();
    try {
        AbstractCDSPropertiesBean abstractCDSPropertiesBean = generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
        buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
    } catch (Exception ex) {
        logger.error("An exception occurred when creating payload for CDS request", ex);
        exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex);
    }
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)

Example 18 with AbstractCDSPropertiesBean

use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.

the class ConfigAssignVnf method preProcessAbstractCDSProcessing.

/**
 * Getting the vnf data, blueprint name, blueprint version etc and setting them in execution object and calling the
 * subprocess.
 */
public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
    logger.info("Start preProcessAbstractCDSProcessing ");
    try {
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        ConfigAssignPropertiesForVnf configAssignPropertiesForVnf = new ConfigAssignPropertiesForVnf();
        configAssignPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
        configAssignPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
        configAssignPropertiesForVnf.setVnfCustomizationUuid(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid());
        configAssignPropertiesForVnf.setVnfId(genericVnf.getVnfId());
        configAssignPropertiesForVnf.setVnfName(genericVnf.getVnfName());
        setUserParamsInConfigAssignPropertiesForVnf(configAssignPropertiesForVnf, execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams(), genericVnf);
        ConfigAssignRequestVnf configAssignRequestVnf = new ConfigAssignRequestVnf();
        configAssignRequestVnf.setResolutionKey(genericVnf.getVnfName());
        configAssignRequestVnf.setConfigAssignPropertiesForVnf(configAssignPropertiesForVnf);
        String blueprintName = genericVnf.getModelInfoGenericVnf().getBlueprintName();
        String blueprintVersion = genericVnf.getModelInfoGenericVnf().getBlueprintVersion();
        logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion);
        AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
        abstractCDSPropertiesBean.setBlueprintName(blueprintName);
        abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
        abstractCDSPropertiesBean.setRequestObject(configAssignRequestVnf.toString());
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
        abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
        abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
        abstractCDSPropertiesBean.setActionName(ACTION_NAME);
        abstractCDSPropertiesBean.setMode(MODE);
        execution.setVariable("executionObject", abstractCDSPropertiesBean);
    } catch (Exception ex) {
        logger.error("An exception occurred when creating ConfigAssignPropertiesForVnf for CDS request", ex);
        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ConfigAssignPropertiesForVnf(org.onap.so.client.cds.beans.ConfigAssignPropertiesForVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ConfigAssignRequestVnf(org.onap.so.client.cds.beans.ConfigAssignRequestVnf) IOException(java.io.IOException) VnfNotFoundException(org.onap.so.bpmn.infrastructure.flowspecific.exceptions.VnfNotFoundException)

Example 19 with AbstractCDSPropertiesBean

use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.

the class ConfigDeployVnf method preProcessAbstractCDSProcessing.

/**
 * Getting the vnf object and set in execution object
 *
 * @param execution
 */
public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
    logger.info("Start preProcessAbstractCDSProcessing");
    try {
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf();
        configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
        configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
        configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
        configDeployPropertiesForVnf.setVnfId(vnf.getVnfId());
        configDeployPropertiesForVnf.setVnfName(vnf.getVnfName());
        ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf();
        configDeployRequestVnf.setResolutionKey(vnf.getVnfName());
        configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf);
        String blueprintName = vnf.getModelInfoGenericVnf().getBlueprintName();
        String blueprintVersion = vnf.getModelInfoGenericVnf().getBlueprintVersion();
        logger.debug(" BlueprintName : " + blueprintName + " BlueprintVersion : " + blueprintVersion);
        AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
        abstractCDSPropertiesBean.setBlueprintName(blueprintName);
        abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
        abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
        abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
        abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
        abstractCDSPropertiesBean.setActionName(ACTION_NAME);
        abstractCDSPropertiesBean.setMode(MODE);
        execution.setVariable("executionObject", abstractCDSPropertiesBean);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ConfigDeployPropertiesForVnf(org.onap.so.client.cds.beans.ConfigDeployPropertiesForVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ConfigDeployRequestVnf(org.onap.so.client.cds.beans.ConfigDeployRequestVnf)

Example 20 with AbstractCDSPropertiesBean

use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean in project so by onap.

the class GenericPnfCDSControllerRunnableBB method prepareAndSetCdsPropertyBean.

private AbstractCDSPropertiesBean prepareAndSetCdsPropertyBean(BuildingBlockExecution buildingBlockExecution) {
    final AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
    final String action = getAction(buildingBlockExecution);
    if (action == null) {
        exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, "Action is null!", ONAPComponents.SO);
    }
    abstractCDSPropertiesBean.setRequestObject(this.buildRequestPayload(action, buildingBlockExecution));
    abstractCDSPropertiesBean.setBlueprintName(buildingBlockExecution.getVariable(PRC_BLUEPRINT_NAME));
    abstractCDSPropertiesBean.setBlueprintVersion(buildingBlockExecution.getVariable(PRC_BLUEPRINT_VERSION));
    abstractCDSPropertiesBean.setRequestId(buildingBlockExecution.getVariable(MSO_REQUEST_ID));
    abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
    abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
    abstractCDSPropertiesBean.setActionName(action);
    abstractCDSPropertiesBean.setMode(DEFAULT_SYNC_MODE);
    return abstractCDSPropertiesBean;
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)

Aggregations

AbstractCDSPropertiesBean (org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)20 Test (org.junit.Test)8 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)2 ExecutionServiceInput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 ControllerContext (org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext)2 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)2 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)2 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)2 PreconditionFailedException (org.onap.so.client.PreconditionFailedException)2 BadResponseException (org.onap.so.client.exception.BadResponseException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 JSONObject (org.json.JSONObject)1 VnfNotFoundException (org.onap.so.bpmn.infrastructure.flowspecific.exceptions.VnfNotFoundException)1 ConfigAssignPropertiesForVnf (org.onap.so.client.cds.beans.ConfigAssignPropertiesForVnf)1 ConfigAssignRequestVnf (org.onap.so.client.cds.beans.ConfigAssignRequestVnf)1