Search in sources :

Example 1 with HomingSolution

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

the class OofHomingTestIT 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)

Example 2 with HomingSolution

use of org.onap.so.bpmn.core.domain.HomingSolution 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 3 with HomingSolution

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

the class OofHomingIT method testHoming_success_existingLicense.

@Test
public void testHoming_success_existingLicense() throws Exception {
    mockOof(wireMockServer);
    String businessKey = UUID.randomUUID().toString();
    Map<String, Object> variables = new HashMap<String, Object>();
    setVariablesExistingLicense(variables);
    invokeSubProcess("Homing", businessKey, variables);
    injectWorkflowMessages(callbacks, "sniro");
    waitForProcessEnd(businessKey, 10000);
    // Get Variables
    WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
    ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
    String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
    Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
    HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution();
    Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
    HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution();
    Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
    HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.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+", " ");
    oofRequest = oofRequest.replaceAll("\\s+", "");
    assertNull(workflowException);
    assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "\"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", false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
    assertEquals(verifyOofRequestExistingLicense(), oofRequest);
}
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)

Example 4 with HomingSolution

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

the class OofHomingIT method setVariablesExistingLicense.

private void setVariablesExistingLicense(Map<String, Object> variables) {
    HomingSolution currentHomingSolution = new HomingSolution();
    serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
    serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
    serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
    serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
    serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
    variables.put("isDebugLogEnabled", "true");
    variables.put("msoRequestId", "testRequestId");
    variables.put("serviceInstanceId", "testServiceInstanceId");
    variables.put("serviceDecomposition", serviceDecomposition);
    variables.put("subscriberInfo", subscriber2);
}
Also used : HomingSolution(org.onap.so.bpmn.core.domain.HomingSolution)

Example 5 with HomingSolution

use of org.onap.so.bpmn.core.domain.HomingSolution 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)

Aggregations

HomingSolution (org.onap.so.bpmn.core.domain.HomingSolution)10 HashMap (java.util.HashMap)8 Test (org.junit.Test)8 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)8 WorkflowException (org.onap.so.bpmn.core.WorkflowException)8 AllottedResource (org.onap.so.bpmn.core.domain.AllottedResource)8 NetworkResource (org.onap.so.bpmn.core.domain.NetworkResource)8 Resource (org.onap.so.bpmn.core.domain.Resource)8 ServiceDecomposition (org.onap.so.bpmn.core.domain.ServiceDecomposition)8 VnfResource (org.onap.so.bpmn.core.domain.VnfResource)8