### Question:
QueryGroups extends CatalogQuery { @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(); } QueryGroups();  QueryGroups(List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations); @Override String JSON2(boolean isArray, boolean isEmbed);  }### Answer:
@Test public void convertToJson_successful() { QueryGroups queryGroups = new QueryGroups(createList()); String jsonResult = queryGroups.JSON2(true, false); Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].modelInfo.modelName")) .contains("test"); Assertions .assertThat( JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].vnfcs[0].modelInfo.modelName")) .contains("test"); }