use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class SetTypeActionTest method newIssue.
private IssueDto newIssue() {
RuleDto rule = db.rules().insertRule(newRuleDto());
ComponentDto project = db.components().insertProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
return newDto(rule, file, project);
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueFinderTest method insertIssue.
private IssueDto insertIssue() {
RuleDto rule = ruleDbTester.insertRule(newRuleDto());
ComponentDto project = componentDbTester.insertProject();
ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
return issueDbTester.insertIssue(newDto(rule, file, project));
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueServiceMediumTest method assign.
@Test
public void assign() {
RuleDto rule = newRule();
ComponentDto project = newProject();
ComponentDto file = newFile(project);
userSessionRule.logIn("john").addProjectUuidPermissions(UserRole.USER, project.uuid());
IssueDto issue = saveIssue(IssueTesting.newDto(rule, file, project));
UserDto user = new UserDto().setLogin("perceval").setName("Perceval");
db.userDao().insert(session, user);
session.commit();
index();
assertThat(getIssueByKey(issue.getKey()).assignee()).isNull();
service.assign(issue.getKey(), user.getLogin());
assertThat(getIssueByKey(issue.getKey()).assignee()).isEqualTo("perceval");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueServiceMediumTest method list_component_tags.
@Test
public void list_component_tags() {
RuleDto rule = newRule();
ComponentDto project = newProject();
ComponentDto file = newFile(project);
saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention", "java8", "bug")));
saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention", "bug")));
saveIssue(IssueTesting.newDto(rule, file, project));
saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention", "java8", "bug")).setResolution(Issue.RESOLUTION_FIXED));
saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention")));
assertThat(service.listTagsForComponent(projectQuery(project.uuid()), 5)).containsOnly(entry("convention", 3L), entry("bug", 2L), entry("java8", 1L));
assertThat(service.listTagsForComponent(projectQuery(project.uuid()), 2)).contains(entry("convention", 3L), entry("bug", 2L)).doesNotContainEntry("java8", 1L);
assertThat(service.listTagsForComponent(projectQuery("other"), 10)).isEmpty();
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueServiceMediumTest method set_tags.
@Test
public void set_tags() {
RuleDto rule = newRule();
ComponentDto project = newProject();
ComponentDto file = newFile(project);
userSessionRule.logIn("john").addProjectUuidPermissions(UserRole.USER, project.uuid());
IssueDto issue = saveIssue(IssueTesting.newDto(rule, file, project));
assertThat(getIssueByKey(issue.getKey()).tags()).isEmpty();
// Tags are lowercased
service.setTags(issue.getKey(), ImmutableSet.of("bug", "Convention"));
assertThat(getIssueByKey(issue.getKey()).tags()).containsOnly("bug", "convention");
// nulls and empty tags are ignored
service.setTags(issue.getKey(), Sets.newHashSet("security", null, "", "convention"));
assertThat(getIssueByKey(issue.getKey()).tags()).containsOnly("security", "convention");
// tag validation
try {
service.setTags(issue.getKey(), ImmutableSet.of("pol op"));
} catch (Exception exception) {
assertThat(exception).isInstanceOf(IllegalArgumentException.class);
}
assertThat(getIssueByKey(issue.getKey()).tags()).containsOnly("security", "convention");
// unchanged tags
service.setTags(issue.getKey(), ImmutableSet.of("convention", "security"));
assertThat(getIssueByKey(issue.getKey()).tags()).containsOnly("security", "convention");
service.setTags(issue.getKey(), ImmutableSet.<String>of());
assertThat(getIssueByKey(issue.getKey()).tags()).isEmpty();
}
Aggregations