use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class ServiceEBBLoaderTest method containsWorkflowTypeTest.
@Test
public void containsWorkflowTypeTest() {
List<Resource> resourceList = new ArrayList<>();
resourceList.add(new Resource(WorkflowType.PNF, "resource id", false, null));
resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false, null));
resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false, null));
resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false, null));
assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.PNF));
assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.VNF));
assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.NETWORK));
assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION));
assertFalse(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.CONFIGURATION));
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource 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.bpmn.infrastructure.workflow.tasks.Resource 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.bpmn.infrastructure.workflow.tasks.Resource in project so by onap.
the class UserParamsServiceTraversalTest method getResourceListFromUserParamsMultipleSameModelVnfVfModule.
@Test
public void getResourceListFromUserParamsMultipleSameModelVnfVfModule() throws Exception {
initExecution("createInstance", readBpmnRequestFromFile(MACRO_CREATE_SVC_SAME_MODEL_VNF_VFMODULE), false);
Mockito.doReturn(getVfModuleCustomization("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", false)).when(mockCatalogDbClient).getVfModuleCustomizationByModelCuztomizationUUID("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0");
Mockito.doReturn(getVfModuleCustomization("83677d89-428a-407b-b4ec-738e68275d84", false)).when(mockCatalogDbClient).getVfModuleCustomizationByModelCuztomizationUUID("83677d89-428a-407b-b4ec-738e68275d84");
List<Resource> resources = userParamsServiceTraversal.getResourceListFromUserParams(execution, getUserParams(), serviceInstanceId, requestAction);
assertEquals(7, resources.size());
Resource service = resources.get(0);
assertTrue(service.getResourceType() == WorkflowType.SERVICE);
assertEquals(2, service.getChildren().size());
Resource vnf1 = service.getChildren().get(0);
assertEquals(service, vnf1.getParent());
assertEquals("vnf-instanceName-1", vnf1.getInstanceName());
assertEquals("0d0ba1ee-6b7f-47fe-8266-2967993b2c08", vnf1.getResourceId());
assertEquals(2, vnf1.getChildren().size());
Resource vnf2 = service.getChildren().get(1);
assertEquals(service, vnf2.getParent());
assertEquals("vnf-instanceName-2", vnf2.getInstanceName());
assertEquals("0d0ba1ee-6b7f-47fe-8266-2967993b2c08", vnf2.getResourceId());
assertEquals(2, vnf2.getChildren().size());
Resource vfmodule1 = vnf1.getChildren().get(0);
assertEquals(vnf1, vfmodule1.getParent());
assertEquals("demo-network-1", vfmodule1.getInstanceName());
assertEquals("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", vfmodule1.getResourceId());
Resource vfmodule2 = vnf1.getChildren().get(1);
assertEquals(vnf1, vfmodule2.getParent());
assertEquals("demo-1", vfmodule2.getInstanceName());
assertEquals("83677d89-428a-407b-b4ec-738e68275d84", vfmodule2.getResourceId());
Resource vfmodule3 = vnf2.getChildren().get(0);
assertEquals(vnf2, vfmodule3.getParent());
assertEquals("demo-2", vfmodule3.getInstanceName());
assertEquals("83677d89-428a-407b-b4ec-738e68275d84", vfmodule3.getResourceId());
Resource vfmodule4 = vnf2.getChildren().get(1);
assertEquals(vnf2, vfmodule4.getParent());
assertEquals("demo-3", vfmodule4.getInstanceName());
assertEquals("83677d89-428a-407b-b4ec-738e68275d84", vfmodule4.getResourceId());
}
use of org.onap.so.bpmn.infrastructure.workflow.tasks.Resource 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());
}
Aggregations