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