use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.
the class NotificationFactoryTest method newNewIssuesNotification_DetailsSupplier_getRuleDefinitionByRuleKey_fails_with_NPE_if_ruleKey_is_null.
@Test
public void newNewIssuesNotification_DetailsSupplier_getRuleDefinitionByRuleKey_fails_with_NPE_if_ruleKey_is_null() {
NewIssuesNotification underTest = this.underTest.newNewIssuesNotification(emptyMap());
DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
assertThatThrownBy(() -> detailsSupplier.getRuleDefinitionByRuleKey(null)).isInstanceOf(NullPointerException.class).hasMessage("ruleKey can't be null");
}
use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.
the class NotificationFactoryTest method newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_returns_empty_if_user_has_null_name.
@Test
public void newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_returns_empty_if_user_has_null_name() {
UserDto user = UserTesting.newUserDto().setLogin("user_noname").setName(null);
MyNewIssuesNotification underTest = this.underTest.newMyNewIssuesNotification(ImmutableMap.of(user.getUuid(), user));
DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
assertThat(detailsSupplier.getUserNameByUuid(user.getUuid())).isEmpty();
}
use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.
the class NotificationFactoryTest method newNewIssuesNotification_DetailsSupplier_getComponentNameByUuid_returns_shortName_of_dir_and_file_in_TreeRootHolder.
@Test
public void newNewIssuesNotification_DetailsSupplier_getComponentNameByUuid_returns_shortName_of_dir_and_file_in_TreeRootHolder() {
treeRootHolder.setRoot(ReportComponent.builder(PROJECT, 1).setUuid("rootUuid").setName("root").addChildren(ReportComponent.builder(DIRECTORY, 2).setUuid("dir1Uuid").setName("dir1").setShortName("dir1_short").addChildren(ReportComponent.builder(FILE, 21).setUuid("file21Uuid").setName("file21").setShortName("file21_short").build()).build()).addChildren(ReportComponent.builder(DIRECTORY, 3).setUuid("dir2Uuid").setName("dir2").setShortName("dir2_short").addChildren(ReportComponent.builder(FILE, 31).setUuid("file31Uuid").setName("file31").setShortName("file31_short").build()).addChildren(ReportComponent.builder(FILE, 32).setUuid("file32Uuid").setName("file32").setShortName("file32_short").build()).build()).addChildren(ReportComponent.builder(FILE, 11).setUuid("file11Uuid").setName("file11").setShortName("file11_short").build()).build());
NewIssuesNotification underTest = this.underTest.newNewIssuesNotification(emptyMap());
DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
Stream.of("dir1", "dir2", "file11", "file21", "file31", "file32").forEach(name -> {
assertThat(detailsSupplier.getComponentNameByUuid(name + "Uuid")).contains(name + "_short");
assertThat(detailsSupplier.getComponentNameByUuid(name)).isEmpty();
});
}
use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.
the class NotificationFactoryTest method newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_returns_name_of_user_from_map_argument.
@Test
public void newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_returns_name_of_user_from_map_argument() {
Set<UserDto> users = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> UserTesting.newUserDto().setLogin("user" + i)).collect(Collectors.toSet());
MyNewIssuesNotification underTest = this.underTest.newMyNewIssuesNotification(users.stream().collect(uniqueIndex(UserDto::getUuid)));
DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
assertThat(detailsSupplier.getUserNameByUuid("foo")).isEmpty();
users.forEach(user -> assertThat(detailsSupplier.getUserNameByUuid(user.getUuid())).contains(user.getName()));
}
use of org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier in project sonarqube by SonarSource.
the class NotificationFactoryTest method newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_always_returns_empty_if_map_argument_is_empty.
@Test
public void newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_always_returns_empty_if_map_argument_is_empty() {
MyNewIssuesNotification underTest = this.underTest.newMyNewIssuesNotification(emptyMap());
DetailsSupplier detailsSupplier = readDetailsSupplier(underTest);
assertThat(detailsSupplier.getUserNameByUuid("foo")).isEmpty();
}
Aggregations