@Test
public void testGetAuthorizable() throws Exception {

    UserManager delegate = mock(UserManager.class);
    UserManagerFacade facade = getFacade(delegate);
    final User userValue = mock(User.class);
    when(userValue.getID()).thenReturn("foo");
    final Group groupValue = mock(Group.class);
    when(groupValue.getID()).thenReturn("bar");
    when(delegate.getAuthorizable(anyString(), isNull())).thenReturn(null);
    when(delegate.getAuthorizable("foo", User.class)).thenReturn(userValue);
    when(delegate.getAuthorizable("foo", Authorizable.class)).thenReturn(userValue);
    when(delegate.getAuthorizable("bar", Group.class)).thenReturn(groupValue);
    when(delegate.getAuthorizable("bar", Authorizable.class)).thenReturn(groupValue);
    assertNull("is null", facade.getAuthorizable("", null));
    Authorizable userFacadeAuthz = facade.getAuthorizable("foo", Authorizable.class);
    assertTrue("is user facade", userFacadeAuthz instanceof UserFacade);
    assertEquals("is same id", "foo", userFacadeAuthz.getID());
    User userFacade = facade.getAuthorizable("foo", User.class);
    assertTrue("is user facade", userFacade instanceof UserFacade);
    assertEquals("is same id", "foo", userFacade.getID());
    Authorizable groupFacadeAuthz = facade.getAuthorizable("bar", Authorizable.class);
    assertTrue("is group facade", groupFacadeAuthz instanceof GroupFacade);
    assertEquals("is same id", "bar", groupFacadeAuthz.getID());
    Group groupFacade = facade.getAuthorizable("bar", Group.class);
    assertTrue("is group facade", groupFacade instanceof GroupFacade);
    assertEquals("is same id", "bar", groupFacade.getID());
}