Exemple #1
0
  @Test
  @ExpectedDataSet
  public void create() throws Exception {
    User user = new User();
    user.setUsername("test");
    user.setPassword("test");
    Role role = new Role();
    role.setId(1);
    user.setRoles(Collections.singleton(role));

    user = userDao.create(user);
    assertNotEquals(0, user.getId());
  }
Exemple #2
0
  @Test
  @ExpectedDataSet
  public void update() throws Exception {
    User user = new User();
    user.setId(1);
    user.setUsername("nimda");
    user.setPassword("nimda");
    Role role = new Role();
    role.setId(1);
    user.setRoles(Collections.singleton(role));

    userDao.update(user);
  }
Exemple #3
0
  private static User getAdmin(long id, String username, String password) {
    User result = new User();

    result.setId(id);
    result.setUsername(username);
    result.setPassword(password);

    Role role = new Role();
    role.setId(1);
    role.setName("Admin");

    Permission permission = new Permission();
    permission.setId(1);
    permission.setScope(User.class);
    permission.setOperation(Operation.READ_LIST);

    role.setPermissions(Collections.singleton(permission));

    result.setRoles(Collections.singleton(role));

    return result;
  }