@Test public void getRecipient_should_return_ran_email_address_for_valid_and_not_blocking_execution() { long projectId = 42; ExecutionDTO execution = validExecution(); when(settingService.get(projectId, Settings.EMAIL_TO_EXECUTION_RAN)).thenReturn("to"); final Optional<String> to = cut.getRecipient(projectId, execution); assertThat(to.orElse("absent")).isEqualTo("to"); }
Optional<String> getRecipient(long projectId, ExecutionDTO execution) { if (crashed(execution)) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_CRASHED); } else if (!execution.isBlockingValidation()) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_RAN); } else if (execution.getQualityStatus() == QualityStatus.WARNING) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_WARNING); } else if (execution.getQualityStatus() == QualityStatus.PASSED) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_PASSED); } else { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_NOT_ELIGIBLE); } }
QualityEmailService { Optional<String> getRecipient(long projectId, ExecutionDTO execution) { if (crashed(execution)) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_CRASHED); } else if (!execution.isBlockingValidation()) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_RAN); } else if (execution.getQualityStatus() == QualityStatus.WARNING) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_WARNING); } else if (execution.getQualityStatus() == QualityStatus.PASSED) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_PASSED); } else { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_NOT_ELIGIBLE); } } }
QualityEmailService { Optional<String> getRecipient(long projectId, ExecutionDTO execution) { if (crashed(execution)) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_CRASHED); } else if (!execution.isBlockingValidation()) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_RAN); } else if (execution.getQualityStatus() == QualityStatus.WARNING) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_WARNING); } else if (execution.getQualityStatus() == QualityStatus.PASSED) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_PASSED); } else { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_NOT_ELIGIBLE); } }  }
QualityEmailService { Optional<String> getRecipient(long projectId, ExecutionDTO execution) { if (crashed(execution)) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_CRASHED); } else if (!execution.isBlockingValidation()) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_RAN); } else if (execution.getQualityStatus() == QualityStatus.WARNING) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_WARNING); } else if (execution.getQualityStatus() == QualityStatus.PASSED) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_PASSED); } else { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_NOT_ELIGIBLE); } }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId); }
QualityEmailService { Optional<String> getRecipient(long projectId, ExecutionDTO execution) { if (crashed(execution)) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_CRASHED); } else if (!execution.isBlockingValidation()) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_RAN); } else if (execution.getQualityStatus() == QualityStatus.WARNING) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_WARNING); } else if (execution.getQualityStatus() == QualityStatus.PASSED) { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_ELIGIBLE_PASSED); } else { return configuredEmail(projectId, Settings.EMAIL_TO_EXECUTION_NOT_ELIGIBLE); } }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId);  }