Search in sources :

Example 71 with Service

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);
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) Relationship(org.onap.aai.domain.yang.Relationship) Pair(org.javatuples.Pair) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 72 with Service

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);
}
Also used : ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) Service(org.onap.so.db.catalog.beans.Service) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 73 with 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());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Service(org.onap.so.db.catalog.beans.Service) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 74 with Service

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"));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Service(org.onap.so.db.catalog.beans.Service) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 75 with Service

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);
}
Also used : Service(org.onap.so.db.catalog.beans.Service) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

Service (org.onap.so.db.catalog.beans.Service)171 Test (org.junit.Test)135 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)57 File (java.io.File)48 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)47 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)46 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)40 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)37 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)36 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)29 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)19 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)18 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)18 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)18 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)18 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)18