ApexRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Apex.KEY) .setName(CheckList.REPOSITORY_NAME); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); checks.stream().forEach((ruleClass) -> { newRule(ruleClass, repository); }); repository.done(); }  @Override void define(Context context);  }
@Test public void test() { rulesDefinition = new ApexRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("apex"); assertThat(repository.name(), equalTo("SonarQube")); assertThat(repository.language(), equalTo("apex")); assertThat(repository.rules().size(), is(CheckList.getChecks().size())); }