Search in sources :

Example 11 with Resource

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

the class ResourceRequestBuilderTest method getListResourceInputTest.

@Test
public void getListResourceInputTest() throws Exception {
    List<Map> vnfdata = null;
    List<Resource> resources = new ArrayList<>();
    if (this.serviceInput.containsKey("serviceResources")) {
        vnfdata = (List<Map>) ((Map) this.serviceInput.get("serviceResources")).get("serviceVnfs");
    }
    assertNotNull(vnfdata);
    vnfdata.forEach(e -> {
        if (e.get("resourceType").equals("VNF")) {
            VnfResource r = new VnfResource();
            r.setResourceInput(e.get("resourceInput").toString());
            resources.add(r);
        } else if (e.get("resourceType").equals("GROUP")) {
            GroupResource r = new GroupResource();
            VnfcResource vfc = new VnfcResource();
            vfc.setResourceInput(e.get("resourceInput").toString());
            List<VnfcResource> vfcList = new ArrayList();
            vfcList.add(vfc);
            r.setVnfcs(vfcList);
            resources.add(r);
        }
    });
    assertEquals(9, resources.size());
    // VF level request
    Map<String, Object> currentVFData = new HashMap<>();
    Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(0), this.userInputMap, currentVFData);
    assertEquals("b", stringObjectMap.get("a"));
    assertEquals("hub_spoke", stringObjectMap.get("topology"));
    assertEquals("defaultvpn", stringObjectMap.get("name"));
    assertTrue(((String) stringObjectMap.get("sitelist")).contains("["));
    // vfc level request
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(1), this.userInputMap, currentVFData);
    assertEquals("", stringObjectMap.get("a"));
    assertEquals("layer3-port", stringObjectMap.get("portswitch"));
    assertEquals("192.168.10.1", stringObjectMap.get("ipAddress"));
    assertEquals("vCPE", stringObjectMap.get("deviceName"));
    // vfc level request
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(2), this.userInputMap, currentVFData);
    assertEquals("", stringObjectMap.get("a"));
    assertEquals("layer2-port", stringObjectMap.get("portswitch"));
    assertEquals("192.168.11.1", stringObjectMap.get("ipAddress"));
    assertEquals("CPE_Beijing", stringObjectMap.get("deviceName"));
    // VF level request
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(3), this.userInputMap, currentVFData);
    assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
    assertEquals("dsvpn_hub1", stringObjectMap.get("role"));
    assertTrue(((String) stringObjectMap.get("wanlist")).contains("["));
    assertTrue(((String) stringObjectMap.get("devlist")).contains("["));
    // VFC request
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(4), this.userInputMap, currentVFData);
    assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
    assertEquals("20000", stringObjectMap.get("postcode"));
    assertEquals("single_gateway", stringObjectMap.get("type"));
    assertEquals("vCPE", stringObjectMap.get("deviceName"));
    assertEquals("DHCP", stringObjectMap.get("ipMode"));
    // VFC request again
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(5), this.userInputMap, currentVFData);
    assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
    assertEquals("20000", stringObjectMap.get("postcode"));
    assertEquals("single_gateway", stringObjectMap.get("type"));
    assertEquals("20.20.20.1", stringObjectMap.get("systemip"));
    assertEquals("default_ipv6", stringObjectMap.get("systemipv6"));
    assertEquals("VNF", stringObjectMap.get("devclass"));
    // VF level request
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(6), this.userInputMap, currentVFData);
    assertEquals("Huawei Public Cloud", stringObjectMap.get("address"));
    assertEquals("dsvpn_hub", stringObjectMap.get("role"));
    assertTrue(((String) stringObjectMap.get("wanlist")).contains("["));
    assertTrue(((String) stringObjectMap.get("devlist")).contains("["));
    // VFC request
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(7), this.userInputMap, currentVFData);
    assertEquals("Huawei Public Cloud", stringObjectMap.get("address"));
    assertEquals("20001", stringObjectMap.get("postcode"));
    assertEquals("multiple_gateway", stringObjectMap.get("type"));
    assertEquals("CPE_Beijing", stringObjectMap.get("deviceName"));
    assertEquals("Static", stringObjectMap.get("ipMode"));
    // VFC request again
    stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resources.get(8), this.userInputMap, currentVFData);
    assertEquals("Huawei Public Cloud", stringObjectMap.get("address"));
    assertEquals("20001", stringObjectMap.get("postcode"));
    assertEquals("multiple_gateway", stringObjectMap.get("type"));
    assertEquals("20.20.20.2", stringObjectMap.get("systemip"));
    assertEquals("default_ipv6", stringObjectMap.get("systemipv6"));
    assertEquals("PNF", stringObjectMap.get("devclass"));
}
Also used : HashMap(java.util.HashMap) 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) ArrayList(java.util.ArrayList) GroupResource(org.onap.so.bpmn.core.domain.GroupResource) VnfResource(org.onap.so.bpmn.core.domain.VnfResource) VnfcResource(org.onap.so.bpmn.core.domain.VnfcResource) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 12 with Resource

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

