Search in sources :

Example 41 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class ServiceEBBLoaderTest method traverseCatalogDbServiceMultipleNetworkTest.

@Test
public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException {
    execution.setVariable("testProcessKey", "testProcessKeyValue");
    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();
    List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
    CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
    collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
    collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
    instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
    collectionResource.setInstanceGroup(instanceGroup);
    collectionResourceCustomization.setCollectionResource(collectionResource);
    ;
    service.setModelUUID("abc");
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
    doReturn(service).when(mockCatalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
    doReturn(collectionResourceCustomization).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
    List<Resource> resource = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    serviceEBBLoader.traverseCatalogDbService(execution, sIRequest, resource, aaiResourceIds);
    assertEquals(resource.size(), 2);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Service(org.onap.so.db.catalog.beans.Service) Mockito.anyString(org.mockito.Mockito.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Pair(org.javatuples.Pair) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 42 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class UserParamsServiceTraversalTest method getUserParams.

private List<Map<String, Object>> getUserParams() throws IOException {
    String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
    ServiceInstancesRequest sIRequest = new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
    return sIRequest.getRequestDetails().getRequestParameters().getUserParams();
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 43 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest 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 44 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest 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 45 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class RelatedInstancesValidationTest method testCreateSIVpnBonding.

@Test
public void testCreateSIVpnBonding() throws IOException, ValidationException {
    String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json")));
    ObjectMapper mapper = new ObjectMapper();
    ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
    ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, 7, false, sir.getRequestDetails().getRequestParameters());
    info.setRequestScope("service");
    sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
    sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
    RelatedInstancesValidation validation = new RelatedInstancesValidation();
    validation.validate(info);
    RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
    assertEquals(info.getRequestScope(), "service");
    assertEquals(instanceList[0].getRelatedInstance().getModelInfo().getModelType().toString(), "vpnBinding");
    assertEquals(instanceList[1].getRelatedInstance().getModelInfo().getModelType().toString(), "network");
}
Also used : RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Aggregations

ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)100 Test (org.junit.Test)58 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)36 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)17 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)15 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)15 IOException (java.io.IOException)11 BaseTest (org.onap.so.apihandlerinfra.BaseTest)11 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)11 ValidationException (org.onap.so.exceptions.ValidationException)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)8 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)8 Service (org.onap.so.db.catalog.beans.Service)8 ArrayList (java.util.ArrayList)7 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)7 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)7 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)7 GenericVnf (org.onap.aai.domain.yang.GenericVnf)6