### Question:
DatabaseObtainerService { AttemptResult<Object> obtainAttemptResult(Cluster cluster, DatabaseOperation databaseOperation, String databaseCrn, boolean cancellable) throws JsonProcessingException { Optional<AttemptResult<Object>> result = Optional.ofNullable(clusterPollingCheckerService.checkClusterCancelledState(cluster, cancellable)); if (result.isEmpty()) { checkArgument(cluster != null, "Cluster must not be null"); try { LOGGER.info("Creation polling redbeams for database status: '{}'", cluster.getName()); DatabaseServerV4Response rdsStatus = redbeamsClient.getByCrn(databaseCrn); LOGGER.info("Response from redbeams: {}", JsonUtil.writeValueAsString(rdsStatus)); result = Optional.of(databaseCriteriaResolver.resolveResultByCriteria(databaseOperation, rdsStatus, cluster)); } catch (NotFoundException e) { result = Optional.of(AttemptResults.finishWith(null)); } } return result.get(); } DatabaseObtainerService(RedbeamsClientService redbeamsClient, ClusterPollingCheckerService clusterPollingCheckerService,
            DatabaseCriteriaResolver databaseCriteriaResolver);   }### Answer:
@Test void cancelledStateIsNull() throws JsonProcessingException { AttemptResult<Object> attemptResult = AttemptResults.justContinue(); when(clusterPollingCheckerService.checkClusterCancelledState(any(), anyBoolean())).thenReturn(attemptResult); AttemptResult<Object> result = underTest.obtainAttemptResult(cluster, DatabaseOperation.CREATION, "crn", true); assertThat(result.getState()).isEqualTo(attemptResult.getState()); }
@Test void rdsNotFound() throws JsonProcessingException { when(clusterPollingCheckerService.checkClusterCancelledState(any(), anyBoolean())).thenReturn(null); when(redbeamsClient.getByCrn(anyString())).thenThrow(NotFoundException.class); AttemptResult<Object> result = underTest.obtainAttemptResult(cluster, DatabaseOperation.CREATION, "crn", true); assertThat(result.getState()).isEqualTo(AttemptState.FINISH); assertThat(result.getResult()).isNull(); }
@Test void attemptResultObtained() throws JsonProcessingException { when(clusterPollingCheckerService.checkClusterCancelledState(any(), anyBoolean())).thenReturn(null); when(redbeamsClient.getByCrn(anyString())).thenReturn(new DatabaseServerV4Response()); AttemptResult<Object> attemptResult = AttemptResults.justContinue(); when(databaseCriteriaResolver.resolveResultByCriteria(any(), any(), any())).thenReturn(attemptResult); AttemptResult<Object> result = underTest.obtainAttemptResult(cluster, DatabaseOperation.CREATION, "crn", true); assertThat(result.getState()).isEqualTo(attemptResult.getState()); assertThat(result.getResult()).isNull(); }