### Question:
NodeTree { public NodeTree withAll(Map<String, Integer> values) { NodeTree ret = this; for (Map.Entry<String, Integer> ent : values.entrySet()) { ret = ret.withValue(ent.getKey(), ent.getValue()); } return ret; } 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 testWithAll() { 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); final Map<String, Integer> newPermissions = new HashMap<>(); newPermissions.put("generate.sunset.red", 1); newPermissions.put("generate.thunderstorm.explosive", 0); newPermissions.put("something.new", -1); NodeTree newTree = oldTree.withAll(newPermissions); assertEquals(-1, oldTree.get("generate.sunset.red")); assertEquals(1, newTree.get("generate.sunset.red")); assertEquals(-1, oldTree.get("generate.thunderstorm.explosive")); assertEquals(0, newTree.get("generate.thunderstorm.explosive")); assertEquals(0, oldTree.get("something.new")); assertEquals(-1, newTree.get("something.new")); }