@Test
public void test() {

  CodeNarcRulesDefinition definition = new CodeNarcRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  definition.define(context);
  RulesDefinition.Repository repository = context.repository(CodeNarcRulesDefinition.REPOSITORY_KEY);
  assertThat(repository.name()).isEqualTo(CodeNarcRulesDefinition.REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo(Groovy.KEY);
  List<Rule> rules = repository.rules();
  assertThat(rules).hasSize(347);
  List<String> missingDebt = new LinkedList<>();
  for (Rule rule : rules) {
    assertThat(rule.key()).isNotNull();
    assertThat(rule.internalKey()).isNotNull();
    assertThat(rule.name()).isNotNull();
    assertThat(rule.htmlDescription()).isNotNull();
    if (rule.debtRemediationFunction() == null) {
      missingDebt.add(rule.key());
    }
  }
  // From SONARGROOV-36, 'org.codenarc.rule.generic.IllegalSubclassRule' does not have debt by purpose
  assertThat(missingDebt).containsOnly("org.codenarc.rule.generic.IllegalSubclassRule.fixed");
  Rule rule = repository.rule("org.codenarc.rule.braces.ElseBlockBracesRule");
  assertThat(rule.params()).hasSize(1);
  assertThat(rule.params().get(0).defaultValue()).isEqualToIgnoringCase("false");
}