use of org.sonar.db.issue.IssueDto 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.issue.IssueDto 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();
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class TransitionServiceTest method list_transitions.
@Test
public void list_transitions() throws Exception {
IssueDto issue = newIssue().setStatus(STATUS_OPEN).setResolution(null);
userSession.logIn("john").addProjectUuidPermissions(ISSUE_ADMIN, issue.getProjectUuid());
List<Transition> result = underTest.listTransitions(issue.toDefaultIssue());
assertThat(result).extracting(Transition::key).containsOnly("confirm", "resolve", "falsepositive", "wontfix");
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method search_by_directory_path.
@Test
public void search_by_directory_path() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto directory = insertComponent(ComponentTesting.newDirectory(project, "D1", "src/main/java/dir"));
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1").setPath(directory.path() + "/MyComponent.java"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
session.commit();
indexIssues();
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, directory.uuid()).execute().assertJson(this.getClass(), "search_by_file_uuid.json");
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, "unknown").execute().assertJson(this.getClass(), "no_issue.json");
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_DIRECTORIES, "src/main/java/dir").execute().assertJson(this.getClass(), "search_by_file_uuid.json");
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_DIRECTORIES, "src/main/java").execute().assertJson(this.getClass(), "no_issue.json");
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method search_by_developer.
@Test
public void search_by_developer() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
ComponentDto developer = insertComponent(ComponentTesting.newDeveloper(otherOrganization1, "Anakin Skywalker"));
db.authorDao().insertAuthor(session, "vader", developer.getId());
db.authorDao().insertAuthor(session, "anakin@skywalker.name", developer.getId());
RuleDto newRule = newRule();
IssueDto issue1 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("vader").setKee("2bd4eac2-b650-4037-80bc-7b112bd4eac2");
IssueDto issue2 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("anakin@skywalker.name").setKee("82fd47d4-b650-4037-80bc-7b1182fd47d4");
db.issueDao().insert(session, issue1, issue2);
session.commit();
indexIssues();
wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, developer.uuid()).execute().assertJson(this.getClass(), "search_by_developer.json");
}
Aggregations