@Test
public void testTemporaryBan() throws Throwable {
DBTransaction transaction = TransactionPool.get().beginWork();
try {
AccountDAO accountDAO = DAORegister.get().get(AccountDAO.class);
CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);
Player player = PlayerTestHelper.createPlayer("bobby");
Player admin = PlayerTestHelper.createPlayer("admin");
RPAction action = new RPAction();
action.put("type", "ban");
action.put("target", player.getName());
action.put("hours", 1);
action.put("reason", "We want to test the temporary bans");
if (!accountDAO.hasPlayer(transaction, player.getName())) {
accountDAO.addPlayer(transaction, player.getName(), new byte[0], "schnubbel");
}
accountDAO.setAccountStatus(transaction, player.getName(), "active");
if (!accountDAO.hasPlayer(transaction, admin.getName())) {
accountDAO.addPlayer(transaction, admin.getName(), new byte[0], "schnubbel");
}
// we do a character check now. Made the the character name and the account name the same
if (!characterDAO.hasCharacter(transaction, player.getName(), player.getName())) {
characterDAO.addCharacter(transaction, player.getName(), player.getName(), player);
}
accountDAO.setAccountStatus(transaction, admin.getName(), "active");
assertEquals("active", accountDAO.getAccountStatus(transaction, player.getName()));