Search in sources :

Example 1 with CollectionResource

use of org.onap.so.db.catalog.beans.CollectionResource in project so by onap.

the class BBInputSetupTest method testMapCollection.

@Test
public void testMapCollection() throws JsonProcessingException {
    List<AAIResultWrapper> collections = new ArrayList<>();
    ServiceInstance serviceInstance = new ServiceInstance();
    org.onap.aai.domain.yang.Collection aaiCollection = new org.onap.aai.domain.yang.Collection();
    org.onap.aai.domain.yang.RelationshipList collectionRelationshipList = new org.onap.aai.domain.yang.RelationshipList();
    org.onap.aai.domain.yang.Relationship collectionInstanceGroupRelationship = new org.onap.aai.domain.yang.Relationship();
    collectionRelationshipList.getRelationship().add(collectionInstanceGroupRelationship);
    aaiCollection.setRelationshipList(collectionRelationshipList);
    collections.add(new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiCollection)));
    Collection collection = new Collection();
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    List<InstanceGroup> instanceGroupsList = new ArrayList<>();
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroupsList.add(instanceGroup);
    NetworkCollectionResourceCustomization networkCollectionCust = Mockito.mock(NetworkCollectionResourceCustomization.class);
    CollectionResource collectionResource = new CollectionResource();
    doReturn(collection).when(bbInputSetupMapperLayer).mapAAICollectionIntoCollection(isA(org.onap.aai.domain.yang.Collection.class));
    doReturn(instanceGroupsList).when(SPY_bbInputSetup).mapInstanceGroups(any());
    doReturn(networkCollectionCust).when(SPY_bbInputSetupUtils).getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
    doReturn(collectionResource).when(networkCollectionCust).getCollectionResource();
    doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(networkCollectionCust, collectionResource);
    SPY_bbInputSetup.mapCollection(collections, serviceInstance);
    assertEquals(collection, serviceInstance.getCollection());
    assertEquals(instanceGroup, collection.getInstanceGroup());
    instanceGroupsList.clear();
    collection = new Collection();
    SPY_bbInputSetup.mapCollection(collections, serviceInstance);
    assertEquals(collection, serviceInstance.getCollection());
    assertNull(collection.getInstanceGroup());
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 2 with CollectionResource

use of org.onap.so.db.catalog.beans.CollectionResource in project so by onap.

the class BBInputSetupTest method testIsVlanTagging.

@Test
public void testIsVlanTagging() throws Exception {
    boolean expected = true;
    Service service = Mockito.mock(Service.class);
    String key = "collectionCustId";
    NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
    networkCollection.setModelCustomizationUUID(key);
    networkCollection.setCollectionResource(new CollectionResource());
    networkCollection.getCollectionResource().setInstanceGroup(new org.onap.so.db.catalog.beans.InstanceGroup());
    networkCollection.getCollectionResource().getInstanceGroup().setToscaNodeType("org.openecomp.resource.cr.NetworkCollectionResource1806");
    List<CollectionResourceCustomization> customizations = new ArrayList<>();
    customizations.add(networkCollection);
    doReturn(customizations).when(service).getCollectionResourceCustomizations();
    boolean actual = SPY_bbInputSetup.isVlanTagging(service, key);
    assertEquals("Is Vlan Tagging check.", expected, actual);
}
Also used : NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Test(org.junit.Test)

Example 3 with CollectionResource

use of org.onap.so.db.catalog.beans.CollectionResource in project so by onap.

the class BBInputSetupMapperLayerTest method testMapCatalogCollectionToCollection.

@Test
public void testMapCatalogCollectionToCollection() throws IOException {
    ModelInfoCollection expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
    CollectionResourceCustomization collectionCust = mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"), CollectionResourceCustomization.class);
    CollectionResource collectionResource = mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
    ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
    assertThat(actual, sameBeanAs(expected));
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) File(java.io.File) Test(org.junit.Test)

Example 4 with CollectionResource

use of org.onap.so.db.catalog.beans.CollectionResource in project so by onap.

the class WorkflowActionTest method selectExecutionListServiceMacroCreateWithNetworkCollectionTest.

