### Question:
NodeTree { public Map<String, Integer> asMap() { ImmutableMap.Builder<String, Integer> ret = ImmutableMap.builder(); for (Map.Entry<String, Node> ent : this.rootNode.children.entrySet()) { populateMap(ret, ent.getKey(), ent.getValue()); } return ret.build(); } private  NodeTree(int value); private  NodeTree(Node rootNode); static NodeTree of(Map<String, Integer> values); static NodeTree of(Map<String, Integer> values, int defaultValue); int get(String node); Map<String, Integer> asMap(); NodeTree withValue(String node, int value); NodeTree withAll(Map<String, Integer> values); static final int PERMISSION_UNDEFINED; }### Answer:
@Test public void testAsMap() { final Map<String, Integer> testPermissions = new HashMap<>(); testPermissions.put("generate.rainbow", 1); testPermissions.put("generate.sunset", -1); testPermissions.put("generate", 1); testPermissions.put("generate.thunderstorm.explosive", -1); NodeTree oldTree = NodeTree.of(testPermissions); assertEquals(testPermissions, oldTree.asMap()); }