use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleFabricDeleteTest.
@Test
public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception {
String gAction = "deleteInstance";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
vnf.setVnfId("vnf0");
vnf.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
vfModule.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
vnfc.setModelInvariantId("modelInvariantId");
vnfc.setVnfcName("testVnfcName");
vnfcs.add(vnfc);
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
configuration.setConfigurationId("configurationId");
configuration.setModelCustomizationId("modelCustimizationId");
configuration.setConfigurationName("testConfigurationName");
doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
SPY_workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.
the class ServiceEBBLoaderTest method traverseAAIServiceTest.
@Test
public void traverseAAIServiceTest() {
List<Resource> resourceCounter = new ArrayList<>();
String resourceId = "si0";
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId(resourceId);
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance();
GenericVnf genericVnf = setGenericVnf();
setVfModule(true);
setVolumeGroup();
setL3Network();
setCollection();
setConfiguration();
org.onap.aai.domain.yang.GenericVnf genericVnfAai = new org.onap.aai.domain.yang.GenericVnf();
genericVnfAai.setModelCustomizationId(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid());
Configuration config = new Configuration();
config.setConfigurationId("testConfigurationId2");
serviceInstance.getConfigurations().add(config);
Relationship relationship1 = new Relationship();
relationship1.setRelatedTo("vnfc");
RelationshipList relationshipList1 = new RelationshipList();
relationshipList1.getRelationship().add(relationship1);
Relationship relationship2 = new Relationship();
relationship2.setRelatedTo("vpn-binding");
RelationshipList relationshipList2 = new RelationshipList();
relationshipList2.getRelationship().add(relationship2);
org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration();
aaiConfiguration1.setConfigurationId("testConfigurationId");
aaiConfiguration1.setRelationshipList(relationshipList1);
org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration();
aaiConfiguration2.setConfigurationId("testConfigurationId2");
aaiConfiguration2.setRelationshipList(relationshipList1);
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setIsBaseVfModule(true);
try {
doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId());
doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId);
doReturn(serviceInstance).when(mockBbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(Optional.of(aaiConfiguration1)).when(mockAaiConfigurationResources).getConfiguration("testConfigurationId");
doReturn(Optional.of(aaiConfiguration2)).when(mockAaiConfigurationResources).getConfiguration("testConfigurationId2");
doReturn(aaiVfModule).when(mockBbInputSetupUtils).getAAIVfModule(any(), any());
serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
assertEquals(8, resourceCounter.size());
assertTrue(resourceCounter.get(2).isBaseVfModule());
assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds()));
} catch (Exception e) {
fail("Unexpected exception was thrown.");
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.
the class WorkflowActionExtractResourcesAAITest method extractRelationshipsConfiguration_notFound_listEmpty.
@Test
public void extractRelationshipsConfiguration_notFound_listEmpty() {
// given
Relationships relationships = mock(Relationships.class);
when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList());
// when
Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
// then
assertThat(resultOpt).isEmpty();
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.
the class WorkflowActionExtractResourcesAAITest method extractRelationshipsConfigurationSuccess.
@Test
public void extractRelationshipsConfigurationSuccess() {
// given
Relationships relationships = mock(Relationships.class);
when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}"));
// when
Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
// then
assertThat(resultOpt).isNotEmpty();
assertThat(resultOpt.get().getConfigurationId()).isEqualTo(CONFIGURATION_ID);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration in project so by onap.
the class AAIObjectMapperTest method mapConfigurationTest.
@Test
public void mapConfigurationTest() {
Configuration configuration = new Configuration();
configuration.setConfigurationId("configId");
configuration.setConfigurationName("VNR");
configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
configuration.setManagementOption("managementOption");
ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
modelInfoConfiguration.setModelCustomizationId("modelCustId");
modelInfoConfiguration.setModelInvariantId("modelInvariantId");
modelInfoConfiguration.setModelVersionId("modelVersionId");
modelInfoConfiguration.setConfigurationType("5G");
modelInfoConfiguration.setConfigurationRole("ConfigurationRole");
configuration.setModelInfoConfiguration(modelInfoConfiguration);
org.onap.aai.domain.yang.Configuration expectedConfiguration = new org.onap.aai.domain.yang.Configuration();
expectedConfiguration.setConfigurationId(configuration.getConfigurationId());
expectedConfiguration.setConfigurationName(configuration.getConfigurationName());
expectedConfiguration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
expectedConfiguration.setOrchestrationStatus(configuration.getOrchestrationStatus().toString());
expectedConfiguration.setManagementOption(configuration.getManagementOption());
expectedConfiguration.setModelInvariantId(configuration.getModelInfoConfiguration().getModelInvariantId());
expectedConfiguration.setModelVersionId(configuration.getModelInfoConfiguration().getModelVersionId());
expectedConfiguration.setModelCustomizationId(configuration.getModelInfoConfiguration().getModelCustomizationId());
expectedConfiguration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
expectedConfiguration.setConfigPolicyName(configuration.getModelInfoConfiguration().getPolicyName());
org.onap.aai.domain.yang.Configuration actualConfiguration = aaiObjectMapper.mapConfiguration(configuration);
assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
}
Aggregations