Search in sources :

Example 1 with VnfResource

use of org.onap.so.bpmn.core.domain.VnfResource in project so by onap.

the class OofHomingTestIT method testHoming_success_vnfResourceList.

@Test
public void testHoming_success_vnfResourceList() throws Exception {
    // Create a Service Decomposition
    MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/oofCatalogResp.json");
    String busKey = UUID.randomUUID().toString();
    Map<String, Object> vars = new HashMap<>();
    setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
    invokeSubProcess("DecomposeService", busKey, vars);
    ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
    logger.debug("In testHoming_success_vnfResourceList, ServiceDecomposition = {}", sd);
    List<VnfResource> vnfResourceList = sd.getVnfResources();
    vnfResourceList.get(0).setResourceId("test-resource-id-000");
    // Invoke Homing
    mockOof(wireMockServer);
    String businessKey = UUID.randomUUID().toString();
    Map<String, Object> variables = new HashMap<>();
    variables.put("homingService", "oof");
    variables.put("isDebugLogEnabled", "true");
    variables.put("msoRequestId", "testRequestId");
    variables.put("serviceInstanceId", "testServiceInstanceId");
    variables.put("serviceDecomposition", sd);
    variables.put("subscriberInfo", subscriber2);
    HashMap customerLocation = new HashMap<String, Object>();
    customerLocation.put("customerLatitude", "32.89748");
    customerLocation.put("customerLongitude", "-97.040443");
    customerLocation.put("customerName", "xyz");
    variables.put("customerLatitude", "32.89748");
    variables.put("customerLongitude", "-97.040443");
    variables.put("customerName", "xyz");
    variables.put("customerLocation", customerLocation);
    variables.put("cloudOwner", "amazon");
    variables.put("cloudRegionId", "TNZED");
    invokeSubProcess("Homing", businessKey, variables);
    injectWorkflowMessages(callbacks, "oof3");
    waitForProcessEnd(businessKey, 10000);
    // Get Variables
    WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
    ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
    logger.debug("serviceDecompositionExp is: {}", serviceDecompositionExp);
    Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
    logger.debug("resourceVnf is: {}", resourceVnf);
    HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
    String resourceVnfHomingString = resourceVnfHoming.toString();
    logger.debug("resourceVnfHomingString is: {}", resourceVnfHomingString);
    resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
    logger.debug("Now resourceVnfHomingString is: {}", resourceVnfHomingString);
    assertNull(workflowException);
    // Verify request
    String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
    logger.debug("oofRequest is: {}", oofRequest);
    assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), oofRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
    assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "test-resource-id-000", "CloudOwner", "mtmnj1a", "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
}
Also used : ServiceDecomposition(org.onap.so.bpmn.core.domain.ServiceDecomposition) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) HashMap(java.util.HashMap) HomingSolution(org.onap.so.bpmn.core.domain.HomingSolution) WorkflowException(org.onap.so.bpmn.core.WorkflowException) NetworkResource(org.onap.so.bpmn.core.domain.NetworkResource) AllottedResource(org.onap.so.bpmn.core.domain.AllottedResource) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) Resource(org.onap.so.bpmn.core.domain.Resource) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 2 with VnfResource

use of org.onap.so.bpmn.core.domain.VnfResource in project so by onap.

the class OofHomingIT method testHoming_success_vnfResourceList.

@Test
public void testHoming_success_vnfResourceList() throws Exception {
    // Create a Service Decomposition
    MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/oofCatalogResp.json");
    String busKey = UUID.randomUUID().toString();
    Map<String, Object> vars = new HashMap<>();
    setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
    invokeSubProcess("DecomposeService", busKey, vars);
    ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
    System.out.println("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd);
    List<VnfResource> vnfResourceList = sd.getVnfResources();
    vnfResourceList.get(0).setResourceId("test-resource-id-000");
    // Invoke Homing
    mockOof(wireMockServer);
    String businessKey = UUID.randomUUID().toString();
    Map<String, Object> variables = new HashMap<>();
    variables.put("homingService", "oof");
    variables.put("isDebugLogEnabled", "true");
    variables.put("msoRequestId", "testRequestId");
    variables.put("serviceInstanceId", "testServiceInstanceId");
    variables.put("serviceDecomposition", sd);
    variables.put("subscriberInfo", subscriber2);
    HashMap customerLocation = new HashMap<String, Object>();
    customerLocation.put("customerLatitude", "32.89748");
    customerLocation.put("customerLongitude", "-97.040443");
    customerLocation.put("customerName", "xyz");
    variables.put("customerLatitude", "32.89748");
    variables.put("customerLongitude", "-97.040443");
    variables.put("customerName", "xyz");
    variables.put("customerLocation", customerLocation);
    variables.put("cloudOwner", "amazon");
    variables.put("cloudRegionId", "TNZED");
    invokeSubProcess("Homing", businessKey, variables);
    injectWorkflowMessages(callbacks, "oof3");
    waitForProcessEnd(businessKey, 10000);
    // Get Variables
    WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
    ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
    System.out.println("serviceDecompositionExp is: " + serviceDecompositionExp);
    Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
    System.out.println("resourceVnf is: " + resourceVnf);
    HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
    String resourceVnfHomingString = resourceVnfHoming.toString();
    System.out.println("resourceVnfHomingString is: " + resourceVnfHomingString);
    resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
    System.out.println("Now resourceVnfHomingString is: " + resourceVnfHomingString);
    assertNull(workflowException);
    // Verify request
    String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
    System.out.println("oofRequest is: " + oofRequest);
    assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), oofRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
    // System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " +
    // resourceVnfHoming.getVnf().getResourceId());
    assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "test-resource-id-000", "CloudOwner", "mtmnj1a", "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
}
Also used : ServiceDecomposition(org.onap.so.bpmn.core.domain.ServiceDecomposition) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) HashMap(java.util.HashMap) HomingSolution(org.onap.so.bpmn.core.domain.HomingSolution) WorkflowException(org.onap.so.bpmn.core.WorkflowException) NetworkResource(org.onap.so.bpmn.core.domain.NetworkResource) AllottedResource(org.onap.so.bpmn.core.domain.AllottedResource) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) Resource(org.onap.so.bpmn.core.domain.Resource) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 3 with VnfResource

