JSONRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(JSONLanguage.KEY, JSONLanguage.KEY) .setName(CheckList.REPOSITORY_NAME); new AnnotationBasedRulesDefinition(repository, JSONLanguage.KEY).addRuleClasses(false, CheckList.getChecks()); repository.done(); }  @Override void define(Context context);  }
@Test public void test() { JSONRulesDefinition rulesDefinition = new JSONRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("json"); assertThat(repository.name()).isEqualTo("SonarQube"); assertThat(repository.language()).isEqualTo("json"); assertThat(repository.rules()).hasSize(CheckList.getChecks().size()); RulesDefinition.Rule fileNameRule = repository.rule(FileNameCheck.class.getAnnotation(Rule.class).key()); assertThat(fileNameRule).isNotNull(); assertThat(fileNameRule.name()).isEqualTo(FileNameCheck.class.getAnnotation(Rule.class).name()); }