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