### Question:
IdeaProfileExporter extends ProfileExporter { public void exportProfile(RulesProfile profile, Writer writer) { try { appendXmlHeader(writer); SortedMap<String, Rule> defaultRules = new TreeMap<String, Rule>(DefaultRules.get()); for (ActiveRule activeRule : profile.getActiveRulesByRepository(REPOSITORY_KEY)) { final Rule rule = activeRule.getRule(); final boolean hasParameters= !rule.getParams().isEmpty(); if (defaultRules.remove(rule.getKey()) == null || hasParameters) { appendRule(writer, rule, true, !hasParameters); if (hasParameters) { appendParameters(writer, activeRule); } } } for (Rule rule : defaultRules.values()) { appendRule(writer, rule, false, true); } appendXmlFooter(writer); } catch (IOException e) { throw new SonarException("Fail to export the profile " + profile, e); } } @SuppressWarnings("UnusedDeclaration")  IdeaProfileExporter(Configuration conf);   IdeaProfileExporter(); void exportProfile(RulesProfile profile, Writer writer);  }### Answer:
@Test public void exportParameters() throws IOException, SAXException { RulesProfile profile = RulesProfile.create("sonar way", "java"); Rule rule = Rule.create(REPOSITORY_KEY, "ConstantConditions", "ConstantConditions").setConfigKey("ConstantConditions"); rule.createParameter("SUGGEST_NULLABLE_ANNOTATIONS"); rule.createParameter("message"); rule.createParameter("DONT_REPORT_TRUE_ASSERT_STATEMENTS"); profile.activateRule(rule, RulePriority.MAJOR).setParameter("DONT_REPORT_TRUE_ASSERT_STATEMENTS", "false") .setParameter("SUGGEST_NULLABLE_ANNOTATIONS", "false"); assertSimilar(exportProfile(profile), "exportParameters.xml"); }
@Test public void empty() throws IOException, SAXException { RulesProfile profile = RulesProfile.create("sonar way", "java"); assertSimilar(exportProfile(profile), "empty.xml"); }
@Test public void noIdeaRulesToExport() throws IOException, SAXException { RulesProfile profile = RulesProfile.create("sonar way", "java"); profile.activateRule(Rule.create("pmd", "PmdRule1", "PMD rule one"), null); assertSimilar(exportProfile(profile), "empty.xml"); }
@Test public void simpleIdeaRulesToExport() throws IOException, SAXException { RulesProfile profile = createSimpleProfile(); assertSimilar(exportProfile(profile), "simpleIdeaRulesToExport.xml"); }
@Test public void addTheIdPropertyWhenManyInstancesWithTheSameConfigKey() throws IOException, SAXException { RulesProfile profile = RulesProfile.create("sonar way", "java"); Rule rule1 = Rule.create(REPOSITORY_KEY, "RedundantCast", "RedundantCast").setConfigKey("RedundantCast"); Rule rule2 = Rule.create(REPOSITORY_KEY, "RedundantCast_12345", "RedundantCast").setConfigKey("RedundantCast") .setParent(rule1); profile.activateRule(rule1, RulePriority.MAJOR); profile.activateRule(rule2, RulePriority.CRITICAL); assertSimilar(exportProfile(profile), "addTheIdPropertyWhenManyInstancesWithTheSameConfigKey.xml"); }