示例#1
0
  @Test
  public void testAdminUser() {
    AdminUser adminUser = new AdminUser();

    Assert.assertEquals(
        "authorities must match",
        Sets.newHashSet(Authorities.ROLE_ADMIN_USER.getGrantedAuthority()),
        adminUser.getAuthorities());
  }
示例#2
0
  public void testBusinessUser() {
    // Initialize an object
    AdminUser user = new AdminUser();
    user.setAccessCode(ACCESSCODE1);
    user.setLastName(LASTNAME1);
    user.setFirstName(FIRSTNAME1);
    user.setEmail(EMAIL1);
    user.setStatus(STATUS1);
    user.setLocale(Locale.ENGLISH);
    user.setUserLevel(LEVEL);

    // Create test
    AdminUserHome.create(user);

    AdminUser userStored = AdminUserHome.findByPrimaryKey(user.getUserId());
    assertEquals(userStored.getAccessCode(), user.getAccessCode());
    assertEquals(userStored.getLastName(), user.getLastName());
    assertEquals(userStored.getFirstName(), user.getFirstName());
    assertEquals(userStored.getEmail(), user.getEmail());
    assertEquals(userStored.getStatus(), user.getStatus());
    assertEquals(userStored.getLocale(), user.getLocale());
    assertEquals(userStored.getUserLevel(), user.getUserLevel());

    AdminUserHome.createRightForUser(user.getUserId(), RIGHT1);
    AdminUserHome.createRoleForUser(user.getUserId(), ROLE1);

    // List Test
    Collection listUsers = AdminUserHome.findUserList();
    assertTrue(listUsers.size() > 0);

    Map listRights = AdminUserHome.getRightsListForUser(user.getUserId());

    //        assertTrue( listRights.size() > 0 );
    Map listRoles = AdminUserHome.getRolesListForUser(user.getUserId());
    //        assertTrue( listRoles.size() > 0 );

    // Update test
    user.setAccessCode(ACCESSCODE2);
    user.setLastName(LASTNAME2);
    user.setFirstName(FIRSTNAME2);
    user.setEmail(EMAIL2);
    user.setStatus(STATUS2);
    user.setLocale(Locale.FRANCE);

    AdminUserHome.update(user);
    userStored = AdminUserHome.findByPrimaryKey(user.getUserId());
    assertEquals(userStored.getAccessCode(), user.getAccessCode());
    assertEquals(userStored.getLastName(), user.getLastName());
    assertEquals(userStored.getFirstName(), user.getFirstName());
    assertEquals(userStored.getEmail(), user.getEmail());
    assertEquals(userStored.getStatus(), user.getStatus());
    //        assertEquals( userStored.getLocale(  ), user.getLocale(  ) );

    // Delete test
    AdminUserHome.removeAllRightsForUser(user.getUserId());
    AdminUserHome.removeAllRolesForUser(user.getUserId());
    AdminUserHome.remove(user.getUserId());
    userStored = AdminUserHome.findByPrimaryKey(user.getUserId());
    assertNull(userStored);
  }
示例#3
0
  @Test
  public void testToString() {
    AdminUser adminUser = new AdminUser();

    Assert.assertNotNull("toString must not be null", adminUser.toString());
  }