Search in sources :

Example 1 with VnfcInstanceGroupCustomization

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

the class BBInputSetupUtilsTest method getVnfcInstanceGroupsTest.

@Test
public void getVnfcInstanceGroupsTest() throws IOException {
    final String modelCustomizationUUID = "modelCustomizationUUIDTest";
    VnfcInstanceGroupCustomization vnfc = mapper.readValue(new File(RESOURCE_PATH + "VnfcInstanceGroupCustomization.json"), VnfcInstanceGroupCustomization.class);
    doReturn(Arrays.asList(vnfc)).when(MOCK_catalogDbClient).getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID);
    assertThat(bbInputSetupUtils.getVnfcInstanceGroups(modelCustomizationUUID), sameBeanAs(Arrays.asList(vnfc)));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) Test(org.junit.Test)

Example 2 with VnfcInstanceGroupCustomization

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

the class BBInputSetupTest method testMapVnfcCollectionInstanceGroup.

@Test
public void testMapVnfcCollectionInstanceGroup() {
    VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
    GenericVnf genericVnf = new GenericVnf();
    ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
    Service service = Mockito.mock(Service.class);
    org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
    instanceGroup.setModelUUID("modelUUID");
    List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
    VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
    vnfcInstanceGroupCust.setInstanceGroup(instanceGroup);
    vnfcInstanceGroupCust.setFunction("function");
    vnfcInstanceGroupCust.setDescription("description");
    vnfcInstanceGroups.add(vnfcInstanceGroupCust);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setModelUUID("modelUUID");
    doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
    doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
    doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
    doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
    SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
    assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 3 with VnfcInstanceGroupCustomization

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

the class QueryServiceVnfs method JSON2.

@Override
public String JSON2(boolean isArray, boolean isEmbed) {
    StringBuilder sb = new StringBuilder();
    if (!isEmbed && isArray)
        sb.append("{ ");
    if (isArray)
        sb.append("\"serviceVnfs\": [");
    Map<String, String> valueMap = new HashMap<>();
    String sep = "";
    boolean first = true;
    for (VnfResourceCustomization o : serviceVnfs) {
        if (first)
            sb.append("\n");
        first = false;
        boolean vrNull = o.getVnfResources() == null;
        put(valueMap, "MODEL_NAME", vrNull ? null : o.getVnfResources().getModelName());
        put(valueMap, "MODEL_UUID", vrNull ? null : o.getVnfResources().getModelUUID());
        put(valueMap, "MODEL_INVARIANT_ID", vrNull ? null : o.getVnfResources().getModelInvariantId());
        put(valueMap, "MODEL_VERSION", vrNull ? null : o.getVnfResources().getModelVersion());
        put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
        put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName());
        put(valueMap, "TOSCA_NODE_TYPE", vrNull ? null : o.getVnfResources().getToscaNodeType());
        put(valueMap, "NF_FUNCTION", o.getNfFunction());
        put(valueMap, "NF_TYPE", o.getNfType());
        put(valueMap, "NF_ROLE", o.getNfRole());
        put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode());
        put(valueMap, "VNFC_INSTANCE_GROUP_ORDER", o.getVnfcInstanceGroupOrder());
        put(valueMap, "MULTI_STEP_DESIGN", o.getMultiStageDesign());
        if (isJSONValid(StringEscapeUtils.unescapeJava(o.getResourceInput()))) {
            put(valueMap, "RESOURCE_INPUT", o.getResourceInput());
        }
        String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true);
        valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t"));
        List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = o.getVnfcInstanceGroupCustomizations();
        String grpSubItem = new QueryGroups(vrNull ? null : vnfcInstanceGroupCustomizations).JSON2(true, true);
        valueMap.put("_GROUPS_", grpSubItem.replaceAll("(?m)^", "\t\t"));
        sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
        sep = ",\n";
    }
    if (!first)
        sb.append("\n");
    if (isArray)
        sb.append("]");
    if (!isEmbed && isArray)
        sb.append("}");
    return sb.toString();
}
Also used : HashMap(java.util.HashMap) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)

