Search in sources :

Example 16 with DetailsSupplier

use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.

the class NotificationFactoryTest method newMyNewIssuesNotification_DetailsSupplier_getComponentNameByUuid_fails_with_NPE_if_uuid_is_null.

@Test
public void newMyNewIssuesNotification_DetailsSupplier_getComponentNameByUuid_fails_with_NPE_if_uuid_is_null() {
    treeRootHolder.setRoot(ReportComponent.builder(PROJECT, 1).setUuid("rootUuid").setName("root").build());
    MyNewIssuesNotification underTest = this.underTest.newMyNewIssuesNotification(emptyMap());
    DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
    assertThatThrownBy(() -> detailsSupplier.getComponentNameByUuid(null)).isInstanceOf(NullPointerException.class).hasMessage("uuid can't be null");
}
Also used : MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) DetailsSupplier(org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier) Test(org.junit.Test)

Example 17 with DetailsSupplier

use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.

the class NotificationFactoryTest method newNewIssuesNotification_DetailsSupplier_getComponentNameByUuid_fails_with_ISE_if_TreeRootHolder_is_not_initialized.

@Test
public void newNewIssuesNotification_DetailsSupplier_getComponentNameByUuid_fails_with_ISE_if_TreeRootHolder_is_not_initialized() {
    NewIssuesNotification underTest = this.underTest.newNewIssuesNotification(emptyMap());
    DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
    assertThatThrownBy(() -> detailsSupplier.getComponentNameByUuid("foo")).isInstanceOf(IllegalStateException.class).hasMessage("Holder has not been initialized yet");
}
Also used : NewIssuesNotification(org.sonar.server.issue.notification.NewIssuesNotification) MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) DetailsSupplier(org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier) Test(org.junit.Test)

Example 18 with DetailsSupplier

use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.

the class NotificationFactoryTest method newNewIssuesNotification_DetailsSupplier_getUserNameByUuid_returns_empty_if_user_has_null_name.

@Test
public void newNewIssuesNotification_DetailsSupplier_getUserNameByUuid_returns_empty_if_user_has_null_name() {
    UserDto user = UserTesting.newUserDto().setLogin("user_noname").setName(null);
    NewIssuesNotification underTest = this.underTest.newNewIssuesNotification(ImmutableMap.of(user.getUuid(), user));
    DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
    assertThat(detailsSupplier.getUserNameByUuid(user.getUuid())).isEmpty();
}
Also used : NewIssuesNotification(org.sonar.server.issue.notification.NewIssuesNotification) MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) UserDto(org.sonar.db.user.UserDto) DetailsSupplier(org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier) Test(org.junit.Test)

Example 19 with DetailsSupplier

use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.

the class NotificationFactoryTest method newMyNewIssuesNotification_DetailsSupplier_getRuleDefinitionByRuleKey_fails_with_NPE_if_ruleKey_is_null.

@Test
public void newMyNewIssuesNotification_DetailsSupplier_getRuleDefinitionByRuleKey_fails_with_NPE_if_ruleKey_is_null() {
    MyNewIssuesNotification underTest = this.underTest.newMyNewIssuesNotification(emptyMap());
    DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
    assertThatThrownBy(() -> detailsSupplier.getRuleDefinitionByRuleKey(null)).isInstanceOf(NullPointerException.class).hasMessage("ruleKey can't be null");
}
Also used : MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) DetailsSupplier(org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier) Test(org.junit.Test)

Example 20 with DetailsSupplier

use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.

the class NotificationFactoryTest method newNewIssuesNotification_DetailsSupplier_getRuleDefinitionByRuleKey_always_returns_empty_if_RuleRepository_is_empty.

@Test
public void newNewIssuesNotification_DetailsSupplier_getRuleDefinitionByRuleKey_always_returns_empty_if_RuleRepository_is_empty() {
    NewIssuesNotification underTest = this.underTest.newNewIssuesNotification(emptyMap());
    DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
    assertThat(detailsSupplier.getRuleDefinitionByRuleKey(RuleKey.of("foo", "bar"))).isEmpty();
    assertThat(detailsSupplier.getRuleDefinitionByRuleKey(RuleKey.of("bar", "foo"))).isEmpty();
}
Also used : NewIssuesNotification(org.sonar.server.issue.notification.NewIssuesNotification) MyNewIssuesNotification(org.sonar.server.issue.notification.MyNewIssuesNotification) DetailsSupplier(org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier) Test(org.junit.Test)

Aggregations

DetailsSupplier (org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier)23 Test (org.junit.Test)22 MyNewIssuesNotification (org.sonar.server.issue.notification.MyNewIssuesNotification)22 NewIssuesNotification (org.sonar.server.issue.notification.NewIssuesNotification)12 RuleKey (org.sonar.api.rule.RuleKey)4 DumbRule (org.sonar.ce.task.projectanalysis.issue.DumbRule)4 RuleDefinition (org.sonar.server.issue.notification.NewIssuesNotification.RuleDefinition)4 Field (java.lang.reflect.Field)3 UserDto (org.sonar.db.user.UserDto)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)2 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Collections (java.util.Collections)2 Collections.emptyMap (java.util.Collections.emptyMap)2 Map (java.util.Map)2 Random (java.util.Random)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2