@Test
public void testAddDefinitionsAsPatternMatchers() {

    DefinitionPatternMatcherFactory factory = createMock(DefinitionPatternMatcherFactory.class);
    PatternRecognizer recognizer = createMock(PatternRecognizer.class);
    DefinitionPatternMatcher firstMatcher = createMock(DefinitionPatternMatcher.class);
    DefinitionPatternMatcher thirdMatcher = createMock(DefinitionPatternMatcher.class);
    expect(recognizer.isPatternRecognized("first")).andReturn(true);
    expect(recognizer.isPatternRecognized("second")).andReturn(false);
    expect(recognizer.isPatternRecognized("third")).andReturn(true);
    Definition firstDefinition = new Definition("first", (Attribute) null,
            null);
    Definition secondDefinition = new Definition("second",
            (Attribute) null, null);
    Definition thirdDefinition = new Definition("third", (Attribute) null,
            null);
    expect(factory.createDefinitionPatternMatcher("first", firstDefinition))
            .andReturn(firstMatcher);
    expect(factory.createDefinitionPatternMatcher("third", thirdDefinition))
            .andReturn(thirdMatcher);
    replay(factory, recognizer, firstMatcher, thirdMatcher);
    BasicPatternDefinitionResolver<Integer> resolver = new BasicPatternDefinitionResolver<Integer>(
            factory, recognizer);
    Map<String, Definition> localeDefsMap = new LinkedHashMap<String, Definition>();
    localeDefsMap.put("first", firstDefinition);
    localeDefsMap.put("second", secondDefinition);
    localeDefsMap.put("third", thirdDefinition);
    List<DefinitionPatternMatcher> matchers = new ArrayList<DefinitionPatternMatcher>();
    resolver.addDefinitionsAsPatternMatchers(matchers, localeDefsMap);
    assertEquals(2, matchers.size());
    assertEquals(firstMatcher, matchers.get(0));
    assertEquals(thirdMatcher, matchers.get(1));
    verify(factory, recognizer, firstMatcher, thirdMatcher);
}