### Question:
ClusterPollingCheckerService { @Nullable public AttemptResult<Object> checkClusterCancelledState(Cluster cluster, boolean cancellable) { checkArgument(cluster != null, "Cluster must not be null!"); AttemptResult<Object> result = null; if (cancellable && PollGroup.CANCELLED.equals(InMemoryStateStore.getCluster(cluster.getId()))) { LOGGER.info("Cluster wait polling cancelled in inmemory store, id: {}", cluster.getId()); result = AttemptResults.breakFor("Cluster wait polling cancelled in inmemory store, id: " + cluster.getId()); } return result; }  @Nullable AttemptResult<Object> checkClusterCancelledState(Cluster cluster, boolean cancellable);  }### Answer:
@Test void nullClusterThrows() { assertThatThrownBy(() -> underTest.checkClusterCancelledState(null, true)).isInstanceOf(IllegalArgumentException.class); }
@Test void nonCancellableReturnsNull() { Cluster cluster = new Cluster(); cluster.setId(1L); AttemptResult<Object> result = underTest.checkClusterCancelledState(cluster, false); assertThat(result).isNull(); }
@Test void cancellableButNotCancelledReturnsNull() { Cluster cluster = new Cluster(); cluster.setId(1L); InMemoryStateStore.putCluster(1L, PollGroup.POLLABLE); AttemptResult<Object> result = underTest.checkClusterCancelledState(cluster, true); assertThat(result).isNull(); }
@Test void cancellableAndCancelledReturnsBreak() { Cluster cluster = new Cluster(); cluster.setId(1L); InMemoryStateStore.putCluster(1L, PollGroup.CANCELLED); AttemptResult<Object> result = underTest.checkClusterCancelledState(cluster, true); assertThat(result).isNotNull(); assertThat(result.getState()).isEqualTo(AttemptState.BREAK); }