Search in sources :

Example 1 with CollectionResourceCustomization

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

the class UserParamsServiceTraversal method findCatalogNetworkCollection.

private CollectionResourceCustomization findCatalogNetworkCollection(DelegateExecution execution, org.onap.so.db.catalog.beans.Service service) {
    CollectionResourceCustomization networkCollection = null;
    int count = 0;
    for (CollectionResourceCustomization collectionCustom : service.getCollectionResourceCustomizations()) {
        if (catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCustom.getModelCustomizationUUID()) != null) {
            networkCollection = collectionCustom;
            count++;
        }
    }
    if (count > 1) {
        buildAndThrowException(execution, "Found multiple Network Collections in the Service model, only one per Service is supported.");
    }
    return networkCollection;
}
Also used : CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization)

Example 2 with CollectionResourceCustomization

use of org.onap.so.db.catalog.beans.CollectionResourceCustomization 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 CollectionResourceCustomization

use of org.onap.so.db.catalog.beans.CollectionResourceCustomization 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 CollectionResourceCustomization

use of org.onap.so.db.catalog.beans.CollectionResourceCustomization 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);
}
Also used : CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest) Transactional(javax.transaction.Transactional)

Example 5 with CollectionResourceCustomization

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

the class ServiceEBBLoaderTest method findCatalogNetworkCollectionTest.

@Test
public void findCatalogNetworkCollectionTest() {
    Service service = new Service();
    NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
    networkCustomization.setModelCustomizationUUID("123");
    service.getCollectionResourceCustomizations().add(networkCustomization);
    doReturn(networkCustomization).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
    CollectionResourceCustomization customization = serviceEBBLoader.findCatalogNetworkCollection(execution, service);
    assertNotNull(customization);
}
Also used : NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Service(org.onap.so.db.catalog.beans.Service) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

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