@Test
public void testMatches() throws Exception {

  assertFalse("null should not match any flavor", flavor("a", "b").matches(null));
  assertTrue("Equal flavors should match", flavor("a", "b").matches(flavor("a", "b")));
  assertFalse("Unequal flavors should not match", flavor("a", "b").matches(flavor("b", "a")));
  assertTrue("Wildcard type did not match", flavor("*", "b").matches(flavor("a", "b")));
  assertTrue("Match with wildcard type should be commutative",
          flavor("a", "b").matches(flavor("*", "b")) && flavor("*", "b").matches(flavor("a", "b")));
  assertTrue("Wildcard subtype did not match", flavor("a", "*").matches(flavor("a", "b")));
  assertTrue("Match with wildcard subtype should be commutative",
          flavor("a", "b").matches(flavor("a", "*")) && flavor("a", "*").matches(flavor("a", "b")));
  assertTrue("Wildcard in both type and subtype did not match", flavor("*", "*").matches(flavor("a", "b")));
  assertTrue("Match with wildcards in both type and subtype should be commutative",
          flavor("*", "*").matches(flavor("a", "b")) && flavor("a", "b").matches(flavor("*", "*")));
  assertTrue("Wildcard matches", flavor("*", "*").matches(flavor("*", "b")));
  assertTrue("Match between wildcards should be commutative",
          flavor("*", "*").matches(flavor("*", "b")) && flavor("*", "b").matches(flavor("*", "*")));
  assertTrue("Wildcard matches", flavor("*", "*").matches(flavor("a", "*")));
  assertTrue("Match between wildcards should be commutative",
          flavor("*", "*").matches(flavor("a", "*")) && flavor("a", "*").matches(flavor("*", "*")));
  assertTrue("Wildcard matches", flavor("*", "*").matches(flavor("*", "*")));
}