Example #1
0
 @Test(expected = IllegalStateException.class)
 public void cannotUpgradeLevel() {
   Level[] levels = Level.values();
   for (Level level : levels) {
     if (level.nextLevel() != null) continue;
     user.setLevel(level);
     user.upgradeLevel();
   }
 }
Example #2
0
 @Test
 public void upgradeLevel() {
   Level[] levels = Level.values();
   for (Level level : levels) {
     if (level.nextLevel() == null) continue;
     user.setLevel(level);
     user.upgradeLevel();
     assertThat(user.getLevel(), is(level.nextLevel()));
   }
 }
Example #3
0
 public User mapRow(ResultSet rs, int rowNum) throws SQLException {
   User user = new User();
   user.setId(rs.getString("id"));
   user.setName(rs.getString("name"));
   user.setPassword(rs.getString("password"));
   user.setLevel(Level.valueOf(rs.getInt("level")));
   user.setLogin(rs.getInt("login"));
   user.setRecommend(rs.getInt("recommend"));
   user.setEmail(rs.getString("email"));
   return user;
 }
Example #4
0
  @Test
  public void add() {
    userDao.deleteAll();

    User userWithLevel = users.get(4); // GOLD 레벨
    User userWithoutLevel = users.get(0);
    userWithoutLevel.setLevel(null);

    userService.add(userWithLevel);
    userService.add(userWithoutLevel);

    User userWithLevelRead = userDao.get(userWithLevel.getId());
    User userWithoutLevelRead = userDao.get(userWithoutLevel.getId());

    assertThat(userWithLevelRead.getLevel(), is(userWithLevel.getLevel()));
    assertThat(userWithoutLevelRead.getLevel(), is(Level.BASIC));
  }
Example #5
0
 public void add(User user) {
   if (user.getLevel() == null) {
     user.setLevel(Level.BASIC);
   }
   userDao.add(user);
 }