@Test(expected = IllegalStateException.class) public void anIllegalStateExceptionShouldBeThrownWhenThePlayerIsNotAtTheTable() throws GameException { table.removeAllPlayers(); underTest.forPlayer(GAME_PLAYER).increaseBalanceBy(AMOUNT, REFERENCE, null); }
@Test @Ignore("To be re-enabled once tx results update the balance") public void balanceQueriesShouldUseTheCachedBalance() throws GameException { // TODO TX-RETURN: this should be enabled once update on tx-return is implemented assertThat(underTest.forPlayer(GAME_PLAYER).getBalance(), is(equalTo(PLAYER_BALANCE))); verifyZeroInteractions(gameHostWallet); }
@Test public void anAsyncTransferIsTriggeredWhenWeTransferToThePlayersAccount() throws GameException, WalletServiceException { underTest.forPlayer(GAME_PLAYER).increaseBalanceBy(AMOUNT, AUDIT_LABEL, REFERENCE); verify(gameHostWallet) .post( TABLE_ID, GAME_ID, playerInfo, AMOUNT, TransactionType.Return, AUDIT_LABEL, REFERENCE, NEW_UUID); }
@Test public void anAsyncTransferIsTriggeredWhenWeTransferFromThePlayersAccount() throws GameException, WalletServiceException { underTest.forPlayer(GAME_PLAYER).decreaseBalanceBy(AMOUNT, AUDIT_LABEL, REFERENCE); verify(gameHostWallet) .post( TABLE_ID, GAME_ID, playerInfo, BigDecimal.ZERO.subtract(AMOUNT), TransactionType.Stake, AUDIT_LABEL, REFERENCE, NEW_UUID); }
@SuppressWarnings({"ThrowableInstanceNeverThrown"}) @Test(expected = GameException.class) public void failedTransferFromThePlayerShouldThrowAGameException() throws WalletServiceException, GameException { doThrow(new WalletServiceException("aTestException")) .when(gameHostWallet) .post( TABLE_ID, GAME_ID, playerInfo, BigDecimal.ZERO.subtract(AMOUNT), TransactionType.Stake, AUDIT_LABEL, REFERENCE, NEW_UUID); underTest.forPlayer(GAME_PLAYER).decreaseBalanceBy(AMOUNT, AUDIT_LABEL, REFERENCE); }