@Test
public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception {
    String gAction = "createInstance";
    String resource = "Service";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v6/serviceInstances/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    northBoundRequest.setIsToplevelflow(true);
    List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    Service service = new Service();
    List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
    NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
    networkCust.setModelCustomizationUUID("123");
    networkCustomizations.add(networkCust);
    service.setNetworkCustomizations(networkCustomizations);
    NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
    collectionResourceCustomization.setModelCustomizationUUID("123");
    CollectionResource collectionResource = new CollectionResource();
    collectionResource.setToscaNodeType("NetworkCollection");
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setToscaNodeType("NetworkCollectionResource");
    instanceGroup.setCollectionNetworkResourceCustomizations(new ArrayList<>());
    CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
    collectionNetworkResourceCust.setModelCustomizationUUID("123");
    collectionNetworkResourceCust.setNetworkResourceCustomization(collectionResourceCustomization);
    instanceGroup.getCollectionNetworkResourceCustomizations().add(collectionNetworkResourceCust);
    List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
    collectionInstanceGroupCustomization.setModelCustomizationUUID("123");
    collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
    collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
    collectionInstanceGroupCustomization.setInstanceGroup(instanceGroup);
    collectionInstanceGroupCustomization.setCollectionResourceCust(collectionResourceCustomization);
    instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
    collectionResource.setInstanceGroup(instanceGroup);
    collectionResourceCustomization.setCollectionResource(collectionResource);
    ;
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
    doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
    assertEquals("Network id not empty", !ebbs.get(2).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id not empty", !ebbs.get(4).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB", ebbs.get(2).getWorkflowResourceIds().getNetworkId() == ebbs.get(3).getWorkflowResourceIds().getNetworkId() && ebbs.get(3).getWorkflowResourceIds().getNetworkId() == ebbs.get(4).getWorkflowResourceIds().getNetworkId(), true);
    assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id not empty", !ebbs.get(7).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB", ebbs.get(5).getWorkflowResourceIds().getNetworkId() == ebbs.get(6).getWorkflowResourceIds().getNetworkId() && ebbs.get(6).getWorkflowResourceIds().getNetworkId() == ebbs.get(7).getWorkflowResourceIds().getNetworkId(), true);
    assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id not empty", !ebbs.get(10).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
    assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB", ebbs.get(8).getWorkflowResourceIds().getNetworkId() == ebbs.get(9).getWorkflowResourceIds().getNetworkId() && ebbs.get(9).getWorkflowResourceIds().getNetworkId() == ebbs.get(10).getWorkflowResourceIds().getNetworkId(), true);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Service(org.onap.so.db.catalog.beans.Service) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 5 with CollectionResource

use of org.onap.so.db.catalog.beans.CollectionResource in project so by onap.

the class ServiceEBBLoaderTest method traverseCatalogDbServiceMultipleNetworkTest.

@Test
public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException {
    execution.setVariable("testProcessKey", "testProcessKeyValue");
    Service service = new Service();
    List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
    NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
    networkCust.setModelCustomizationUUID("123");
    networkCustomizations.add(networkCust);
    service.setNetworkCustomizations(networkCustomizations);
    NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
    collectionResourceCustomization.setModelCustomizationUUID("123");
    CollectionResource collectionResource = new CollectionResource();
    collectionResource.setToscaNodeType("NetworkCollection");
    InstanceGroup instanceGroup = new InstanceGroup();
    List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
    collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
    collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
    instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
    collectionResource.setInstanceGroup(instanceGroup);
    collectionResourceCustomization.setCollectionResource(collectionResource);
    ;
    service.setModelUUID("abc");
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    doReturn(service).when(mockCatalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
    doReturn(collectionResourceCustomization).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
    List<Resource> resource = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    serviceEBBLoader.traverseCatalogDbService(execution, sIRequest, resource, aaiResourceIds);
    assertEquals(resource.size(), 2);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Service(org.onap.so.db.catalog.beans.Service) Mockito.anyString(org.mockito.Mockito.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)9 Service (org.onap.so.db.catalog.beans.Service)7 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)6 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)4 ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)4 CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)4 List (java.util.List)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)3 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)3 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)3 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)3 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)3