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

    Request request = createMock(Request.class);
    Map<String, Definition> definitions = createMock(Map.class);
    Map<String, Object> scope = createMock(Map.class);
    Definition definition = createMock(Definition.class);
    expect(request.getContext("request")).andReturn(scope);
    expect(scope.get(DEFAULT_DEFINITIONS_ATTRIBUTE_NAME)).andReturn(
            definitions);
    expect(definition.getName()).andReturn(null);
    expect(definitions.containsKey("$anonymousMutableDefinition1"))
            .andReturn(false);
    definition.setName("$anonymousMutableDefinition1");
    expect(definition.isExtending()).andReturn(true);
    // trick to test resolve definition separately.
    expect(definition.isExtending()).andReturn(false);
    expect(definition.getName()).andReturn("$anonymousMutableDefinition1");
    expect(definitions.put("$anonymousMutableDefinition1", definition))
            .andReturn(null);
    replay(wrapped, request, definitions, scope, definition);
    container.register(definition, request);
    verify(wrapped, request, definitions, scope, definition);
}