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