### Question:
QueryVfModule extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { StringBuilder sb = new StringBuilder(); if (!isEmbed && isArray) sb.append("{ "); if (isArray) sb.append("\"vfModules\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VfModuleCustomization o : vfModules) { if (first) sb.append("\n"); first = false; boolean vfNull = o.getVfModule() == null; boolean hasVolumeGroup = false; HeatEnvironment envt = o.getVolumeHeatEnv(); if (envt != null) { hasVolumeGroup = true; } put(valueMap, "MODEL_NAME", vfNull ? null : o.getVfModule().getModelName()); put(valueMap, "MODEL_UUID", vfNull ? null : o.getVfModule().getModelUUID()); put(valueMap, "MODEL_INVARIANT_ID", vfNull ? null : o.getVfModule().getModelInvariantUUID()); put(valueMap, "MODEL_VERSION", vfNull ? null : o.getVfModule().getModelVersion()); put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID()); put(valueMap, "IS_BASE", !vfNull && (o.getVfModule().getIsBase())); put(valueMap, "VF_MODULE_LABEL", o.getLabel()); put(valueMap, "INITIAL_COUNT", o.getInitialCount()); put(valueMap, "HAS_VOLUME_GROUP", hasVolumeGroup); 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(); } QueryVfModule();  QueryVfModule(List<VfModuleCustomization> vlist); List<VfModuleCustomization> getVfModule(); void setVfModule(List<VfModuleCustomization> v); @Override String toString(); @Override String JSON2(boolean isArray, boolean isEmbed);  }### Answer:
@Test public void convertToJson_successful() { QueryVfModule testedObject = new QueryVfModule(createList()); String jsonResult = testedObject.JSON2(true, false); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelName")) .contains(VF_MODULE_MODEL_NAME); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelUuid")) .contains(VF_MODEL_UUID); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelInvariantUuid")) .contains(VF_MODULE_INVARIANT_UUID); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].isBase")).contains("true"); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].vfModuleLabel")) .contains(VF_MODEL_CUSTOMIZATION_LABEL); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].initialCount")) .contains(String.valueOf(VF_MODEL_CUSTOMIZATION_INITIAL_COUNT)); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].hasVolumeGroup")) .contains("false"); }
@Test public void convertToJson_successful_hasVolumeGroupIsTrue() { QueryVfModule testedObject = new QueryVfModule(createListWithHeatEnvironmentArtifactUuid()); String jsonResult = testedObject.JSON2(true, false); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].hasVolumeGroup")) .contains("true"); }