MyJavaRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, "java") .setName("MyCompany Custom Repository"); for (Class<? extends JavaCheck> check : RulesList.getChecks()) { new RulesDefinitionAnnotationLoader().load(repository, check); newRule(check, repository); } repository.done(); }  @Override void define(Context context); static final String REPOSITORY_KEY; }
@Test public void test() { MyJavaRulesDefinition rulesDefinition = new MyJavaRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(MyJavaRulesDefinition.REPOSITORY_KEY); assertThat(repository.name()).isEqualTo("MyCompany Custom Repository"); assertThat(repository.language()).isEqualTo("java"); assertThat(repository.rules()).hasSize(RulesList.getChecks().size()); assertRuleProperties(repository); assertParameterProperties(repository); assertAllRuleParametersHaveDescription(repository); }