use of org.sonar.api.config.MapSettings 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.config.MapSettings 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));
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultCpdTokensTest method basic_validation.
@Test
public void basic_validation() {
SensorStorage sensorStorage = mock(SensorStorage.class);
DefaultCpdTokens tokens = new DefaultCpdTokens(new MapSettings(), sensorStorage);
try {
tokens.save();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Call onFile() first");
}
try {
tokens.addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Call onFile() first");
}
try {
tokens.addToken(null, "foo");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Range should not be null");
}
try {
tokens.addToken(INPUT_FILE.newRange(1, 2, 1, 5), null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Image should not be null");
}
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class SensorContextTesterTest method testSettings.
@Test
public void testSettings() {
Settings settings = new MapSettings();
settings.setProperty("foo", "bar");
tester.setSettings(settings);
assertThat(tester.settings().getString("foo")).isEqualTo("bar");
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class FileExclusionsTest method load_inclusions.
@Test
public void load_inclusions() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Foo.java");
settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*FooTest.java");
FileExclusions moduleExclusions = new FileExclusions(settings);
assertThat(moduleExclusions.sourceInclusions()).containsOnly("**/*Foo.java");
assertThat(moduleExclusions.testInclusions()).containsOnly("**/*FooTest.java");
}
Aggregations