use of org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization 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());
}
use of org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization 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);
}
use of org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization in project so by onap.
the class BBInputSetup method getCollection.
private Collection getCollection(org.onap.aai.domain.yang.Collection aaiCollection) {
Collection collection = this.mapperLayer.mapAAICollectionIntoCollection(aaiCollection);
NetworkCollectionResourceCustomization collectionResourceCust = bbInputSetupUtils.getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
collection.setModelInfoCollection(mapperLayer.mapCatalogCollectionToCollection(collectionResourceCust, collectionResourceCust.getCollectionResource()));
return collection;
}
use of org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization in project so by onap.
the class NetworkCollectionCatalogDbQueryTest method networkCollectionTest.
@Test
@Transactional
public void networkCollectionTest() {
logger.debug("TEST IS STARTING UP...");
String modelUUID = "4694a55f-58b3-4f17-92a5-796d6f5ffd0d";
boolean found = false;
logger.debug(Integer.toString(port));
InstanceGroup instanceGroup = null;
List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupList = null;
org.onap.so.db.catalog.beans.Service service = client.getServiceByID(modelUUID);
if (service == null) {
logger.debug("null");
} else {
List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations();
if (customizations.isEmpty()) {
logger.debug("No Network Collection found. CollectionResourceCustomizations is empty");
}
for (CollectionResourceCustomization crc : customizations) {
if (client.getNetworkCollectionResourceCustomizationByID(crc.getModelCustomizationUUID()) instanceof NetworkCollectionResourceCustomization) {
if (crc.getCollectionResource() != null) {
if (crc.getCollectionResource().getToscaNodeType() != null) {
String toscaNodeType = crc.getCollectionResource().getToscaNodeType();
if (toscaNodeType.contains(NETWORKCOLLECTION)) {
logger.debug("Found a network collection");
instanceGroup = crc.getCollectionResource().getInstanceGroup();
collectionInstanceGroupList = instanceGroup.getCollectionInstanceGroupCustomizations();
CollectionNetworkResourceCustomization collectionNetworkCust = instanceGroup.getCollectionNetworkResourceCustomizations().get(0);
logger.debug("Found Collection Network Resource Customization: " + collectionNetworkCust.getModelCustomizationUUID());
} else {
logger.debug("No Network Collection found. toscaNodeType does not contain NetworkCollection");
}
} else {
logger.debug("No Network Collection found. toscaNodeType is null");
}
} else {
logger.debug("No Network Collection found. collectionResource is null");
}
found = true;
} else {
logger.debug("Not a Network Collection Resource Customization Instance");
}
}
}
assertEquals("Number of CollectionResourceInstanceGroupCustomization in list", 2, collectionInstanceGroupList.size());
assertNotNull(instanceGroup);
assertTrue(found);
}
use of org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization 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);
}
Aggregations