@Test
public void shouldCreateProfile() {

  ProfileDefinition profileDefinition = new SonarWayProfile(new XMLProfileParser(newRuleFinder()));
  ValidationMessages messages = ValidationMessages.create();
  RulesProfile profile = profileDefinition.createProfile(messages);
  assertThat(profile.getName()).isEqualTo("Sonar way");
  assertThat(profile.getLanguage()).isEqualTo(Groovy.KEY);
  assertThat(profile.getActiveRules()).hasSize(59);
  assertThat(messages.hasErrors()).isFalse();
  CodeNarcRulesDefinition definition = new CodeNarcRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  definition.define(context);
  RulesDefinition.Repository repository = context.repository(CodeNarcRulesDefinition.REPOSITORY_KEY);
  Map<String, RulesDefinition.Rule> rules = new HashMap<>();
  for (RulesDefinition.Rule rule : repository.rules()) {
    rules.put(rule.key(), rule);
  }
  for (ActiveRule activeRule : profile.getActiveRules()) {
    assertThat(rules.containsKey(activeRule.getConfigKey())).as("No such rule: " + activeRule.getConfigKey()).isTrue();
  }
}