CssRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.CSS_REPOSITORY_KEY, CssLanguage.KEY) .setName(CheckList.CSS_REPOSITORY_NAME); new AnnotationBasedRulesDefinition(repository, CssLanguage.KEY).addRuleClasses(false, CheckList.getCssChecks()); repository.done(); }  @Override void define(Context context);  }
@Test public void test() { CssRulesDefinition rulesDefinition = new CssRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("css"); assertThat(repository.name()).isEqualTo("SonarQube"); assertThat(repository.language()).isEqualTo("css"); assertThat(repository.rules()).hasSize(87); assertThat(CheckList.getEmbeddedCssChecks()).hasSize(repository.rules().size() - 6); RulesDefinition.Rule todoRule = repository.rule(TodoTagCheck.class.getAnnotation(Rule.class).key()); assertThat(todoRule).isNotNull(); assertThat(todoRule.name()).isEqualTo(TodoTagCheck.class.getAnnotation(Rule.class).name()); }