public boolean hasState() {
        for (OperatorSubtaskState operatorSubtaskState : subtaskStatesByOperatorID.values()) {
            if (operatorSubtaskState != null && operatorSubtaskState.hasState()) {
                return true;
            }
        }
        return isTaskDeployedAsFinished;
    }
@Test
    void hasState() {
        Random random = new Random(0x42);
        TaskStateSnapshot taskStateSnapshot = new TaskStateSnapshot();
        assertThat(taskStateSnapshot.hasState()).isFalse();

        OperatorSubtaskState emptyOperatorSubtaskState = OperatorSubtaskState.builder().build();
        assertThat(emptyOperatorSubtaskState.hasState()).isFalse();
        taskStateSnapshot.putSubtaskStateByOperatorID(new OperatorID(), emptyOperatorSubtaskState);
        assertThat(taskStateSnapshot.hasState()).isFalse();

        OperatorStateHandle stateHandle =
                StateHandleDummyUtil.createNewOperatorStateHandle(2, random);
        OperatorSubtaskState nonEmptyOperatorSubtaskState =
                OperatorSubtaskState.builder().setManagedOperatorState(stateHandle).build();

        assertThat(nonEmptyOperatorSubtaskState.hasState()).isTrue();
        taskStateSnapshot.putSubtaskStateByOperatorID(
                new OperatorID(), nonEmptyOperatorSubtaskState);
        assertThat(taskStateSnapshot.hasState()).isTrue();
    }