@Test
public void testAllRulesValid() {

    final CheckstyleExtensionRulesDefinition definition =
        new CheckstyleExtensionRulesDefinition(new RulesDefinitionXmlLoader());
    final RulesDefinition.Context context = new RulesDefinition.Context();
    definition.define(context);
    final RulesDefinition.Repository repository = context.repository("checkstyle");
    Assert.assertEquals("Incorrect repository name", "Checkstyle", repository.name());
    Assert.assertEquals("Incorrect repository language", "java", repository.language());
    final List<RulesDefinition.Rule> rules = repository.rules();
    Assert.assertEquals("Incorrect number of loaded rules", 59, rules.size());
    for (RulesDefinition.Rule rule : rules) {
        Assert.assertNotNull("Rule key is not set", rule.key());
        Assert.assertNotNull("Config key is not set for rule " + rule.key(),
            rule.internalKey());
        Assert.assertNotNull("Name is not set for rule " + rule.key(), rule.name());
        Assert.assertNotNull("Description is not set for rule " + rule.key(),
            rule.htmlDescription());
        for (RulesDefinition.Param param : rule.params()) {
            Assert.assertNotNull("Key is not set for a parameter of rule " + rule.key(),
                param.key());
            Assert.assertNotNull("Description is not set for a parameter '"
                + param.name() + "' of rule " + rule.key(), param.description());
        }
    }
}