### Question:
QueryResourceRecipe extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { Map<String, String> valueMap = new HashMap<>(); valueMap.put("id", null == resourceRecipe || null == resourceRecipe.getId() ? StringUtils.EMPTY : String.valueOf(resourceRecipe.getId())); valueMap.put("action", null == resourceRecipe || null == resourceRecipe.getAction() ? StringUtils.EMPTY : resourceRecipe.getAction()); valueMap.put("orchestrationUri", null == resourceRecipe || null == resourceRecipe.getOrchestrationUri() ? StringUtils.EMPTY : resourceRecipe.getOrchestrationUri()); valueMap.put("recipeTimeout", null == resourceRecipe || null == resourceRecipe.getRecipeTimeout() ? StringUtils.EMPTY : String.valueOf(resourceRecipe.getRecipeTimeout())); valueMap.put("paramXSD", null == resourceRecipe || null == resourceRecipe.getParamXsd() ? StringUtils.EMPTY : resourceRecipe.getParamXsd()); valueMap.put("description", null == resourceRecipe || null == resourceRecipe.getDescription() ? StringUtils.EMPTY : resourceRecipe.getDescription()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); String jsonStr = ""; try { jsonStr = mapper.writeValueAsString(valueMap); } catch (JsonProcessingException e) { logger.error("Error creating JSON", e); } return jsonStr; } QueryResourceRecipe(Recipe resourceRecipe); @Override String toString(); @Override String JSON2(boolean isArray, boolean isEmbed);  }### Answer:
@Test public void convertingToJsonSuccessful() { String jsonResult = testedObject.JSON2(true, true); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.id")).contains(String.valueOf(RECIPE_ID)); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.action")).contains(RECIPE_ACTION); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.orchestrationUri")).contains(RECIPE_URI); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.recipeTimeout")) .contains(String.valueOf(RECIPE_TIMEOUT)); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.paramXSD")).contains(RECIPE_PARAMS_XSD); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.description")).contains(RECIPE_DESCRIPTION); }
@Test public void convertToJson() { Recipe recipe = createRecipe(); QueryResourceRecipe queryResourceRecipe = new QueryResourceRecipe(recipe); assertEquals( "{\"orchestrationUri\":\"uriTest\",\"action\":\"actionTest\",\"description\":\"descrTest\",\"id\":\"123\",\"recipeTimeout\":\"100\",\"paramXSD\":\"paramsXsdTest\"}", queryResourceRecipe.JSON2(false, false)); }
@Test public void convertToJsonEmptyRecipe() { QueryResourceRecipe vnfQueryRR = new QueryResourceRecipe(new VnfRecipe()); QueryResourceRecipe networkQueryRR = new QueryResourceRecipe(new NetworkRecipe()); QueryResourceRecipe arQueryRR = new QueryResourceRecipe(new ArRecipe()); String expected = "{\"orchestrationUri\":\"\",\"action\":\"\",\"description\":\"\",\"id\":\"\",\"recipeTimeout\":\"\",\"paramXSD\":\"\"}"; assertEquals(expected, vnfQueryRR.JSON2(false, false)); assertEquals(expected, networkQueryRR.JSON2(false, false)); assertEquals(expected, arQueryRR.JSON2(false, false)); }