assertFalse(gaeUser.isAdmin());
}
/** Test initializeCredentials(). */
@Test public void testInitializeCredentials() {
User user = new User("email", "authDomain", "userId", "federatedIdentity");
GaeUser gaeUser = new GaeUser();
gaeUser.initializeCredentials(user, false, null);
assertNotNull(gaeUser);
assertEquals(user.getAuthDomain(), gaeUser.getAuthDomain());
assertEquals(user.getFederatedIdentity(), gaeUser.getFederatedIdentity());
assertEquals(user.getEmail(), gaeUser.getEmail());
assertEquals(user.getUserId(), gaeUser.getUserId());
assertEquals(2, gaeUser.getRoles().size());
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ANONYMOUS));
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_USER));
assertEquals(2, gaeUser.getAuthorities().length);
assertContains(GaeRole.ROLE_ANONYMOUS, gaeUser.getAuthorities());
assertContains(GaeRole.ROLE_USER, gaeUser.getAuthorities());
assertNotNull(gaeUser.toString());
assertFalse(gaeUser.isAnonymous());
assertFalse(gaeUser.isAdmin());
gaeUser = new GaeUser();
gaeUser.initializeCredentials(user, true, null);
assertNotNull(gaeUser);
assertEquals(user.getAuthDomain(), gaeUser.getAuthDomain());
assertEquals(user.getFederatedIdentity(), gaeUser.getFederatedIdentity());
assertEquals(user.getEmail(), gaeUser.getEmail());
assertEquals(user.getUserId(), gaeUser.getUserId());
assertEquals(3, gaeUser.getRoles().size());
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ANONYMOUS));
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_USER));
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ADMIN));
assertEquals(3, gaeUser.getAuthorities().length);
assertContains(GaeRole.ROLE_ANONYMOUS, gaeUser.getAuthorities());
assertContains(GaeRole.ROLE_USER, gaeUser.getAuthorities());
assertContains(GaeRole.ROLE_ADMIN, gaeUser.getAuthorities());
assertNotNull(gaeUser.toString());
assertFalse(gaeUser.isAnonymous());
assertTrue(gaeUser.isAdmin());
gaeUser = new GaeUser();
gaeUser.initializeCredentials(user, true, new String[] { "ONE", "TWO", });
assertNotNull(gaeUser);
assertEquals(user.getAuthDomain(), gaeUser.getAuthDomain());
assertEquals(user.getFederatedIdentity(), gaeUser.getFederatedIdentity());
assertEquals(user.getEmail(), gaeUser.getEmail());
assertEquals(user.getUserId(), gaeUser.getUserId());
assertEquals(5, gaeUser.getRoles().size());
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ANONYMOUS));
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_USER));
assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ADMIN));
assertTrue(gaeUser.getRoles().contains(new GaeRole("ONE")));