@Test public void define_should_createRepositoryAndRegisterAllSmellPluginChecks() { Mockito.when(this.repository.key()) .thenReturn(EXPECTED_REPOSITORY_KEY); Mockito.when(this.rule.key()) .thenReturn(LAST_RULE_KEY); Mockito.when(this.context.createRepository(Matchers.anyString(), Matchers.anyString())) .thenReturn(this.repository); Mockito.when(this.repository.setName(Matchers.anyString())) .thenReturn(this.repository); Mockito.when(this.repository.rules()) .thenReturn(ImmutableList.<NewRule> of(this.rule)); Mockito.when(this.repository.createRule(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.repository.rule(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.rule.setName(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.rule.setHtmlDescription(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.rule.setSeverity(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.rule.setTemplate(Matchers.anyBoolean())) .thenReturn(this.rule); Mockito.when(this.rule.setStatus(Matchers.any(RuleStatus.class))) .thenReturn(this.rule); Mockito.when(this.rule.setTags(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.rule.setDebtSubCharacteristic(Matchers.anyString())) .thenReturn(this.rule); Mockito.when(this.rule.setDebtRemediationFunction(Matchers.any(DebtRemediationFunction.class))) .thenReturn(this.rule); Mockito.when(this.rule.debtRemediationFunctions()) .thenReturn(this.functions); Mockito.when(this.rule.setEffortToFixDescription(Matchers.anyString())) .thenReturn(this.rule); final SmellRulesDefinition sut = new SmellRulesDefinition(); sut.define(this.context); Mockito.verify(this.context, Mockito.times(1)) .createRepository(Matchers.eq(EXPECTED_REPOSITORY_KEY), Matchers.eq(Java.KEY)); Mockito.verify(this.repository, Mockito.times(1)) .setName(Matchers.eq(EXPECTED_REPOSITORY_NAME)); Mockito.verify(this.repository, Mockito.times(27)) .createRule(this.captor.capture()); Assertions.assertThat(this.captor.getValue()) .isEqualTo(LAST_RULE_KEY); Mockito.verify(this.rule, Mockito.times(28)) .key(); Mockito.verify(this.rule, Mockito.times(1)) .setInternalKey(Matchers.eq(LAST_RULE_KEY)); Mockito.verify(this.repository, Mockito.times(1)) .done(); }
@SuppressWarnings("rawtypes") @Override public void define(final Context context) { final NewRepository repository = context.createRepository(REPOSITORY_KEY, Java.KEY) .setName(REPOSITORY_NAME); final List<Class> checkClasses = ImmutableList.<Class> builder() .addAll(SmellChecksRegistrar.checkClasses()) .build(); new AnnotationBasedRulesDefinition(repository, Java.KEY).addRuleClasses(false, checkClasses); for (final NewRule rule : repository.rules()) { final String metadataKey = rule.key(); rule.setInternalKey(metadataKey); rule.setHtmlDescription(readRuleDefinitionResource(metadataKey + ".html")); addMetadata(rule, metadataKey); } repository.done(); }
SmellRulesDefinition implements RulesDefinition { @SuppressWarnings("rawtypes") @Override public void define(final Context context) { final NewRepository repository = context.createRepository(REPOSITORY_KEY, Java.KEY) .setName(REPOSITORY_NAME); final List<Class> checkClasses = ImmutableList.<Class> builder() .addAll(SmellChecksRegistrar.checkClasses()) .build(); new AnnotationBasedRulesDefinition(repository, Java.KEY).addRuleClasses(false, checkClasses); for (final NewRule rule : repository.rules()) { final String metadataKey = rule.key(); rule.setInternalKey(metadataKey); rule.setHtmlDescription(readRuleDefinitionResource(metadataKey + ".html")); addMetadata(rule, metadataKey); } repository.done(); } }
SmellRulesDefinition implements RulesDefinition { @SuppressWarnings("rawtypes") @Override public void define(final Context context) { final NewRepository repository = context.createRepository(REPOSITORY_KEY, Java.KEY) .setName(REPOSITORY_NAME); final List<Class> checkClasses = ImmutableList.<Class> builder() .addAll(SmellChecksRegistrar.checkClasses()) .build(); new AnnotationBasedRulesDefinition(repository, Java.KEY).addRuleClasses(false, checkClasses); for (final NewRule rule : repository.rules()) { final String metadataKey = rule.key(); rule.setInternalKey(metadataKey); rule.setHtmlDescription(readRuleDefinitionResource(metadataKey + ".html")); addMetadata(rule, metadataKey); } repository.done(); }  }
SmellRulesDefinition implements RulesDefinition { @SuppressWarnings("rawtypes") @Override public void define(final Context context) { final NewRepository repository = context.createRepository(REPOSITORY_KEY, Java.KEY) .setName(REPOSITORY_NAME); final List<Class> checkClasses = ImmutableList.<Class> builder() .addAll(SmellChecksRegistrar.checkClasses()) .build(); new AnnotationBasedRulesDefinition(repository, Java.KEY).addRuleClasses(false, checkClasses); for (final NewRule rule : repository.rules()) { final String metadataKey = rule.key(); rule.setInternalKey(metadataKey); rule.setHtmlDescription(readRuleDefinitionResource(metadataKey + ".html")); addMetadata(rule, metadataKey); } repository.done(); }  @SuppressWarnings("rawtypes") @Override void define(final Context context); }
SmellRulesDefinition implements RulesDefinition { @SuppressWarnings("rawtypes") @Override public void define(final Context context) { final NewRepository repository = context.createRepository(REPOSITORY_KEY, Java.KEY) .setName(REPOSITORY_NAME); final List<Class> checkClasses = ImmutableList.<Class> builder() .addAll(SmellChecksRegistrar.checkClasses()) .build(); new AnnotationBasedRulesDefinition(repository, Java.KEY).addRuleClasses(false, checkClasses); for (final NewRule rule : repository.rules()) { final String metadataKey = rule.key(); rule.setInternalKey(metadataKey); rule.setHtmlDescription(readRuleDefinitionResource(metadataKey + ".html")); addMetadata(rule, metadataKey); } repository.done(); }  @SuppressWarnings("rawtypes") @Override void define(final Context context); static final String REPOSITORY_KEY; static final String REPOSITORY_NAME; }