Search in sources :

Example 1 with ControllerContext

use of org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext 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 2 with ControllerContext

use of org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext 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)

Aggregations

Test (org.junit.Test)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 ControllerContext (org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext)2 AbstractCDSPropertiesBean (org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)2 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)1