use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method persist_symbols.
@Test
public void persist_symbols() {
DbFileSources.Data dbData = DbFileSources.Data.newBuilder().addAllLines(Arrays.asList(DbFileSources.Line.newBuilder().setSymbols("2,4,1").build(), DbFileSources.Line.newBuilder().build(), DbFileSources.Line.newBuilder().setSymbols("1,3,1").build())).build();
setComputedData(dbData);
underTest.execute(new TestComputationStepContext());
assertThat(dbTester.countRowsOfTable("file_sources")).isOne();
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectByFileUuid(session, FILE1_UUID);
assertThat(fileSourceDto.getSourceData()).isEqualTo(dbData);
verify(fileSourceDataWarnings).commitWarnings();
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method not_update_sources_when_nothing_has_changed.
@Test
public void not_update_sources_when_nothing_has_changed() {
dbClient.fileSourceDao().insert(dbTester.getSession(), createDto());
dbTester.getSession().commit();
Changeset changeset = Changeset.newChangesetBuilder().setDate(1L).setRevision("rev-1").build();
setComputedData(DbFileSources.Data.newBuilder().build(), Collections.singletonList("lineHash"), "sourceHash", changeset);
underTest.execute(new TestComputationStepContext());
assertThat(dbTester.countRowsOfTable("file_sources")).isOne();
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectByFileUuid(session, FILE1_UUID);
assertThat(fileSourceDto.getSrcHash()).isEqualTo("sourceHash");
assertThat(fileSourceDto.getLineHashes()).isEqualTo(Collections.singletonList("lineHash"));
assertThat(fileSourceDto.getCreatedAt()).isEqualTo(PAST);
assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(PAST);
verify(fileSourceDataWarnings).commitWarnings();
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method persist_scm.
@Test
public void persist_scm() {
DbFileSources.Data dbData = DbFileSources.Data.newBuilder().addLines(DbFileSources.Line.newBuilder().setScmAuthor("john").setScmDate(123456789L).setScmRevision("rev-1").build()).build();
setComputedData(dbData);
underTest.execute(new TestComputationStepContext());
assertThat(dbTester.countRowsOfTable("file_sources")).isOne();
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectByFileUuid(session, FILE1_UUID);
assertThat(fileSourceDto.getSourceData()).isEqualTo(dbData);
assertThat(fileSourceDto.getRevision()).isNull();
verify(fileSourceDataWarnings).commitWarnings();
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method save_revision.
@Test
public void save_revision() {
Changeset latest = Changeset.newChangesetBuilder().setDate(0L).setRevision("rev-1").build();
setComputedData(DbFileSources.Data.newBuilder().build(), Collections.singletonList("lineHashes"), "srcHash", latest);
underTest.execute(new TestComputationStepContext());
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectByFileUuid(session, FILE1_UUID);
assertThat(fileSourceDto.getRevision()).isEqualTo("rev-1");
verify(fileSourceDataWarnings).commitWarnings();
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PurgeDatastoresStepTest method verify_call_purge_method_of_the_purge_task.
private void verify_call_purge_method_of_the_purge_task(Component project) {
treeRootHolder.setRoot(project);
when(settingsRepository.getConfiguration()).thenReturn(new MapSettings().asConfig());
underTest.execute(new TestComputationStepContext());
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
verify(projectCleaner).purge(any(), argumentCaptor.capture(), anyString(), any(), any());
assertThat(argumentCaptor.getValue()).isEqualTo(PROJECT_UUID);
}
Aggregations