@Override public void addContextProperty(String key, String value) { sensorStorage.storeProperty(key, value); }
private SensorContextTester(Path moduleBaseDir) { this.settings = new MapSettings(); this.fs = new DefaultFileSystem(moduleBaseDir).setEncoding(Charset.defaultCharset()); this.activeRules = new ActiveRulesBuilder().build(); this.sensorStorage = new InMemorySensorStorage(); this.project = new DefaultInputProject(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.module = new DefaultInputModule(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.runtime = SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.SCANNER); }
private SensorContextTester(Path moduleBaseDir) { this.settings = new MapSettings(); this.fs = new DefaultFileSystem(moduleBaseDir).setEncoding(Charset.defaultCharset()); this.activeRules = new ActiveRulesBuilder().build(); this.sensorStorage = new InMemorySensorStorage(); this.project = new DefaultInputProject(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.module = new DefaultInputModule(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.runtime = SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.SCANNER); }
@Test public void test_storeProperty() { assertThat(underTest.contextProperties).isEmpty(); underTest.storeProperty("foo", "bar"); assertThat(underTest.contextProperties).containsOnly(entry("foo", "bar")); }
@Test public void storeProperty_throws_IAE_if_value_is_null() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Value of context property must not be null"); underTest.storeProperty("foo", null); } }
@Test public void storeProperty_throws_IAE_if_key_is_null() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Key of context property must not be null"); underTest.storeProperty(null, "bar"); }
@Override public void addContextProperty(String key, String value) { sensorStorage.storeProperty(key, value); }