@Test
public void testGroupMatching() {

  VariableContext letterGroups = new VariableContext();
  letterGroups.putExtraDataset("groups", Sets.newHashSet("a", "b", "c"));
  VariableContext numberGroups = new VariableContext();
  numberGroups.putExtraDataset("groups", Sets.newHashSet("1", "2", "3"));
  VariableContext noGroups = new VariableContext();
  MappingRuleMatcher matchA =
      MappingRuleMatchers.createUserGroupMatcher("a");
  MappingRuleMatcher matchB =
      MappingRuleMatchers.createUserGroupMatcher("b");
  MappingRuleMatcher matchC =
      MappingRuleMatchers.createUserGroupMatcher("c");
  MappingRuleMatcher match1 =
      MappingRuleMatchers.createUserGroupMatcher("1");
  MappingRuleMatcher match2 =
      MappingRuleMatchers.createUserGroupMatcher("2");
  MappingRuleMatcher match3 =
      MappingRuleMatchers.createUserGroupMatcher("3");
  MappingRuleMatcher matchNull =
      MappingRuleMatchers.createUserGroupMatcher(null);
  //letter groups submission should match only the letters
  assertTrue(matchA.match(letterGroups));
  assertTrue(matchB.match(letterGroups));
  assertTrue(matchC.match(letterGroups));
  assertFalse(match1.match(letterGroups));
  assertFalse(match2.match(letterGroups));
  assertFalse(match3.match(letterGroups));
  assertFalse(matchNull.match(letterGroups));
  //numeric groups submission should match only the numbers
  assertFalse(matchA.match(numberGroups));
  assertFalse(matchB.match(numberGroups));
  assertFalse(matchC.match(numberGroups));
  assertTrue(match1.match(numberGroups));
  assertTrue(match2.match(numberGroups));
  assertTrue(match3.match(numberGroups));
  assertFalse(matchNull.match(numberGroups));
  //noGroups submission should not match anything
  assertFalse(matchA.match(noGroups));
  assertFalse(matchB.match(noGroups));
  assertFalse(matchC.match(noGroups));
  assertFalse(match1.match(noGroups));
  assertFalse(match2.match(noGroups));
  assertFalse(match3.match(noGroups));
  assertFalse(matchNull.match(noGroups));
}