use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class ServiceEBBLoaderTest method traverseVrfConfigurationTest.
@Test
public void traverseVrfConfigurationTest() throws VrfBondingServiceException, JsonProcessingException {
List<Resource> resource = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
Service service = new Service();
List<ConfigurationResourceCustomization> resourceCustomizations = new ArrayList<>();
ConfigurationResourceCustomization configuration = new ConfigurationResourceCustomization();
configuration.setModelCustomizationUUID("123");
resourceCustomizations.add(configuration);
service.setConfigurationCustomizations(resourceCustomizations);
Relationship relationship = new Relationship();
relationship.setRelatedTo("vpn-binding");
RelationshipList relationshipList = new RelationshipList();
relationshipList.getRelationship().add(relationship);
org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
aaiLocalNetwork.setNetworkId("localNetworkId");
aaiLocalNetwork.setRelationshipList(relationshipList);
RelatedInstance relatedVpnBinding = new RelatedInstance();
relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
RelatedInstance relatedLocalNetwork = new RelatedInstance();
relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
doReturn(aaiLocalNetwork).when(mockBbInputSetupUtils).getAAIL3Network("localNetworkInstanceId");
Resource serviceResource = new Resource(WorkflowType.SERVICE, "1", false, null);
serviceEBBLoader.traverseVrfConfiguration(aaiResourceIds, resource, serviceResource, service, relatedVpnBinding, relatedLocalNetwork);
assertEquals(resource.size(), 1);
assertEquals(aaiResourceIds.size(), 0);
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class VrfValidationTest method testVrfCatalogDbChecks.
@Test
public void testVrfCatalogDbChecks() throws VrfBondingServiceException {
Service service = new Service();
service.setModelName("modelName");
ConfigurationResourceCustomization configuration = new ConfigurationResourceCustomization();
service.setConfigurationCustomizations(new ArrayList<>());
service.getConfigurationCustomizations().add(configuration);
ServiceProxyResourceCustomization serviceProxy = new ServiceProxyResourceCustomization();
configuration.setServiceProxyResourceCustomization(serviceProxy);
service.setServiceProxyCustomizations(new ArrayList<>());
service.getServiceProxyCustomizations().add(serviceProxy);
Service sourceService = new Service();
sourceService.setServiceType("TRANSPORT");
serviceProxy.setSourceService(sourceService);
configuration.setType("VRF-ENTRY");
configuration.setRole("INFRASTRUCTURE-CLOUD-VPN");
ExpectedException.none();
vrfValidation.vrfCatalogDbChecks(service);
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class UpgradePreWorkflowValidatorTest method validateHappyCase.
@Test
public void validateHappyCase() throws JsonProcessingException {
ServiceInstancesRequest sir = new ServiceInstancesRequest();
sir.setRequestDetails(new RequestDetails());
sir.getRequestDetails().setModelInfo(new ModelInfo());
sir.getRequestDetails().getModelInfo().setModelUuid(UUID.randomUUID().toString());
String modelInvariantId = UUID.randomUUID().toString();
sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId);
Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
serviceResource.setModelInvariantId(modelInvariantId);
Resource vnfResource = new Resource(WorkflowType.VNF, "", false, serviceResource);
String vnfCustomiationId = UUID.randomUUID().toString();
vnfResource.setVnfCustomizationId(vnfCustomiationId);
Service service = new Service();
VnfResourceCustomization vnfCustomization = new VnfResourceCustomization();
vnfCustomization.setModelCustomizationUUID(vnfCustomiationId);
service.setVnfCustomizations(Arrays.asList(vnfCustomization));
when(catalogDbClient.getServiceByModelUUID(anyString())).thenReturn(service);
BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource, vnfResource));
Optional<String> message = validator.validate(execution);
assertFalse(message.isPresent());
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class UpgradePreWorkflowValidatorTest method validateAAIVnfsNotSupported.
@Test
public void validateAAIVnfsNotSupported() throws JsonProcessingException {
ServiceInstancesRequest sir = new ServiceInstancesRequest();
sir.setRequestDetails(new RequestDetails());
sir.getRequestDetails().setModelInfo(new ModelInfo());
sir.getRequestDetails().getModelInfo().setModelUuid(UUID.randomUUID().toString());
String modelInvariantId = UUID.randomUUID().toString();
sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId);
Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
serviceResource.setModelInvariantId(modelInvariantId);
Resource vnfResource = new Resource(WorkflowType.VNF, "", false, serviceResource);
vnfResource.setVnfCustomizationId(UUID.randomUUID().toString());
Service service = new Service();
VnfResourceCustomization vnfCustomization = new VnfResourceCustomization();
vnfCustomization.setModelCustomizationUUID(UUID.randomUUID().toString());
service.setVnfCustomizations(Arrays.asList(vnfCustomization));
when(catalogDbClient.getServiceByModelUUID(anyString())).thenReturn(service);
BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource, vnfResource));
Optional<String> message = validator.validate(execution);
assertTrue(message.isPresent());
assertTrue(message.get().startsWith("Existing vnfs in AAI are not supported by service model"));
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class VrfValidationTest method testVrfServiceValidation.
@Test
public void testVrfServiceValidation() throws VrfBondingServiceException {
Service service = new Service();
service.setModelName("modelName");
service.setServiceType("BONDING");
service.setServiceRole("VPN");
exceptionRule.expect(VrfBondingServiceException.class);
exceptionRule.expectMessage("Service: modelName does not have service type of BONDING and does not have service role of INFRASTRUCTURE-VPN");
vrfValidation.vrfServiceValidation(service);
service.setServiceType("BOND");
service.setServiceRole("INFRASTRUCTURE-VPN");
exceptionRule.expect(VrfBondingServiceException.class);
exceptionRule.expectMessage("Service: modelName does not have service type of BONDING and does not have service role of INFRASTRUCTURE-VPN");
vrfValidation.vrfServiceValidation(service);
service.setServiceType("BONDING");
service.setServiceRole("INFRASTRUCTURE-VPN");
ExpectedException.none();
vrfValidation.vrfServiceValidation(service);
}
Aggregations