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));
}
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);
}
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));
}
Aggregations