XmlFileSensor implements Sensor { @Override public void describe(SensorDescriptor descriptor) { descriptor.name("JavaXmlSensor").onlyWhenConfiguration(configuration -> !checks.all().isEmpty()); } XmlFileSensor(CheckFactory checkFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }
@Test void testDescriptor() throws Exception { XmlFileSensor sensor = new XmlFileSensor(new CheckFactory(new ActiveRulesBuilder().build())); DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor(); sensor.describe(descriptor); assertThat(descriptor.name()).isEqualTo("JavaXmlSensor"); assertThat(descriptor.languages()).isEmpty(); assertThat(descriptor.isGlobal()).isFalse(); assertThat(descriptor.configurationPredicate().test(new MapSettings().asConfig())).isFalse(); sensor = new XmlFileSensor(new CheckFactory(activeRules())); descriptor = new DefaultSensorDescriptor(); sensor.describe(descriptor); assertThat(descriptor.languages()).isEmpty(); assertThat(descriptor.isGlobal()).isFalse(); assertThat(descriptor.configurationPredicate().test(new MapSettings().asConfig())).isTrue(); }