Search in sources :

Example 11 with NetworkCollectionResourceCustomization

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

the class UserParamsServiceTraversalTest method getResourceListFromUserParamsForNetworks.

@Test
public void getResourceListFromUserParamsForNetworks() throws Exception {
    requestAction = "createInstance";
    initExecution(requestAction, readBpmnRequestFromFile(NETWORK_COLLECTION_JSON), false);
    Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString());
    Mockito.doReturn(getService()).when(mockCatalogDbClient).getServiceByID(anyString());
    Mockito.doReturn(new NetworkCollectionResourceCustomization()).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID(anyString());
    List<Resource> resourceListFromUserParams = userParamsServiceTraversal.getResourceListFromUserParams(execution, getUserParams(), serviceInstanceId, requestAction);
    List<WorkflowType> expected = List.of(WorkflowType.SERVICE, WorkflowType.NETWORK, WorkflowType.NETWORK, WorkflowType.NETWORKCOLLECTION);
    List<WorkflowType> result = resourceListFromUserParams.stream().map(Resource::getResourceType).collect(Collectors.toList());
    assertEquals(4, resourceListFromUserParams.size());
    assertThat(expected, is(result));
}
Also used : NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) WorkflowType(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 12 with NetworkCollectionResourceCustomization

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

the class BBInputSetupTest method testPopulateNetworkCollectionAndInstanceGroupAssign.

@Test
public void testPopulateNetworkCollectionAndInstanceGroupAssign() throws Exception {
    Service service = Mockito.mock(Service.class);
    String key = "collectionCustId";
    ServiceInstance serviceInstance = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), ServiceInstance.class);
    String resourceId = "123";
    Collection collection = SPY_bbInputSetup.createCollection(resourceId);
    InstanceGroup instanceGroup = SPY_bbInputSetup.createInstanceGroup();
    assertNull(serviceInstance.getCollection());
    doReturn(true).when(SPY_bbInputSetup).isVlanTagging(service, key);
    doReturn(collection).when(SPY_bbInputSetup).createCollection(resourceId);
    doReturn(instanceGroup).when(SPY_bbInputSetup).createInstanceGroup();
    doNothing().when(SPY_bbInputSetup).mapCatalogCollection(service, collection, key);
    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("NetworkCollectionResource");
    networkCollection.getCollectionResource().getInstanceGroup().setType(InstanceGroupType.L3_NETWORK);
    networkCollection.getCollectionResource().getInstanceGroup().setCollectionInstanceGroupCustomizations(new ArrayList<>());
    List<CollectionResourceCustomization> customizations = new ArrayList<>();
    customizations.add(networkCollection);
    doReturn(customizations).when(service).getCollectionResourceCustomizations();
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setService(service).setServiceInstance(serviceInstance).setResourceId(resourceId).setKey(key).setBbName(AssignFlows.NETWORK_COLLECTION.toString()).build();
    SPY_bbInputSetup.populateNetworkCollectionAndInstanceGroupAssign(parameter);
    assertNotNull(serviceInstance.getCollection());
    assertNotNull(serviceInstance.getCollection().getInstanceGroup());
    verify(SPY_bbInputSetup, times(1)).mapCatalogCollection(service, serviceInstance.getCollection(), key);
    verify(SPY_bbInputSetup, times(1)).mapCatalogNetworkCollectionInstanceGroup(service, serviceInstance.getCollection().getInstanceGroup(), key);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) 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) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) File(java.io.File) Test(org.junit.Test)

Example 13 with NetworkCollectionResourceCustomization

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

the class BBInputSetupTest method testMapCatalogCollectionAndInstanceGroup.

@Test
public void testMapCatalogCollectionAndInstanceGroup() {
    ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
    modelInfoCollection.setCollectionFunction("collectionFunction");
    modelInfoCollection.setCollectionRole("collectionRole");
    modelInfoCollection.setCollectionType("collectionType");
    modelInfoCollection.setDescription("description");
    modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
    modelInfoCollection.setQuantity(0);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setFunction("function");
    modelInfoInstanceGroup.setInstanceGroupRole("instanceGroupRole");
    modelInfoInstanceGroup.setModelInvariantUUID("modelInvariantUUID");
    modelInfoInstanceGroup.setModelUUID("modelUUID");
    modelInfoInstanceGroup.setType("VNFC");
    modelInfoInstanceGroup.setDescription("description");
    InstanceGroup instanceGroup = new InstanceGroup();
    Collection collection = new Collection();
    collection.setInstanceGroup(instanceGroup);
    CollectionResource collectionResource = new CollectionResource();
    org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
    collectionResource.setToscaNodeType("NetworkCollection");
    collectionResource.setInstanceGroup(catalogInstanceGroup);
    CollectionResourceCustomization collectionCust = new NetworkCollectionResourceCustomization();
    collectionCust.setModelCustomizationUUID("modelCustomizationUUID");
    collectionCust.setCollectionResource(collectionResource);
    Service service = new Service();
    service.getCollectionResourceCustomizations().add(collectionCust);
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setCollection(collection);
    List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization instanceGroupCust = new CollectionResourceInstanceGroupCustomization();
    instanceGroupCust.setFunction("function");
    instanceGroupCust.setDescription("description");
    doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust, collectionResource);
    doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup);
    SPY_bbInputSetup.mapCatalogCollection(service, serviceInstance.getCollection(), "modelCustomizationUUID");
    SPY_bbInputSetup.mapCatalogNetworkCollectionInstanceGroup(service, serviceInstance.getCollection().getInstanceGroup(), collectionCust.getModelCustomizationUUID());
    assertThat(collection.getModelInfoCollection(), sameBeanAs(modelInfoCollection));
    assertThat(instanceGroup.getModelInfoInstanceGroup(), sameBeanAs(modelInfoInstanceGroup));
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Test(org.junit.Test)

Aggregations

NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)13 Test (org.junit.Test)11 Service (org.onap.so.db.catalog.beans.Service)8 ArrayList (java.util.ArrayList)7 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)6 CollectionResourceCustomization (org.onap.so.db.catalog.beans.CollectionResourceCustomization)6 CollectionResourceInstanceGroupCustomization (org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization)5 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)4 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)3 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)3 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)3 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)3 CollectionNetworkResourceCustomization (org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)3 InstanceGroup (org.onap.so.db.catalog.beans.InstanceGroup)3 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)2 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1