@Test
public void testLastMatch() {

    final Rule allowsDigits = Rules.fromJson(key(Rule.keys().type(), "ALLOW")
            .key(Rule.keys().pattern(), "[0-9]*").get());
    final Rule deniesLetters = Rules.fromJson(key(Rule.keys().type(), "DENY")
            .key(Rule.keys().pattern(), "[a-z]*").get());
    final List<Rule> expectRules = Arrays.asList(allowsDigits, deniesLetters);
    final Rule adHocDefault = new Rule(RuleType.ALLOW, Pattern.compile("\\.\\."));
    final Rule matched0 = Rules.lastMatch(expectRules, "...", rules -> adHocDefault);
    assertSame("expect specific default", adHocDefault, matched0);
    final Rule matched1 = Rules.lastMatch(expectRules, "...", null);
    assertSame("expect globbal default", Rules.DEFAULT_INCLUDE, matched1);
    final Rule matchedDigits = Rules.lastMatch(expectRules, "123");
    assertSame("expect digits rule", allowsDigits, matchedDigits);
    final Rule matchedAlpha = Rules.lastMatch(expectRules, "abc");
    assertSame("expect alpha rule", deniesLetters, matchedAlpha);
}