@Test public void whenCreatingCustomJavaRulesDefinitionThenGenerateRulesDefinition() { RulesDefinition.Context context = new RulesDefinition.Context(); CustomRulesDefinition rulesDefinition = new CustomRulesDefinition(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(CheckList.REPOSITORY_KEY); assertThat(repository.name(), is(CheckList.REPOSITORY_NAME)); assertThat(repository.language(), is(Java.KEY)); assertThat(repository.rules().size(), is(CheckList.getChecks().size())); }
@Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName(CheckList.REPOSITORY_NAME); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); for (Class ruleClass : checks) { newRule(ruleClass, repository); } repository.done(); }
CustomRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName(CheckList.REPOSITORY_NAME); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); for (Class ruleClass : checks) { newRule(ruleClass, repository); } repository.done(); } }
CustomRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName(CheckList.REPOSITORY_NAME); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); for (Class ruleClass : checks) { newRule(ruleClass, repository); } repository.done(); }  }
CustomRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName(CheckList.REPOSITORY_NAME); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); for (Class ruleClass : checks) { newRule(ruleClass, repository); } repository.done(); }  @Override void define(Context context); }
CustomRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName(CheckList.REPOSITORY_NAME); List<Class> checks = CheckList.getChecks(); new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class)); for (Class ruleClass : checks) { newRule(ruleClass, repository); } repository.done(); }  @Override void define(Context context);  }