@Test void should_export_xPath_rule() { Rule rule = Rule.create(PmdConstants.REPOSITORY_KEY, "MyOwnRule", "This is my own xpath rule.") .setConfigKey(PmdConstants.XPATH_CLASS) .setRepositoryKey(PmdConstants.REPOSITORY_KEY); rule.createParameter(PmdConstants.XPATH_EXPRESSION_PARAM); rule.createParameter(PmdConstants.XPATH_MESSAGE_PARAM); RulesProfile profile = RulesProfile.create(); ActiveRule xpath = profile.activateRule(rule, null); xpath.setParameter(PmdConstants.XPATH_EXPRESSION_PARAM, " xpath.setParameter(PmdConstants.XPATH_MESSAGE_PARAM, "This is bad"); final StringWriter writer = new StringWriter(); exporter.exportProfile(profile, writer); assertThat(writer.toString()).satisfies(equalsIgnoreEOL(PmdTestUtils.getResourceContent("/org/sonar/plugins/pmd/export_xpath_rules.xml"))); }
@Override public void exportProfile(RulesProfile profile, Writer writer) { final PmdRuleSet tree = PmdRuleSets.from(profile, PmdConstants.REPOSITORY_KEY); try { tree.writeTo(writer); } catch (IllegalStateException e) { throw new IllegalStateException("An exception occurred while generating the PMD configuration file from profile: " + profile.getName(), e); } }
PmdProfileExporter extends ProfileExporter { @Override public void exportProfile(RulesProfile profile, Writer writer) { final PmdRuleSet tree = PmdRuleSets.from(profile, PmdConstants.REPOSITORY_KEY); try { tree.writeTo(writer); } catch (IllegalStateException e) { throw new IllegalStateException("An exception occurred while generating the PMD configuration file from profile: " + profile.getName(), e); } } }
PmdProfileExporter extends ProfileExporter { @Override public void exportProfile(RulesProfile profile, Writer writer) { final PmdRuleSet tree = PmdRuleSets.from(profile, PmdConstants.REPOSITORY_KEY); try { tree.writeTo(writer); } catch (IllegalStateException e) { throw new IllegalStateException("An exception occurred while generating the PMD configuration file from profile: " + profile.getName(), e); } } PmdProfileExporter(); }
PmdProfileExporter extends ProfileExporter { @Override public void exportProfile(RulesProfile profile, Writer writer) { final PmdRuleSet tree = PmdRuleSets.from(profile, PmdConstants.REPOSITORY_KEY); try { tree.writeTo(writer); } catch (IllegalStateException e) { throw new IllegalStateException("An exception occurred while generating the PMD configuration file from profile: " + profile.getName(), e); } } PmdProfileExporter(); @Override void exportProfile(RulesProfile profile, Writer writer); }
PmdProfileExporter extends ProfileExporter { @Override public void exportProfile(RulesProfile profile, Writer writer) { final PmdRuleSet tree = PmdRuleSets.from(profile, PmdConstants.REPOSITORY_KEY); try { tree.writeTo(writer); } catch (IllegalStateException e) { throw new IllegalStateException("An exception occurred while generating the PMD configuration file from profile: " + profile.getName(), e); } } PmdProfileExporter(); @Override void exportProfile(RulesProfile profile, Writer writer);  }