Search in sources :

Example 56 with FileSourceDto

use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.

the class LinesActionTest method branch.

@Test
public void branch() {
    ComponentDto project = db.components().insertPrivateProject();
    userSession.addProjectPermission(UserRole.USER, project);
    ComponentDto branch = db.components().insertProjectBranch(project);
    ComponentDto file = db.components().insertComponent(newFileDto(branch));
    db.getDbClient().fileSourceDao().insert(db.getSession(), new FileSourceDto().setUuid(Uuids.createFast()).setProjectUuid(branch.uuid()).setFileUuid(file.uuid()).setSourceData(FileSourceTesting.newFakeData(3).build()));
    db.commit();
    userSession.logIn("login").addProjectPermission(UserRole.CODEVIEWER, project, file);
    tester.newRequest().setParam("key", file.getKey()).setParam("branch", file.getBranch()).execute().assertJson(getClass(), "show_source.json");
}
Also used : FileSourceDto(org.sonar.db.source.FileSourceDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 57 with FileSourceDto

use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.

the class ScmActionTest method return_empty_value_when_no_scm.

@Test
public void return_empty_value_when_no_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().build()));
    dbSession.commit();
    tester.newRequest().setParam("key", FILE_KEY).execute().assertJson(getClass(), "return_empty_value_when_no_scm.json");
}
Also used : FileSourceDto(org.sonar.db.source.FileSourceDto) Test(org.junit.Test)

Example 58 with FileSourceDto

use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.

the class ScmActionTest method show_scm_from_given_range_lines.

@Test
public void show_scm_from_given_range_lines() {
    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-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("from", "2").setParam("to", "3").execute().assertJson(getClass(), "show_scm_from_given_range_lines.json");
}
Also used : FileSourceDto(org.sonar.db.source.FileSourceDto) Test(org.junit.Test)

Aggregations

FileSourceDto (org.sonar.db.source.FileSourceDto)58 Test (org.junit.Test)46 DbFileSources (org.sonar.db.protobuf.DbFileSources)19 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)15 BaseStepTest (org.sonar.ce.task.projectanalysis.step.BaseStepTest)14 Changeset (org.sonar.ce.task.projectanalysis.scm.Changeset)5 ComponentDto (org.sonar.db.component.ComponentDto)5 Before (org.junit.Before)3 DbSession (org.sonar.db.DbSession)3 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 DigestUtils (org.apache.commons.codec.digest.DigestUtils)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Rule (org.junit.Rule)2 Mockito (org.mockito.Mockito)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.verify (org.mockito.Mockito.verify)2 Mockito.when (org.mockito.Mockito.when)2