@Test
public void testInvalidChecks() throws Exception {

    RulesDefinition.Context context = new RulesDefinition.Context();
    RulesDefinition.NewRepository newRepository = context.createRepository("test", "java");
    newRepository.createRule("cardinality");
    newRepository.createRule("A1005");
    try {
        rulesDefinition.newRule(CheckWithNoAnnotation.class, newRepository);
    } catch (IllegalArgumentException illegaArgumentException) {
        assertThat(illegaArgumentException)
                .hasMessage(String.format("No Rule annotation was found on class %s", CheckWithNoAnnotation.class.getName()));
    }
    try {
        rulesDefinition.newRule(EmptyRuleKey.class, newRepository);
    } catch (IllegalArgumentException illegaArgumentException) {
        assertThat(illegaArgumentException)
                .hasMessage(String.format("No key is defined in Rule annotation of class %s", EmptyRuleKey.class.getName()));
    }
    try {
        rulesDefinition.newRule(UnregisteredRule.class, newRepository);
    } catch (IllegalStateException illegalStateException) {
        assertThat(illegalStateException)
                .hasMessage(String.format("No rule was created for class %s in test", UnregisteredRule.class.getName()));
    }
    rulesDefinition.newRule(CorrectRule.class, newRepository);
}