@Test public void testJSONConversionWithSpecificRecipe() { Recipe postgresql = new Recipe("postgresql", "server"); assertEquals("JSON representation is incorrect.", POSTGRES_JSON, postgresql.toJSON()); }
public String toJSON() { Gson gson = new Gson(); JsonObject recipeAsJSON = new JsonObject(); if (!attribs.isEmpty()) { JsonObject jsonAttribs = new JsonObject(); for (Map.Entry<String, Object> entry : attribs.entrySet()) { jsonAttribs.add(entry.getKey(), gson.toJsonTree(entry.getValue())); } recipeAsJSON.add(cookbook, jsonAttribs); } recipeAsJSON.add( "run_list", gson.toJsonTree(new String[] { "recipe[" + cookbook + (recipe != null ? ("::" + recipe) : "") + "]" })); return gson.toJson(recipeAsJSON); }
Recipe implements Statement { public String toJSON() { Gson gson = new Gson(); JsonObject recipeAsJSON = new JsonObject(); if (!attribs.isEmpty()) { JsonObject jsonAttribs = new JsonObject(); for (Map.Entry<String, Object> entry : attribs.entrySet()) { jsonAttribs.add(entry.getKey(), gson.toJsonTree(entry.getValue())); } recipeAsJSON.add(cookbook, jsonAttribs); } recipeAsJSON.add( "run_list", gson.toJsonTree(new String[] { "recipe[" + cookbook + (recipe != null ? ("::" + recipe) : "") + "]" })); return gson.toJson(recipeAsJSON); } }
Recipe implements Statement { public String toJSON() { Gson gson = new Gson(); JsonObject recipeAsJSON = new JsonObject(); if (!attribs.isEmpty()) { JsonObject jsonAttribs = new JsonObject(); for (Map.Entry<String, Object> entry : attribs.entrySet()) { jsonAttribs.add(entry.getKey(), gson.toJsonTree(entry.getValue())); } recipeAsJSON.add(cookbook, jsonAttribs); } recipeAsJSON.add( "run_list", gson.toJsonTree(new String[] { "recipe[" + cookbook + (recipe != null ? ("::" + recipe) : "") + "]" })); return gson.toJson(recipeAsJSON); } Recipe(String cookbook);  Recipe(String cookbook, String recipe);  Recipe(String cookbook, String recipe, String url);   Recipe(String cookbook, String recipe, Configuration config); }
Recipe implements Statement { public String toJSON() { Gson gson = new Gson(); JsonObject recipeAsJSON = new JsonObject(); if (!attribs.isEmpty()) { JsonObject jsonAttribs = new JsonObject(); for (Map.Entry<String, Object> entry : attribs.entrySet()) { jsonAttribs.add(entry.getKey(), gson.toJsonTree(entry.getValue())); } recipeAsJSON.add(cookbook, jsonAttribs); } recipeAsJSON.add( "run_list", gson.toJsonTree(new String[] { "recipe[" + cookbook + (recipe != null ? ("::" + recipe) : "") + "]" })); return gson.toJson(recipeAsJSON); } Recipe(String cookbook);  Recipe(String cookbook, String recipe);  Recipe(String cookbook, String recipe, String url);   Recipe(String cookbook, String recipe, Configuration config); String toJSON(); @Override Iterable<String> functionDependencies(OsFamily family); @Override String render(OsFamily family); static RunScriptOptions recipeScriptOptions(RunScriptOptions options); }
Recipe implements Statement { public String toJSON() { Gson gson = new Gson(); JsonObject recipeAsJSON = new JsonObject(); if (!attribs.isEmpty()) { JsonObject jsonAttribs = new JsonObject(); for (Map.Entry<String, Object> entry : attribs.entrySet()) { jsonAttribs.add(entry.getKey(), gson.toJsonTree(entry.getValue())); } recipeAsJSON.add(cookbook, jsonAttribs); } recipeAsJSON.add( "run_list", gson.toJsonTree(new String[] { "recipe[" + cookbook + (recipe != null ? ("::" + recipe) : "") + "]" })); return gson.toJson(recipeAsJSON); } Recipe(String cookbook);  Recipe(String cookbook, String recipe);  Recipe(String cookbook, String recipe, String url);   Recipe(String cookbook, String recipe, Configuration config); String toJSON(); @Override Iterable<String> functionDependencies(OsFamily family); @Override String render(OsFamily family); static RunScriptOptions recipeScriptOptions(RunScriptOptions options); final String cookbook; final String recipe; public String url; final Map<String, Object> attribs; }