Created
January 10, 2015 13:22
-
-
Save javaeeeee/c82dc85b05225bd16d79 to your computer and use it in GitHub Desktop.
A mockito test to make sure only desired interactions took place
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testWithdrawCashNotEnoughMoneyOnAccount() throws BankServiceException { | |
//given | |
BigDecimal amount = new BigDecimal("1000"); | |
BigDecimal balance = new BigDecimal("500"); | |
Mockito.when(keypad.getAmount()).thenReturn(amount); | |
Mockito.when(bankService.getBalance()).thenReturn(balance); | |
Mockito.when(cashDispenser.isThereEnoughMoney(amount)).thenReturn(true); | |
//when | |
sut.withdrawCash(); | |
//then | |
Mockito.verifyZeroInteractions(cashDispenser); | |
Mockito.verify(bankService, Mockito.times(0)) | |
.debit(Mockito.any(BigDecimal.class)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment