use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultIssueTest method build_directory_issue.
@Test
public void build_directory_issue() {
SensorStorage storage = mock(SensorStorage.class);
DefaultIssue issue = new DefaultIssue(storage).at(new DefaultIssueLocation().on(new DefaultInputDir("foo", "src")).message("Wrong way!")).forRule(RuleKey.of("repo", "rule")).overrideSeverity(Severity.BLOCKER);
assertThat(issue.primaryLocation().inputComponent()).isEqualTo(new DefaultInputDir("foo", "src"));
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule"));
assertThat(issue.primaryLocation().textRange()).isNull();
assertThat(issue.primaryLocation().message()).isEqualTo("Wrong way!");
assertThat(issue.overriddenSeverity()).isEqualTo(Severity.BLOCKER);
issue.save();
verify(storage).store(issue);
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultMeasureTest method build_project_measure.
@Test
public void build_project_measure() {
SensorStorage storage = mock(SensorStorage.class);
DefaultInputModule module = new DefaultInputModule("foo");
DefaultMeasure<Integer> newMeasure = new DefaultMeasure<Integer>(storage).forMetric(CoreMetrics.LINES).on(module).withValue(3);
assertThat(newMeasure.inputComponent()).isEqualTo(new DefaultInputModule("foo"));
assertThat(newMeasure.metric()).isEqualTo(CoreMetrics.LINES);
assertThat(newMeasure.value()).isEqualTo(3);
newMeasure.save();
verify(storage).store(newMeasure);
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultHighlightableTest method should_store_highlighting_rules.
@Test
public void should_store_highlighting_rules() {
SensorStorage sensorStorage = mock(SensorStorage.class);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.php").initMetadata("azerty\nbla bla").build();
DefaultHighlightable highlightablePerspective = new DefaultHighlightable(inputFile, sensorStorage, mock(AnalysisMode.class));
highlightablePerspective.newHighlighting().highlight(0, 6, "k").highlight(7, 10, "cppd").done();
ArgumentCaptor<DefaultHighlighting> argCaptor = ArgumentCaptor.forClass(DefaultHighlighting.class);
verify(sensorStorage).store(argCaptor.capture());
assertThat(argCaptor.getValue().getSyntaxHighlightingRuleSet()).hasSize(2);
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultCpdTokensTest method validate_tokens_order.
@Test
public void validate_tokens_order() {
SensorStorage sensorStorage = mock(SensorStorage.class);
DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage).onFile(INPUT_FILE).addToken(INPUT_FILE.newRange(1, 6, 1, 10), "bar");
try {
tokens.addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Tokens of file [moduleKey=foo, relative=src/Foo.java, basedir=foo] should be provided in order.\n" + "Previous token: Range[from [line=1, lineOffset=6] to [line=1, lineOffset=10]]\n" + "Last token: Range[from [line=1, lineOffset=2] to [line=1, lineOffset=5]]");
}
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultCpdTokensTest method save_one_token.
@Test
public void save_one_token() {
SensorStorage sensorStorage = mock(SensorStorage.class);
DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage).onFile(INPUT_FILE).addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo");
tokens.save();
verify(sensorStorage).store(tokens);
assertThat(tokens.getTokenLines()).extracting("value", "startLine", "hashCode", "startUnit", "endUnit").containsExactly(tuple("foo", 1, "foo".hashCode(), 1, 1));
}
Aggregations