### Question:
QueryVnfcs extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { StringBuilder sb = new StringBuilder(); if (!isEmbed && isArray) { sb.append("{"); } if (isArray) { sb.append("\"vnfcs\": ["); } Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VnfcCustomization o : vnfcCustomizations) { if (first) sb.append("\n"); first = false; put(valueMap, "MODEL_NAME", o.getModelName()); put(valueMap, "MODEL_UUID", o.getModelUUID()); put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantUUID()); put(valueMap, "MODEL_VERSION", o.getModelVersion()); put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID()); if (isJSONValid(o.getResourceInput())) { put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); } 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(); } QueryVnfcs();  QueryVnfcs(List<VnfcCustomization> vnfcCustomizations); List<VnfcCustomization> getVnfcCustomizations(); void setVnfcCustomizations(List<VnfcCustomization> vnfcCustomizations); @Override String toString(); @Override String JSON2(boolean isArray, boolean isEmbed);  }### Answer:
@Test public void convertToJson_successful() { QueryVnfcs queryVnfcs = new QueryVnfcs(createList()); String jsonResult = queryVnfcs.JSON2(true, false); System.out.println(jsonResult); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[0].modelInfo.modelName")) .contains("model1"); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[1].modelInfo.modelName")) .contains("model2"); }