use of org.onap.so.bpmn.core.domain.VnfResource in project so by onap.

the class InstnaceResourceListTest method testSimpleVFResource.

// Test when PK is empty
@Test
public void testSimpleVFResource() throws IOException {
    String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
    VnfResource vnfResource = new VnfResource();
    vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}");
    List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
    Assert.assertEquals(1, instanceResourceList.size());
    Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
}
Also used : VnfResource(org.onap.so.bpmn.core.domain.VnfResource) GroupResource(org.onap.so.bpmn.core.domain.GroupResource) VnfcResource(org.onap.so.bpmn.core.domain.VnfcResource) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) Resource(org.onap.so.bpmn.core.domain.Resource) ModuleResource(org.onap.so.bpmn.core.domain.ModuleResource) Test(org.junit.Test)

Example 4 with VnfResource

use of org.onap.so.bpmn.core.domain.VnfResource in project so by onap.

the class InstnaceResourceListTest method testVFResourceWithModule.

@Test
public void testVFResourceWithModule() throws IOException {
    String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
    VnfResource vnfResource = new VnfResource();
    vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}");
    // Come from package org.onap.so.bpmn.core.domain.VnfResourceTest
    List<ModuleResource> moduleResources;
    moduleResources = new ArrayList<>();
    ModuleResource moduleresource = getModuleResource();
    moduleResources.add(moduleresource);
    vnfResource.setModules(moduleResources);
    List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
    Assert.assertEquals(2, instanceResourceList.size());
    Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
    Assert.assertEquals(ResourceType.MODULE, instanceResourceList.get(1).getResourceType());
}
Also used : VnfResource(org.onap.so.bpmn.core.domain.VnfResource) GroupResource(org.onap.so.bpmn.core.domain.GroupResource) VnfcResource(org.onap.so.bpmn.core.domain.VnfcResource) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) Resource(org.onap.so.bpmn.core.domain.Resource) ModuleResource(org.onap.so.bpmn.core.domain.ModuleResource) ModuleResource(org.onap.so.bpmn.core.domain.ModuleResource) Test(org.junit.Test)

Example 5 with VnfResource

use of org.onap.so.bpmn.core.domain.VnfResource in project so by onap.

the class InstnaceResourceListTest method testVFWithEmptyGroupResource.

// Test when PK is not empty and PK does not contain any groups
@Test
public void testVFWithEmptyGroupResource() throws IOException {
    String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
    VnfResource vnfResource = new VnfResource();
    vnfResource.setResourceInput("{\"a\":\"[emptygroup_list,INDEX,name]\"}");
    List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
    Assert.assertEquals(1, instanceResourceList.size());
    Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
}
Also used : VnfResource(org.onap.so.bpmn.core.domain.VnfResource) GroupResource(org.onap.so.bpmn.core.domain.GroupResource) VnfcResource(org.onap.so.bpmn.core.domain.VnfcResource) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) Resource(org.onap.so.bpmn.core.domain.Resource) ModuleResource(org.onap.so.bpmn.core.domain.ModuleResource) Test(org.junit.Test)

Aggregations

VnfResource (org.onap.so.bpmn.core.domain.VnfResource)20 Test (org.junit.Test)16 Resource (org.onap.so.bpmn.core.domain.Resource)11 GroupResource (org.onap.so.bpmn.core.domain.GroupResource)10 HashMap (java.util.HashMap)8 VnfcResource (org.onap.so.bpmn.core.domain.VnfcResource)7 BaseTest (org.onap.so.BaseTest)6 ModuleResource (org.onap.so.bpmn.core.domain.ModuleResource)6 ArrayList (java.util.ArrayList)3 Gson (com.google.gson.Gson)2 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 List (java.util.List)2 Map (java.util.Map)2 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 WorkflowException (org.onap.so.bpmn.core.WorkflowException)2 AllottedResource (org.onap.so.bpmn.core.domain.AllottedResource)2 HomingSolution (org.onap.so.bpmn.core.domain.HomingSolution)2 NetworkResource (org.onap.so.bpmn.core.domain.NetworkResource)2