use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method duplicateSymbolTable.
@Test(expected = UnsupportedOperationException.class)
public void duplicateSymbolTable() throws Exception {
InputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.java").setModuleBaseDir(temp.newFolder().toPath()).build();
DefaultSymbolTable st = new DefaultSymbolTable(null).onFile(inputFile);
underTest.store(st);
underTest.store(st);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method should_save_external_issue.
@Test
public void should_save_external_issue() {
InputFile file = new TestInputFileBuilder("foo", "src/Foo.php").build();
DefaultExternalIssue externalIssue = new DefaultExternalIssue(project).at(new DefaultIssueLocation().on(file));
underTest.store(externalIssue);
ArgumentCaptor<ExternalIssue> argumentCaptor = ArgumentCaptor.forClass(ExternalIssue.class);
verify(moduleIssues).initAndAddExternalIssue(argumentCaptor.capture());
assertThat(argumentCaptor.getValue()).isEqualTo(externalIssue);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method should_skip_significant_code_on_pull_request_when_file_status_is_SAME.
@Test
public void should_skip_significant_code_on_pull_request_when_file_status_is_SAME() {
DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php").setStatus(InputFile.Status.SAME).setContents("foo").build();
when(branchConfiguration.isPullRequest()).thenReturn(true);
underTest.store(new DefaultSignificantCode().onFile(file).addRange(file.selectLine(1)));
assertThat(reportWriter.hasComponentData(FileStructure.Domain.SGNIFICANT_CODE, file.scannerId())).isFalse();
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method should_save_file_measure.
@Test
public void should_save_file_measure() {
DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php").build();
underTest.store(new DefaultMeasure().on(file).forMetric(CoreMetrics.NCLOC).withValue(10));
ScannerReport.Measure m = reportReader.readComponentMeasures(file.scannerId()).next();
assertThat(m.getIntValue().getValue()).isEqualTo(10);
assertThat(m.getMetricKey()).isEqualTo(CoreMetrics.NCLOC_KEY);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method should_save_issue.
@Test
public void should_save_issue() {
InputFile file = new TestInputFileBuilder("foo", "src/Foo.php").build();
DefaultIssue issue = new DefaultIssue(project).at(new DefaultIssueLocation().on(file));
underTest.store(issue);
ArgumentCaptor<Issue> argumentCaptor = ArgumentCaptor.forClass(Issue.class);
verify(moduleIssues).initAndAddIssue(argumentCaptor.capture());
assertThat(argumentCaptor.getValue()).isEqualTo(issue);
}
Aggregations