@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(); } }
@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())); } }
protected void upgradeLevel(User user) { user.upgradeLevel(); userDao.update(user); sendUpgradeEMail(user); }