the class InstnaceResourceListTest method testVFResourceWithEmptyGroup.

@Test
public void testVFResourceWithEmptyGroup() throws IOException {
    String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
    VnfResource vnfResource = new VnfResource();
    vnfResource.setResourceInput("{\"a\":\"[emptygroup_list2,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)

Example 13 with Resource

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

the class InstnaceResourceListTest method testVFWithEmptyGroupKeyResource.

// Test when PK is not empty and contains a group which SK is empty
@Test
public void testVFWithEmptyGroupKeyResource() 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]\"}");
    createGroupKeyResource(vnfResource);
    List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
    Assert.assertEquals(2, instanceResourceList.size());
    Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
    Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType());
    Assert.assertEquals("wan", instanceResourceList.get(1).getModelInfo().getModelName());
}
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 14 with Resource

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

the class ServicePluginFactory method doProcessSiteLocation.

@SuppressWarnings("unchecked")
public String doProcessSiteLocation(ServiceDecomposition serviceDecomposition, String uuiRequest) {
    if (!isNeedProcessSite(uuiRequest)) {
        return uuiRequest;
    }
    Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
    if (uuiObject == null) {
        return uuiRequest;
    }
    Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.getOrDefault("service", Collections.emptyMap());
    Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.getOrDefault("parameters", Collections.emptyMap());
    Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.getOrDefault("requestInputs", Collections.emptyMap());
    List<Object> resources = (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList());
    if (isSiteLocationLocal(serviceRequestInputs, resources)) {
        // resources changed : added TP info
        return getJsonString(uuiObject);
    }
    List<Resource> addResourceList = new ArrayList<>();
    addResourceList.addAll(serviceDecomposition.getServiceResources());
    serviceDecomposition.setVnfResources(null);
    serviceDecomposition.setAllottedResources(null);
    serviceDecomposition.setNetworkResources(null);
    serviceDecomposition.setConfigResources(null);
    for (Resource resource : addResourceList) {
        String resourcemodelName = resource.getModelInfo().getModelName();
        if (StringUtils.containsIgnoreCase(resourcemodelName, "sppartner")) {
            // change serviceDecomposition
            serviceDecomposition.addResource(resource);
            break;
        }
    }
    return uuiRequest;
}
Also used : Resource(org.onap.so.bpmn.core.domain.Resource) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 15 with Resource

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

the class OofHomingIT method testHoming_success_2AR1Vnf2Net.

@Test
public void testHoming_success_2AR1Vnf2Net() throws Exception {
    mockOof(wireMockServer);
    String businessKey = UUID.randomUUID().toString();
    Map<String, Object> variables = new HashMap<>();
    setVariables2(variables);
    invokeSubProcess("Homing", businessKey, variables);
    injectWorkflowMessages(callbacks, "oof3");
    waitForProcessEnd(businessKey, 10000);
    // Get Variables
    WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
    ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
    String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
    Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
    HomingSolution resourceARHoming = resourceAR.getHomingSolution();
    Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
    HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
    Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
    HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
    Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
    HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
    Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
    HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
    String resourceARHomingString = resourceARHoming.toString();
    resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
    String resourceARHoming2String = resourceARHoming2.toString();
    resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
    String resourceVNFHomingString = resourceVNFHoming.toString();
    resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
    String resourceNetHomingString = resourceNetHoming.toString();
    resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
    String resourceNetHoming2String = resourceNetHoming2.toString();
    resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
    expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
    assertNull(workflowException);
    assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(), "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString);
    assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null), resourceARHoming2String);
    assertEquals(homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
    assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(), "aic", "testCloudRegionIdNet", null, null), resourceNetHomingString);
    assertEquals(homingSolutionCloud("cloud", "aic", "testCloudRegionIdNet2", false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), resourceNetHoming2String);
    assertEquals(verifyOofRequest(), expectedOofRequest);
}
Also used : ServiceDecomposition(org.onap.so.bpmn.core.domain.ServiceDecomposition) 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)

Aggregations

Resource (org.onap.so.bpmn.core.domain.Resource)18 VnfResource (org.onap.so.bpmn.core.domain.VnfResource)17 Test (org.junit.Test)15 HashMap (java.util.HashMap)10 GroupResource (org.onap.so.bpmn.core.domain.GroupResource)9 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)8 WorkflowException (org.onap.so.bpmn.core.WorkflowException)8 AllottedResource (org.onap.so.bpmn.core.domain.AllottedResource)8 HomingSolution (org.onap.so.bpmn.core.domain.HomingSolution)8 NetworkResource (org.onap.so.bpmn.core.domain.NetworkResource)8 ServiceDecomposition (org.onap.so.bpmn.core.domain.ServiceDecomposition)8 VnfcResource (org.onap.so.bpmn.core.domain.VnfcResource)7 ModuleResource (org.onap.so.bpmn.core.domain.ModuleResource)6 ArrayList (java.util.ArrayList)4 List (java.util.List)3 Map (java.util.Map)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