@SuppressWarnings("unchecked")
@Test
public void testGetDefinition() {

    DefinitionDAO<Locale> dao = createMock(DefinitionDAO.class);
    LocaleResolver localeResolver = createMock(LocaleResolver.class);
    Request request = createMock(Request.class);
    Attribute templateAttribute = Attribute.createTemplateAttribute("/mytemplate.jsp");
    Definition definition = new Definition("myDefinition", null, null);
    definition.setExtends("anotherDefinition");
    Map<String, Attribute> attributes = new HashMap<String, Attribute>();
    attributes.put("first", new Attribute("myValue"));
    Definition anotherDefinition = new Definition("anotherDefinition", templateAttribute, attributes);
    Locale locale = Locale.ITALY;
    expect(localeResolver.resolveLocale(request)).andReturn(locale);
    expect(dao.getDefinition("myDefinition", locale)).andReturn(definition);
    expect(dao.getDefinition("anotherDefinition", locale)).andReturn(anotherDefinition);
    LocaleDefinitionsFactory factory = new LocaleDefinitionsFactory();
    replay(dao, localeResolver, request);
    factory.setDefinitionDAO(dao);
    factory.setLocaleResolver(localeResolver);
    Definition realDefinition = new Definition(definition);
    realDefinition.inherit(anotherDefinition);
    assertEquals(realDefinition, factory.getDefinition("myDefinition", request));
    verify(dao, localeResolver, request);
}