Example 4 with VnfcInstanceGroupCustomization

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

the class QueryGroups method JSON2.

@Override
public String JSON2(boolean isArray, boolean isEmbed) {
    StringBuilder sb = new StringBuilder();
    if (!isEmbed && isArray)
        sb.append("{ ");
    if (isArray)
        sb.append("\"groups\": [");
    Map<String, String> valueMap = new HashMap<>();
    String sep = "";
    boolean first = true;
    for (VnfcInstanceGroupCustomization o : vnfcInstanceGroupCustomizations) {
        if (first)
            sb.append("\n");
        first = false;
        boolean vnfcCustomizationNull = o.getVnfcCustomizations() == null;
        InstanceGroup instanceGroup = o.getInstanceGroup();
        if (instanceGroup != null) {
            put(valueMap, "MODEL_NAME", instanceGroup.getModelName());
            put(valueMap, "MODEL_UUID", instanceGroup.getModelUUID());
            put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID());
            put(valueMap, "MODEL_VERSION", instanceGroup.getModelVersion());
        }
        String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true);
        valueMap.put("_VNFCS_", subItem.replaceAll("(?m)^", "\t\t"));
        sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
        sep = ",\n";
    }
    if (!first)
        sb.append("\n");
    if (isArray)
        sb.append("]");
    if (!isEmbed && isArray)
        sb.append("}");
    return sb.toString();
}
Also used : HashMap(java.util.HashMap) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup)

Example 5 with VnfcInstanceGroupCustomization

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

the class BBInputSetup method mapVnfcCollectionInstanceGroup.

protected void mapVnfcCollectionInstanceGroup(GenericVnf genericVnf, ModelInfo modelInfo, Service service) {
    VnfResourceCustomization vnfResourceCustomization = getVnfResourceCustomizationFromService(modelInfo, service);
    if (vnfResourceCustomization != null) {
        List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = vnfResourceCustomization.getVnfcInstanceGroupCustomizations();
        for (VnfcInstanceGroupCustomization vnfcInstanceGroupCust : vnfcInstanceGroups) {
            InstanceGroup instanceGroup = this.createInstanceGroup();
            org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = bbInputSetupUtils.getCatalogInstanceGroup(vnfcInstanceGroupCust.getInstanceGroup().getModelUUID());
            instanceGroup.setModelInfoInstanceGroup(this.mapperLayer.mapCatalogInstanceGroupToInstanceGroup(null, catalogInstanceGroup));
            instanceGroup.getModelInfoInstanceGroup().setFunction(vnfcInstanceGroupCust.getFunction());
            instanceGroup.getModelInfoInstanceGroup().setDescription(vnfcInstanceGroupCust.getDescription());
            genericVnf.getInstanceGroups().add(instanceGroup);
        }
    }
}
Also used : VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Aggregations

VnfcInstanceGroupCustomization (org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)9 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)4 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 InstanceGroup (org.onap.so.db.catalog.beans.InstanceGroup)3 VFCInstanceGroup (org.onap.so.db.catalog.beans.VFCInstanceGroup)3 ArrayList (java.util.ArrayList)2 IEntityDetails (org.onap.sdc.tosca.parser.api.IEntityDetails)2 Property (org.onap.sdc.toscaparser.api.Property)2 Metadata (org.onap.sdc.toscaparser.api.elements.Metadata)2 GetInput (org.onap.sdc.toscaparser.api.functions.GetInput)2 Input (org.onap.sdc.toscaparser.api.parameters.Input)2 NetworkInstanceGroup (org.onap.so.db.catalog.beans.NetworkInstanceGroup)2 VnfcCustomization (org.onap.so.db.catalog.beans.VnfcCustomization)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 Timestamp (java.sql.Timestamp)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1