use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ScmActionTest method group_lines_by_commit.
@Test
public void group_lines_by_commit() {
userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project, file);
// lines 1 and 2 are the same commit, but not 3 (different date)
dbTester.getDbClient().fileSourceDao().insert(dbSession, new FileSourceDto().setUuid(Uuids.createFast()).setProjectUuid(PROJECT_UUID).setFileUuid(FILE_UUID).setSourceData(DbFileSources.Data.newBuilder().addLines(newSourceLine("julien", "123-456-789", DateUtils.parseDateTime("2015-03-30T12:34:56+0000"), 1)).addLines(newSourceLine("julien", "123-456-789", DateUtils.parseDateTime("2015-03-30T12:34:56+0000"), 2)).addLines(newSourceLine("julien", "456-789-101", DateUtils.parseDateTime("2015-03-27T12:34:56+0000"), 3)).addLines(newSourceLine("simon", "789-101-112", DateUtils.parseDateTime("2015-03-31T12:34:56+0000"), 4)).build()));
dbSession.commit();
tester.newRequest().setParam("key", FILE_KEY).setParam("commits_by_line", "false").execute().assertJson(getClass(), "group_lines_by_commit.json");
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ScmActionTest method accept_negative_value_in_from_parameter.
@Test
public void accept_negative_value_in_from_parameter() {
userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project, file);
dbTester.getDbClient().fileSourceDao().insert(dbSession, new FileSourceDto().setUuid(Uuids.createFast()).setProjectUuid(PROJECT_UUID).setFileUuid(FILE_UUID).setSourceData(DbFileSources.Data.newBuilder().addLines(newSourceLine("julien", "123-456-789", DateUtils.parseDateTime("2015-03-30T12:34:56+0000"), 1)).addLines(newSourceLine("julien", "123-456-710", DateUtils.parseDateTime("2015-03-29T12:34:56+0000"), 2)).addLines(newSourceLine("julien", "456-789-101", DateUtils.parseDateTime("2015-03-27T12:34:56+0000"), 3)).addLines(newSourceLine("simon", "789-101-112", DateUtils.parseDateTime("2015-03-31T12:34:56+0000"), 4)).build()));
dbSession.commit();
tester.newRequest().setParam("key", FILE_KEY).setParam("from", "-2").setParam("to", "3").execute().assertJson(getClass(), "accept_negative_value_in_from_parameter.json");
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ScmActionTest method not_group_lines_by_commit.
@Test
public void not_group_lines_by_commit() {
userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project, file);
// lines 1 and 2 are the same commit, but not 3 (different date)
dbTester.getDbClient().fileSourceDao().insert(dbSession, new FileSourceDto().setUuid(Uuids.createFast()).setProjectUuid(PROJECT_UUID).setFileUuid(FILE_UUID).setSourceData(DbFileSources.Data.newBuilder().addLines(newSourceLine("julien", "123-456-789", DateUtils.parseDateTime("2015-03-30T12:34:56+0000"), 1)).addLines(newSourceLine("julien", "123-456-789", DateUtils.parseDateTime("2015-03-30T12:34:56+0000"), 2)).addLines(newSourceLine("julien", "456-789-101", DateUtils.parseDateTime("2015-03-27T12:34:56+0000"), 3)).addLines(newSourceLine("simon", "789-101-112", DateUtils.parseDateTime("2015-03-31T12:34:56+0000"), 4)).build()));
dbSession.commit();
tester.newRequest().setParam("key", FILE_KEY).setParam("commits_by_line", "true").execute().assertJson(getClass(), "not_group_lines_by_commit.json");
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ScmActionTest method show_scm.
@Test
public void show_scm() {
userSessionRule.addProjectPermission(UserRole.CODEVIEWER, project, file);
dbTester.getDbClient().fileSourceDao().insert(dbSession, new FileSourceDto().setUuid(Uuids.createFast()).setProjectUuid(PROJECT_UUID).setFileUuid(FILE_UUID).setSourceData(DbFileSources.Data.newBuilder().addLines(newSourceLine("julien", "123-456-789", DateUtils.parseDateTime("2015-03-30T12:34:56+0000"), 1)).build()));
dbSession.commit();
tester.newRequest().setParam("key", FILE_KEY).execute().assertJson(getClass(), "show_scm.json");
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class SourceServiceTest method injectFakeLines.
@Before
public void injectFakeLines() {
FileSourceDto dto = new FileSourceDto();
dto.setFileUuid(FILE_UUID).setUuid(Uuids.createFast()).setProjectUuid("PROJECT_UUID");
dto.setSourceData(FileSourceTesting.newFakeData(10).build());
dbTester.getDbClient().fileSourceDao().insert(dbTester.getSession(), dto);
dbTester.commit();
}
Aggregations