Search in sources :

Example 16 with Configuration

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");
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnf(org.onap.aai.domain.yang.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 17 with Configuration

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.");
    }
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) Mockito.anyString(org.mockito.Mockito.anyString) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) ExpectedException(org.junit.rules.ExpectedException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Relationship(org.onap.aai.domain.yang.Relationship) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 18 with Configuration

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();
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Test(org.junit.Test)

Example 19 with Configuration

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);
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Test(org.junit.Test)

Example 20 with Configuration

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));
}
Also used : ModelInfoConfiguration(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ModelInfoConfiguration(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration) Test(org.junit.Test)

Aggregations

Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)41 Test (org.junit.Test)23 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)13 ArrayList (java.util.ArrayList)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)11 ModelInfoConfiguration (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)9 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)8 Service (org.onap.so.db.catalog.beans.Service)8 File (java.io.File)7 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)7 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)7 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)6 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)6 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)6 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)6 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)6 GenericVnf (org.onap.aai.domain.yang.GenericVnf)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)5