Search in sources :

Example 1 with AbstractCDSPropertiesBean

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

the class GenericPnfCDSProcessingDE method prepare.

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

Example 2 with AbstractCDSPropertiesBean

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

the class GenericPnfCDSControllerRunnableBB method prepare.

@Override
public void prepare(ControllerContext<BuildingBlockExecution> controllerContext) {
    BuildingBlockExecution buildingBlockExecution = controllerContext.getExecution();
    final AbstractCDSPropertiesBean abstractCDSPropertiesBean = prepareAndSetCdsPropertyBean(buildingBlockExecution);
    buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)

Example 3 with AbstractCDSPropertiesBean

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

the class GeneratePayloadForCdsTest method testBuildCdsPropertiesBeanDownloadPnf.

@Test
public void testBuildCdsPropertiesBeanDownloadPnf() throws Exception {
    // given
    final String downloadPayload = "{\"downloadNeSw-request\":{\"resolution-key\":\"PNFDemo\",\"downloadNeSw-properties\":{\"service-instance-id\":\"test_service_id\",\"service-model-uuid\":\"6bc0b04d-1873-4721-b53d-6615225b2a28\",\"pnf-id\":\"5df8b6de-2083-11e7-93ae-92361f002671\",\"pnf-name\":\"PNFDemo\",\"pnf-customization-uuid\":\"9acb3a83-8a52-412c-9a45-901764938144\",\"target-software-version\":\"demo-sw-ver2.0.0\"}}}";
    DelegateExecution execution = prepareDelegateExecutionObj(PayloadConstants.PNF_SCOPE, DOWNLOAD_ACTION);
    doReturn(Optional.of(downloadPayload)).when(pnfCDSRequestProvider).buildRequestPayload(DOWNLOAD_ACTION);
    doReturn(TEST_PNF_RESOURCE_BLUEPRINT_NAME).when(pnfCDSRequestProvider).getBlueprintName();
    doReturn(TEST_PNF_RESOURCE_BLUEPRINT_VERSION).when(pnfCDSRequestProvider).getBlueprintVersion();
    // when
    AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(execution);
    // verify
    assertNotNull(propertyBean);
    String payload = propertyBean.getRequestObject();
    assertThat(downloadPayload.equals(payload));
    assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
    assertThat(propertyBean.getOriginatorId().equals("SO"));
    assertNotNull(propertyBean.getSubRequestId());
    assertThat(propertyBean.getActionName().equals(DOWNLOAD_ACTION));
    assertThat(propertyBean.getMode().equalsIgnoreCase("async"));
    assertThat(propertyBean.getBlueprintName().equalsIgnoreCase(TEST_PNF_RESOURCE_BLUEPRINT_NAME));
    assertThat(propertyBean.getBlueprintVersion().equalsIgnoreCase(TEST_PNF_RESOURCE_BLUEPRINT_VERSION));
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Test(org.junit.Test)

Example 4 with AbstractCDSPropertiesBean

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

the class GeneratePayloadForCdsTest method testBuildCdsPropertiesBeanAssignVnf.

@Test
public void testBuildCdsPropertiesBeanAssignVnf() throws Exception {
    // given
    final String assignPayload = "{\"configAssign-request\":{\"resolution-key\":\"vnf-name-1\",\"configAssign-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\",\"vnf-id\":\"vnfId_configVnfTest1\",\"vnf-name\":\"vnf-name-1\",\"vnf-customization-uuid\":\"23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4\",\"acl-cloud-region\":\"acl-cloud-region\",\"public_net_id\":\"public-net-id\"}}}";
    setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
    doReturn(Optional.of(assignPayload)).when(vnfCDSRequestProvider).buildRequestPayload(ASSIGN_ACTION);
    // when
    AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
    // verify
    assertNotNull(propertyBean);
    String payload = propertyBean.getRequestObject();
    assertThat(assignPayload.equals(payload));
    assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
    assertThat(propertyBean.getOriginatorId().equals("SO"));
    assertNotNull(propertyBean.getSubRequestId());
    assertThat(propertyBean.getActionName().equals(ASSIGN_ACTION));
    assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) Test(org.junit.Test)

Example 5 with AbstractCDSPropertiesBean

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

the class GenericCDSProcessingBBTest method prepareCDSBean.

private AbstractCDSPropertiesBean prepareCDSBean() {
    AbstractCDSPropertiesBean cdsBean = new AbstractCDSPropertiesBean();
    cdsBean.setBlueprintName(BLUEPRINT_NAME);
    cdsBean.setBlueprintVersion(BLUEPRINT_VERSION);
    cdsBean.setRequestId(TEST_MSO_REQUEST_ID);
    cdsBean.setRequestObject("requestObject");
    return cdsBean;
}
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