@Test public void does_not_fail_when_subject_param_is_missing() throws Exception { logInAsSystemAdministrator(); executeRequest("john@doo.com", null, "This is a test message from SonarQube at http://localhost:9000"); verify(emailNotificationChannel).sendTestEmail("john@doo.com", null, "This is a test message from SonarQube at http://localhost:9000"); }
@Test public void fail_with_BadRequestException_when_EmailException_is_generated() throws Exception { logInAsSystemAdministrator(); IllegalArgumentException exception1 = new IllegalArgumentException("root cause"); IllegalArgumentException exception2 = new IllegalArgumentException("parent cause", exception1); IllegalArgumentException exception3 = new IllegalArgumentException("child cause", exception2); EmailException emailException = new EmailException("last message", exception3); doThrow(emailException).when(emailNotificationChannel).sendTestEmail(anyString(), anyString(), anyString()); try { executeRequest("john@doo.com", "Test Message from SonarQube", "This is a test message from SonarQube at http://localhost:9000"); fail(); } catch (BadRequestException e) { assertThat(e.errors()).containsExactly( "root cause", "parent cause", "child cause", "last message"); } }
@Test public void send_test_email() throws Exception { logInAsSystemAdministrator(); executeRequest("john@doo.com", "Test Message from SonarQube", "This is a test message from SonarQube at http://localhost:9000"); verify(emailNotificationChannel).sendTestEmail("john@doo.com", "Test Message from SonarQube", "This is a test message from SonarQube at http://localhost:9000"); }
@Test public void fail_when_message_param_is_missing() { logInAsSystemAdministrator(); expectedException.expect(IllegalArgumentException.class); executeRequest("john@doo.com", "Test Message from SonarQube", null); }
@Test public void fail_when_to_param_is_missing() { logInAsSystemAdministrator(); expectedException.expect(IllegalArgumentException.class); executeRequest(null, "Test Message from SonarQube", "This is a test message from SonarQube at http://localhost:9000"); }