Set<TaskId> assignedTasks() {
        final Set<TaskId> assignedActiveTaskIds = assignedActiveTasks.taskIds();
        final Set<TaskId> assignedStandbyTaskIds = assignedStandbyTasks.taskIds();
        // Since we're copying it, it's not strictly necessary to make it unmodifiable also.
        // I'm just trying to prevent subtle bugs if we write code that thinks it can update
        // the assignment by updating the returned set.
        return unmodifiableSet(
            union(
                () -> new HashSet<>(assignedActiveTaskIds.size() + assignedStandbyTaskIds.size()),
                assignedActiveTaskIds,
                assignedStandbyTaskIds
            )
        );
    }
@Test
    public void shouldNotModifyAssignedView() {
        final ClientState clientState = new ClientState(1);
        final Set<TaskId> taskIds = clientState.assignedTasks();
        assertThrows(UnsupportedOperationException.class, () -> taskIds.add(TASK_0_0));
        assertThat(clientState, hasActiveTasks(0));
        assertThat(clientState, hasStandbyTasks(0));
    }