### Question:
JobPlanner { static List<Set<ClusterTask>> deDupNodePerStage(List<Set<ClusterTask>> tasks) { List<Map<String, ClusterTask>> deDupTasks = Lists.newArrayList(); for (Set<ClusterTask> stage : tasks) { List<Map<String, ClusterTask>> newStages = Lists.newArrayList(); for (ClusterTask task : stage) { if (!addToExistingStage(task, newStages)) { Map<String, ClusterTask> newStage = Maps.newHashMap(); newStage.put(task.getNodeId(), task); newStages.add(newStage); } } deDupTasks.addAll(newStages); } return Lists.newArrayList(Iterables.transform(deDupTasks, MAP_CLUSTER_TASK_FUNCTION)); } JobPlanner(ClusterJob job, Set<Node> clusterNodes); Map<String, Service> getServiceMap(); Map<String, Node> getNodeMap(); List<Set<TaskNode>> linearizeDependentTasks();  }### Answer:
@Test public void testDedupNodesPerStage() throws Exception { List<Set<ClusterTask>> tasks = ImmutableList.of( createSortedSet(createClusterTask("INSTALL", "1-1-1", "host1"), createClusterTask("CONFIGURE", "1-1-2", "host1"), createClusterTask("INSTALL", "1-1-3", "host3")), createSortedSet(createClusterTask("INSTALL", "1-1-12", "host1"), createClusterTask("INSTALL", "1-1-22", "host2"), createClusterTask("INSTALL", "1-1-32", "host3")), createSortedSet(createClusterTask("INSTALL", "1-1-13", "host1"), createClusterTask("CONFIGURE", "1-1-22", "host1"), createClusterTask("INSTALL", "1-1-32", "host3")) ); List<Set<ClusterTask>> actual = JobPlanner.deDupNodePerStage(tasks); List<Set<ClusterTask>> expected = ImmutableList.of( createSortedSet(createClusterTask("INSTALL", "1-1-1", "host1"), createClusterTask("INSTALL", "1-1-3", "host3")), createSortedSet(createClusterTask("CONFIGURE", "1-1-2", "host1")), createSortedSet(createClusterTask("INSTALL", "1-1-12", "host1"), createClusterTask("INSTALL", "1-1-22", "host2"), createClusterTask("INSTALL", "1-1-32", "host3")), createSortedSet(createClusterTask("INSTALL", "1-1-13", "host1"), createClusterTask("INSTALL", "1-1-32", "host3")), createSortedSet(createClusterTask("CONFIGURE", "1-1-22", "host1")) ); Assert.assertEquals(expected, actual); }