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