use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.
the class BBInputSetup method createServiceInstance.
protected ServiceInstance createServiceInstance(RequestDetails requestDetails, Project project, OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId) {
ServiceInstance serviceInstance = new ServiceInstance();
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
serviceInstance.setServiceInstanceId(serviceInstanceId);
if (requestDetails.getRequestInfo() != null) {
serviceInstance.setServiceInstanceName(requestDetails.getRequestInfo().getInstanceName());
}
serviceInstance.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
serviceInstance.setProject(project);
serviceInstance.setOwningEntity(owningEntity);
return serviceInstance;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.
the class BBInputSetupTest method testMapProject.
@Test
public void testMapProject() throws JsonProcessingException {
org.onap.aai.domain.yang.Project expectedAAI = new org.onap.aai.domain.yang.Project();
Project expected = new Project();
AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
doReturn(expected).when(bbInputSetupMapperLayer).mapAAIProject(isA(org.onap.aai.domain.yang.Project.class));
ServiceInstance serviceInstance = new ServiceInstance();
SPY_bbInputSetup.mapProject(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), serviceInstance);
assertEquals(expected, serviceInstance.getProject());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.
the class VfModuleCDSRequestProviderTest method testRequestPayloadForConfigDeployVfModule.
@Test
public void testRequestPayloadForConfigDeployVfModule() throws Exception {
// given
setScopeAndAction(VF_SCOPE, DEPLOY_ACTION);
ServiceInstance serviceInstance = createServiceInstance();
doReturn(serviceInstance).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID);
doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.GENERIC_VNF_ID);
doReturn(createVfModule()).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.VF_MODULE_ID);
doReturn(getUserParams()).when(extractServiceFromUserParameters).getServiceFromRequestUserParams(anyList());
doCallRealMethod().when(configureInstanceParamsForVfModule).populateInstanceParams(any(), any(), anyString(), anyString(), any());
// when
vfModuleCDSRequestProvider.setExecutionObject(buildingBlockExecution);
String payload = vfModuleCDSRequestProvider.buildRequestPayload(DEPLOY_ACTION).get();
// verify
ObjectMapper mapper = new ObjectMapper();
JsonNode payloadJson = mapper.readTree(payload);
JsonNode requestNode = payloadJson.findValue("configDeploy-request");
JsonNode propertiesNode = payloadJson.findValue("configDeploy-properties");
assertNotNull(payload);
assertTrue(verfiyJsonFromString(payload));
assertThat(requestNode.get("resolution-key").asText()).isEqualTo(VF_MODULE_NAME);
assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
assertThat(propertiesNode.get("vf-module-id").asText()).isEqualTo(VF_MODULE_ID);
assertThat(propertiesNode.get("vf-module-name").asText()).isEqualTo(VF_MODULE_NAME);
assertThat(propertiesNode.get("vf-module-customization-uuid").asText()).isEqualTo(VF_MODULE_CUSTOMIZATION_UUID);
assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.
the class VfModuleCDSRequestProviderTest method testRequestPayloadForConfigDeployVfModuleWithoutUserParams.
@Test
public void testRequestPayloadForConfigDeployVfModuleWithoutUserParams() throws Exception {
// given
setScopeAndActionWithoutUserParams(VF_SCOPE, DEPLOY_ACTION);
ServiceInstance serviceInstance = createServiceInstance();
doReturn(serviceInstance).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID);
doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.GENERIC_VNF_ID);
doReturn(createVfModule()).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.VF_MODULE_ID);
doReturn(getUserParams()).when(extractServiceFromUserParameters).getServiceFromRequestUserParams(anyList());
doCallRealMethod().when(configureInstanceParamsForVfModule).populateInstanceParams(any(), any(), anyString(), anyString(), any());
vfModuleCDSRequestProvider.setExecutionObject(buildingBlockExecution);
String payload = vfModuleCDSRequestProvider.buildRequestPayload(DEPLOY_ACTION).get();
// verify
ObjectMapper mapper = new ObjectMapper();
JsonNode payloadJson = mapper.readTree(payload);
JsonNode requestNode = payloadJson.findValue("configDeploy-request");
JsonNode propertiesNode = payloadJson.findValue("configDeploy-properties");
assertNotNull(payload);
assertTrue(verfiyJsonFromString(payload));
assertThat(requestNode.get("resolution-key").asText()).isEqualTo(VF_MODULE_NAME);
assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
assertThat(propertiesNode.get("vf-module-id").asText()).isEqualTo(VF_MODULE_ID);
assertThat(propertiesNode.get("vf-module-name").asText()).isEqualTo(VF_MODULE_NAME);
assertThat(propertiesNode.get("vf-module-customization-uuid").asText()).isEqualTo(VF_MODULE_CUSTOMIZATION_UUID);
assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.
the class VnfCDSRequestProviderTest method testBuildRequestPayloadAssignActionVnf.
@Test
public void testBuildRequestPayloadAssignActionVnf() throws Exception {
// given
setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
ServiceInstance instance = createServiceInstance();
doReturn(instance).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID);
doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.GENERIC_VNF_ID);
// when
vnfCDSRequestProvider.setExecutionObject(buildingBlockExecution);
String payload = vnfCDSRequestProvider.buildRequestPayload(ASSIGN_ACTION).get();
// verify
ObjectMapper mapper = new ObjectMapper();
JsonNode payloadJson = mapper.readTree(payload);
JsonNode requestNode = payloadJson.findValue("configAssign-request");
JsonNode propertiesNode = payloadJson.findValue("configAssign-properties");
assertNotNull(payload);
assertTrue(verfiyJsonFromString(payload));
assertThat(requestNode.get("resolution-key").asText()).isEqualTo(GENERIC_VNF_NAME);
assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
assertThat(propertiesNode.get("vnf-customization-uuid").asText()).isEqualTo(VNF_MODEL_CUSTOMIZATION_UUID);
}
Aggregations