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());
}
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());
}
}
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);
}
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"));
}
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"));
}
Aggregations