use of org.sonar.server.ws.WsTester.Result in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method search_by_developer_technical_project.
@Test
public void search_by_developer_technical_project() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
ComponentDto otherProject = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P2").setKey("PK2"));
setDefaultProjectPermission(otherProject);
ComponentDto otherFile = insertComponent(newFileDto(otherProject, null, "F2").setKey("FK2"));
ComponentDto developer = insertComponent(ComponentTesting.newDeveloper(defaultOrganization, "Anakin Skywalker"));
ComponentDto technicalProject = insertComponent(ComponentTesting.newDevProjectCopy("COPY_P1", project, developer));
insertComponent(ComponentTesting.newDevProjectCopy("COPY_P2", otherProject, developer));
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");
IssueDto issueX = IssueTesting.newDto(newRule, otherFile, otherProject).setAuthorLogin("anakin@skywalker.name").setKee("82fd47d4-b650-4037-7b11-80bc82fd47d4");
db.issueDao().insert(session, issue1, issue2, issueX);
session.commit();
indexIssues();
Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, technicalProject.uuid()).execute();
result.assertJson(this.getClass(), "search_by_developer.json");
}
use of org.sonar.server.ws.WsTester.Result in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method issues_on_different_projects.
@Test
public void issues_on_different_projects() throws Exception {
RuleDto rule = newRule();
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
IssueDto issue = IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setStatus("OPEN").setResolution("OPEN").setSeverity("MAJOR").setIssueCreationDate(DateUtils.parseDateTime("2014-09-04T00:00:00+0100")).setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
db.issueDao().insert(session, issue);
ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P2").setKey("PK2"));
setDefaultProjectPermission(project2);
ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
IssueDto issue2 = IssueTesting.newDto(rule, file2, project2).setKee("92fd47d4-b650-4037-80bc-7b112bd4eac2").setStatus("OPEN").setResolution("OPEN").setSeverity("MAJOR").setIssueCreationDate(DateUtils.parseDateTime("2014-09-04T00:00:00+0100")).setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
db.issueDao().insert(session, issue2);
session.commit();
indexIssues();
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).execute();
result.assertJson(this.getClass(), "issues_on_different_projects.json");
}
use of org.sonar.server.ws.WsTester.Result in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method display_directory_facet.
@Test
public void display_directory_facet() 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, directory, "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();
userSessionRule.logIn("john");
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("resolved", "false").setParam(WebService.Param.FACETS, "directories").execute();
result.assertJson(this.getClass(), "display_directory_facet.json");
}
use of org.sonar.server.ws.WsTester.Result in project sonarqube by SonarSource.
the class BackupActionTest method backup_profile.
@Test
public void backup_profile() throws Exception {
when(profileFactory.find(any(DbSession.class), eq(QProfileRef.fromKey(SOME_PROFILE_KEY)))).thenReturn(QualityProfileTesting.newQualityProfileDto().setKey(SOME_PROFILE_KEY));
final String response = "<polop><palap/></polop>";
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Writer w = (Writer) invocation.getArguments()[1];
new PrintWriter(w).print(response);
w.close();
return null;
}
}).when(backuper).backup(eq(SOME_PROFILE_KEY), any(Writer.class));
Result result = tester.newGetRequest("api/qualityprofiles", "backup").setParam(QProfileRef.PARAM_PROFILE_KEY, SOME_PROFILE_KEY).execute();
assertThat(result.outputAsString()).isEqualTo(response);
result.assertHeader("Content-Disposition", "attachment; filename=" + SOME_PROFILE_KEY + ".xml");
}
Aggregations