Search in sources :

Example 11 with AbstractCDSPropertiesBean

use of org.onap.so.client.cds.beans.AbstractCDSPropertiesBean 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());
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) ControllerContext(org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 12 with AbstractCDSPropertiesBean

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

the class GenericPnfCDSProcessingDETest method testExecution_validPnf_action_executionObjectCreated.

@Test
public void testExecution_validPnf_action_executionObjectCreated() {
    try {
        // given
        ControllerContext controllerContext = new ControllerContext();
        controllerContext.setExecution(execution);
        controllerContext.setControllerActor("cds");
        controllerContext.setControllerAction(this.action);
        controllerContext.setControllerScope(this.scope);
        AbstractCDSPropertiesBean bean = new AbstractCDSPropertiesBean();
        doNothing().when(cdsDispather).constructExecutionServiceInputObject(execution);
        doNothing().when(cdsDispather).sendRequestToCDSClient(execution);
        doReturn(bean).when(generatePayloadForCds).buildCdsPropertiesBean(execution);
        // when
        Boolean isUnderstandable = controllerRunnable.understand(controllerContext);
        Boolean isReady = controllerRunnable.ready(controllerContext);
        controllerRunnable.prepare(controllerContext);
        controllerRunnable.run(controllerContext);
        // verify
        assertEquals(isUnderstandable, true);
        assertEquals(isReady, true);
        Object executionObject = execution.getVariable(EXECUTION_OBJECT);
        assertThat(executionObject).isNotNull();
        assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception thrown" + e.getMessage());
    }
}
Also used : ControllerContext(org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 13 with AbstractCDSPropertiesBean

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

the class ConfigAssignVnfTest method verifyConfigAssignPropertiesJsonContent.

private void verifyConfigAssignPropertiesJsonContent(BuildingBlockExecution buildingBlockExecution) throws Exception {
    AbstractCDSPropertiesBean abstractCDSPropertiesBean = buildingBlockExecution.getVariable("executionObject");
    String payload = abstractCDSPropertiesBean.getRequestObject();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode payloadJson = mapper.readTree(payload);
    JsonNode configAssignPropertiesNode = payloadJson.findValue("config-assign-properties");
    assertThat(configAssignPropertiesNode.size()).isEqualTo(THE_NUMBER_OF_EXPECTED_CONFIG_PROPERTIES);
    assertThat(configAssignPropertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
    assertThat(configAssignPropertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
    assertThat(configAssignPropertiesNode.get("vnf-name").asText()).isEqualTo(GENERIC_VNF_NAME);
    assertThat(configAssignPropertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
    assertThat(configAssignPropertiesNode.get("vnf-customization-uuid").asText()).isEqualTo(VNF_MODEL_CUSTOMIZATION_ID);
    assertThat(configAssignPropertiesNode.has(INSTANCE_PARAM1_NAME)).isTrue();
    assertThat(configAssignPropertiesNode.get(INSTANCE_PARAM1_NAME).asText()).isEqualTo(INSTANCE_PARAM1_VALUE);
    assertThat(configAssignPropertiesNode.has(INSTANCE_PARAM2_NAME)).isTrue();
    assertThat(configAssignPropertiesNode.get(INSTANCE_PARAM2_NAME).asText()).isEqualTo(INSTANCE_PARAM2_VALUE);
    assertThat(configAssignPropertiesNode.has(INSTANCE_PARAM3_NAME)).isTrue();
    assertThat(configAssignPropertiesNode.get(INSTANCE_PARAM3_NAME).asText()).isEqualTo(INSTANCE_PARAM3_VALUE);
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with AbstractCDSPropertiesBean

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

the class GeneratePayloadForCdsTest method testBuildCdsPropertiesBeanDeployVnf.

@Test
public void testBuildCdsPropertiesBeanDeployVnf() throws Exception {
    // given
    final String deployPayload = "{\"configDeploy-request\":{\"resolution-key\":\"vnf-name-1\",\"configDeploy-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, DEPLOY_ACTION);
    doReturn(Optional.of(deployPayload)).when(vnfCDSRequestProvider).buildRequestPayload(DEPLOY_ACTION);
    // when
    AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
    // verify
    assertNotNull(propertyBean);
    String payload = propertyBean.getRequestObject();
    assertThat(deployPayload.equals(payload));
    assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
    assertThat(propertyBean.getOriginatorId().equals("SO"));
    assertNotNull(propertyBean.getSubRequestId());
    assertThat(propertyBean.getActionName().equals(DEPLOY_ACTION));
    assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) Test(org.junit.Test)

Example 15 with AbstractCDSPropertiesBean

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

the class GeneratePayloadForCdsTest method testBuildCdsPropertiesBeanConfigDeployVfModule.

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

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