Search in sources :

Example 91 with ServiceInstance

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;
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 92 with 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());
}
Also used : Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 93 with ServiceInstance

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);
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 94 with ServiceInstance

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);
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 95 with ServiceInstance

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);
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)228 Test (org.junit.Test)118 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)110 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)84 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)70 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)61 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)54 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)53 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)51 HashMap (java.util.HashMap)50 Service (org.onap.so.db.catalog.beans.Service)46 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)40 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)38 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)37 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)35 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)33 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)33 File (java.io.File)31 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)25 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)24