Search in sources :

Example 31 with HeatTemplate

use of org.onap.so.db.catalog.beans.HeatTemplate in project so by onap.

the class WorkflowActionTest method selectExecutionListServiceMacroAssignTest.

/**
 * SERVICE MACRO TESTS
 */
@Test
public void selectExecutionListServiceMacroAssignTest() throws Exception {
    String gAction = "assignInstance";
    String resource = "Service";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v6/serviceInstances/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
    HeatEnvironment volumeHeatEnv = new HeatEnvironment();
    vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
    org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
    HeatTemplate volumeHeatTemplate = new HeatTemplate();
    vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
    vfModuleCustomization.setVfModule(vfModule);
    VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
    vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    HeatEnvironment heatEnvironment = new HeatEnvironment();
    vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
    org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
    HeatTemplate moduleHeatTemplate = new HeatTemplate();
    vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
    vfModuleCustomization2.setVfModule(vfModule2);
    VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
    vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString())).thenReturn(prepareListWithResources(false, false));
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB");
}
Also used : HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 32 with HeatTemplate

use of org.onap.so.db.catalog.beans.HeatTemplate in project so by onap.

the class WorkflowActionTest method selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest.

@Test
public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
    String gAction = "replaceInstanceRetainAssignments";
    String resource = "VfModule";
    String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON);
    initExecution(gAction, bpmnRequest, true);
    execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
    execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
    execution.setVariable("vfModuleId", "1234");
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId("volumeGroupId");
    doReturn(Optional.of(volumeGroup)).when(bbSetupUtils).getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
    org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
    vfModule.setVolumeHeatTemplate(new HeatTemplate());
    vfModuleCustomization.setVfModule(vfModule);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(vfModuleCustomization);
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
Also used : HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 33 with HeatTemplate

use of org.onap.so.db.catalog.beans.HeatTemplate in project so by onap.

the class UserParamsServiceTraversalTest method getVfModuleCustomization.

private VfModuleCustomization getVfModuleCustomization(String modelCustomizationUUID, boolean includeVolumeGroup) {
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID(modelCustomizationUUID);
    VfModule vfModule = new VfModule();
    if (includeVolumeGroup) {
        vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
        vfModule.setVolumeHeatTemplate(new HeatTemplate());
        vfModule.setModelName("helm");
    } else {
        vfModuleCustomization.setHeatEnvironment(new HeatEnvironment());
    }
    vfModule.setModuleHeatTemplate(new HeatTemplate());
    vfModuleCustomization.setVfModule(vfModule);
    return vfModuleCustomization;
}
Also used : HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VfModule(org.onap.so.db.catalog.beans.VfModule)

Example 34 with HeatTemplate

use of org.onap.so.db.catalog.beans.HeatTemplate in project so by onap.

the class MsoHeatUtilsUnitTest method convertInputMapValuesTest.

@Test
public final void convertInputMapValuesTest() {
    MsoHeatUtils utils = new MsoHeatUtils();
    Map<String, Object> inputs = new HashMap<>();
    Set<HeatTemplateParam> params = new HashSet<>();
    HeatTemplate ht = new HeatTemplate();
    HeatTemplateParam htp = new HeatTemplateParam();
    htp.setParamName("vnf_name");
    htp.setParamType("string");
    params.add(htp);
    inputs.put("vnf_name", "a_vnf_name");
    htp = new HeatTemplateParam();
    htp.setParamName("image_size");
    htp.setParamType("number");
    params.add(htp);
    inputs.put("image_size", "1024");
    htp = new HeatTemplateParam();
    htp.setParamName("external");
    htp.setParamType("boolean");
    params.add(htp);
    inputs.put("external", "false");
    htp = new HeatTemplateParam();
    htp.setParamName("oam_ips");
    htp.setParamType("comma_delimited_list");
    params.add(htp);
    inputs.put("oam_ips", "a,b");
    htp = new HeatTemplateParam();
    htp.setParamName("oam_prefixes");
    htp.setParamType("json");
    params.add(htp);
    String jsonEscInput = "[{\"prefix\": \"aValue\"}, {\"prefix\": \"aValue2\"}]";
    inputs.put("oam_prefixes", jsonEscInput);
    ht.setParameters(params);
    Map<String, Object> output = utils.convertInputMap(inputs, ht);
    assertEquals("a_vnf_name", output.get("vnf_name"));
    assertEquals(1024, output.get("image_size"));
    assertEquals(false, output.get("external"));
    List<String> cdl = new ArrayList<>();
    cdl.add(0, "a");
    cdl.add(1, "b");
    assertEquals(cdl, output.get("oam_ips"));
    ObjectMapper JSON_MAPPER = new ObjectMapper();
    JsonNode jn = null;
    try {
        jn = JSON_MAPPER.readTree(jsonEscInput);
    } catch (Exception e) {
    }
    assertEquals(jn, output.get("oam_prefixes"));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 35 with HeatTemplate

use of org.onap.so.db.catalog.beans.HeatTemplate in project so by onap.

the class MsoHeatUtilsTest method testGetVfHeatTimeoutValue.

@Test
public void testGetVfHeatTimeoutValue() {
    VfModuleCustomization vfmc = new VfModuleCustomization();
    VfModule vf = new VfModule();
    HeatTemplate heat = new HeatTemplate();
    heat.setTimeoutMinutes(110);
    vf.setModuleHeatTemplate(heat);
    vfmc.setVfModule(vf);
    Mockito.when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("uuid")).thenReturn(vfmc);
    int timeout = heatUtils.getVfHeatTimeoutValue("uuid", false);
    assertEquals(110, timeout);
    Mockito.verify(catalogDbClient, times(1)).getVfModuleCustomizationByModelCuztomizationUUID("uuid");
}
Also used : HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VfModule(org.onap.so.db.catalog.beans.VfModule) Test(org.junit.Test)

Aggregations

HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)35 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)22 ArrayList (java.util.ArrayList)21 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)20 Test (org.junit.Test)19 List (java.util.List)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 RelationshipList (org.onap.aai.domain.yang.RelationshipList)12 VfModule (org.onap.aai.domain.yang.VfModule)12 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)12 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)12 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)12 HashMap (java.util.HashMap)10 HeatTemplateParam (org.onap.so.db.catalog.beans.HeatTemplateParam)10 VfModule (org.onap.so.db.catalog.beans.VfModule)8 HashSet (java.util.HashSet)6 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)6 NetworkResource (org.onap.so.db.catalog.beans.NetworkResource)6