@Test
public void verifyDeDupTaskIds() {

    List<String> expectedIdList = new ArrayList<String>() {{
        add("task1");
        add("task2");
        add("task3");
        add("task4");
    }};
    // with duplicate ids
    List<Task> activeTasks = new ArrayList<>();
    activeTasks.add(Task.newBuilder().setId("task1").build());
    activeTasks.add(Task.newBuilder().setId("task2").build());
    activeTasks.add(Task.newBuilder().setId("task3").build());
    List<Task> archivedTasks = new ArrayList<>();
    archivedTasks.add(Task.newBuilder().setId("task2").build());
    archivedTasks.add(Task.newBuilder().setId("task3").build());
    archivedTasks.add(Task.newBuilder().setId("task4").build());
    List<Task> tasks = GatewayJobServiceGateway.deDupTasks(activeTasks, archivedTasks);
    assertThat(tasks.size()).isEqualTo(4);
    List<String> taskIds = tasks.stream().map(Task::getId).sorted().collect(Collectors.toList());
    assertThat(taskIds).isEqualTo(expectedIdList);
    // disjoint lists
    activeTasks = new ArrayList<>();
    activeTasks.add(Task.newBuilder().setId("task1").build());
    activeTasks.add(Task.newBuilder().setId("task2").build());
    archivedTasks = new ArrayList<>();
    archivedTasks.add(Task.newBuilder().setId("task3").build());
    archivedTasks.add(Task.newBuilder().setId("task4").build());
    tasks = GatewayJobServiceGateway.deDupTasks(activeTasks, archivedTasks);
    assertThat(tasks.size()).isEqualTo(4);
    taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList());
    Collections.sort(taskIds);
    assertThat(taskIds).isEqualTo(expectedIdList);
}