@Test public void testNode() throws Exception { String jsonText = ChefUtil.createNode(name1); ChefUtil.putNodeAttribute(name1, "__TRANSCEND_TEST__", name1); logger.debug(jsonText); assertThat("Node is created.", jsonText, containsString(name1)); jsonText = ChefUtil.getNode(name1); logger.debug(jsonText); JsonNode json = JsonUtil.load(jsonText); // logger.debug(JsonUtil.toJsonPrettyPrintString(json)); assertThat("Node name is correct.", json.get("name").getTextValue(), is(name1)); }
@Test public void testSearchNode() throws Exception { try { ChefUtil.createNode(name1); ChefUtil.putNodeAttribute(name1, "__TRANSCEND_TEST__", name1); } catch (Exception e) { // ignore failure; may have already been created. } // Search for :"name:chefutil-*"; String search = "name%3A" + name1.substring(0, 9) + "*"; final List<String> nodes = ChefUtil.searchNodes(search); // final JsonNode jsonNodes = JsonUtil.load(nodes); for (String node : nodes) { JsonNode json = JsonUtil.load(node); logger.debug(JsonUtil.toJsonPrettyPrintString(json)); } }
@Test public void testNodeUpdateRunlist() throws Exception { try { ChefUtil.createNode(name1); ChefUtil.putNodeAttribute(name1, "__TRANSCEND_TEST__", name1); } catch (Exception e) { // ignore failure; may have already been created. } String jsonText = ChefUtil.putNodeRunlist(name1, "role[transcend_defaultrole]"); logger.debug(jsonText); jsonText = ChefUtil.getNode(name1); JsonNode json = JsonUtil.load(jsonText); logger.debug(JsonUtil.toJsonPrettyPrintString(json)); assertThat("Node name is correct.", json.get("name").getTextValue(), is(name1)); assertThat( "Node attributes are intact.", json.get("normal").toString(), containsString("__TRANSCEND_TEST__")); }