@Test
public void testResolveNoLoginAliasToUserName() throws Exception {

  reset(servletRequestAttributes);
  // No request attributes/http session available yet
  RequestContextHolder.setRequestAttributes(null);
  assertEquals("user", AuthorizationHelper.resolveLoginAliasToUserName("user"));
  // request attributes available but user doesn't have any login aliases
  RequestContextHolder.setRequestAttributes(servletRequestAttributes);
  expect(servletRequestAttributes.getAttribute(eq("nosuchalias"), eq(RequestAttributes.SCOPE_SESSION)))
    .andReturn(null).atLeastOnce();
  replay(servletRequestAttributes);
  // When
  String user = AuthorizationHelper.resolveLoginAliasToUserName("nosuchalias");
  // Then
  verify(servletRequestAttributes);
  assertEquals("nosuchalias", user);
}