CustomJavaScriptRulesDefinition implements RulesDefinition { @Override public void define(RulesDefinition.Context context) { RulesDefinition.NewRepository repo = context.createRepository(repositoryKey(), "js").setName(repositoryName()); new AnnotationBasedRulesDefinition(repo, "javascript").addRuleClasses(false, ImmutableList.copyOf(checkClasses())); repo.done(); }  @Override void define(RulesDefinition.Context context); abstract String repositoryName(); abstract String repositoryKey(); abstract Class<? extends JavaScriptCheck>[] checkClasses();  }
@Test public void test() { MyCustomJavaScriptRulesDefinition rulesDefinition = new MyCustomJavaScriptRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY); assertThat(repository.name()).isEqualTo(REPOSITORY_NAME); assertThat(repository.language()).isEqualTo("js"); assertThat(repository.rules()).hasSize(1); RulesDefinition.Rule alertUseRule = repository.rule(RULE_KEY); assertThat(alertUseRule).isNotNull(); assertThat(alertUseRule.name()).isEqualTo(RULE_NAME); for (RulesDefinition.Rule rule : repository.rules()) { for (Param param : rule.params()) { assertThat(param.description()).as("description for " + param.key()).isNotEmpty(); } } }