Search in sources :

Example 21 with Resource

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));
}
Also used : Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 22 with Resource

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);
}
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 23 with Resource

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);
}
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 24 with Resource

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

Example 25 with Resource

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

Aggregations

Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)40 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)9 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)8 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)6 Pair (org.javatuples.Pair)5 Service (org.onap.so.db.catalog.beans.Service)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)4 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 Mockito.anyString (org.mockito.Mockito.anyString)3 Relationship (org.onap.aai.domain.yang.Relationship)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)3 ConfigurationResource (org.onap.so.db.catalog.beans.ConfigurationResource)3 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)3