### Question:
SolidityRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(SolidityRulesDefinition.REPO_KEY, Solidity.KEY) .setName(SolidityRulesDefinition.REPO_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader("org/sonar/l10n/solidity/rules/solidity", SolidityProfile.SONAR_WAY_PROFILE_PATH); ruleMetadataLoader.addRulesByAnnotatedClass(repository, CheckList.returnChecks()); repository.done(); if (externalIssuesSupported) { AbstractExternalReportSensor.createExternalRuleRepository(context, SoliumReportSensor.LINTER_ID, SoliumReportSensor.LINTER_NAME); } } SolidityRulesDefinition(boolean reportExternalIssues); @Override void define(Context context); static final String REPO_KEY; }### Answer:
@Test public void foo() { SolidityRulesDefinition rulesDefinition = new SolidityRulesDefinition(false); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); context.createRepository(Solidity.KEY, "solidity"); RulesDefinition.Repository repository = context.repository(SolidityRulesDefinition.REPO_KEY); assertThat(repository.name()).isEqualTo(SolidityRulesDefinition.REPO_NAME); assertThat(repository.language()).isEqualTo("solidity"); assertThat(repository.rules()).hasSize(24); List<Rule> activated = repository.rules().stream().filter(x -> x.status().name().equals("READY")).collect(Collectors.toList()); assertThat(activated).isNotEmpty(); assertThat(activated.size()).isEqualTo(24); }
@Test public void test_external() { SolidityRulesDefinition rulesDefinition = new SolidityRulesDefinition(true); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); context.createRepository(Solidity.KEY, "solidity"); RulesDefinition.Repository soliumRepository = context.repository("external_solium"); assertThat(context.repositories()).hasSize(2); assertThat(soliumRepository.isExternal()).isTrue(); assertThat(soliumRepository.name()).isEqualTo("Solium"); assertThat(soliumRepository.language()).isEqualTo("solidity"); assertThat(soliumRepository.rules()).hasSize(45); }