Skip to content

Commit

Permalink
finish step 10
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Jun 21, 2013
1 parent 62da24a commit 29dd9e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Binary file modified BankAccountDay05/bin/test/BankAccountTest.class
Binary file not shown.
17 changes: 15 additions & 2 deletions BankAccountDay05/src/test/BankAccountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public void testDepositShouldBeSaveToDB() {
String description = "Deposit with amount is 200";
BankAccountDTO bankAccount = BankAccount.openAccount(accountNumber);
when(mockBankAccountDAO.getAccount(bankAccount.getAccountNumber())).thenReturn(bankAccount);
Long timeStamp = mockCalendar.getTimeInMillis();
Long timeStamp = System.currentTimeMillis();
when(mockCalendar.getTimeInMillis()).thenReturn(timeStamp);
BankAccount.deposit(accountNumber, amount, description);
ArgumentCaptor<TransactionDTO> argument = ArgumentCaptor.forClass(TransactionDTO.class);
verify(mockTransactionDAO, times(1)).doTransaction(argument.capture());
Expand Down Expand Up @@ -113,7 +114,8 @@ public void testWithdrawShouldBeSaveToDB() {
String accountNumber = "1234567890";
float amount = 50F;
String description = "Withdraw with amount is 50";
Long timeStamp = mockCalendar.getTimeInMillis();
Long timeStamp = System.currentTimeMillis();
when(mockCalendar.getTimeInMillis()).thenReturn(timeStamp);
BankAccountDTO bankAccount = BankAccount.openAccount(accountNumber);
when(mockBankAccountDAO.getAccount(bankAccount.getAccountNumber())).thenReturn(bankAccount);
BankAccount.withdraw(accountNumber, amount, description);
Expand Down Expand Up @@ -186,4 +188,15 @@ public void testGetNumberOfNewTransactions() {
}
}

@Test
public void testOpenAccountShouldSaveTimeStampToDB() {
String accountNumber = "1234567890";
BankAccount.openAccount(accountNumber);
Long timeStamp = System.currentTimeMillis();
when(mockCalendar.getTimeInMillis()).thenReturn(timeStamp);
ArgumentCaptor<BankAccountDTO> openAccount = ArgumentCaptor.forClass(BankAccountDTO.class);
verify(mockBankAccountDAO, times(1)).save(openAccount.capture());
assertTrue(openAccount.getValue().getOpenTimestampt() != null);
assertEquals(timeStamp, openAccount.getValue().getOpenTimestampt());
}
}

0 comments on commit 29dd9e2

Please sign in to comment.