-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathStatementPrintingSteps.java
57 lines (45 loc) · 1.67 KB
/
StatementPrintingSteps.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.craftedsw.acceptancetests.steps;
import static org.mockito.Mockito.mock;
import java.io.PrintStream;
import java.util.Date;
import org.craftedsw.domain.Account;
import org.craftedsw.domain.Amount;
import org.craftedsw.domain.Statement;
import org.jbehave.core.annotations.BeforeStory;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.mockito.InOrder;
import org.mockito.Mockito;
public class StatementPrintingSteps {
private Account account;
private PrintStream printer = mock(PrintStream.class);
@BeforeStory
public void beforeStoryDo() {
account = new Account(new Statement());
}
@Given("a client makes a deposit of $value on $date")
public void givenAClientMakesADepositOf(Amount value, Date date){
account.deposit(value, date);
}
@Given("a deposit of $value on $date")
public void givenADepositOf(Amount value, Date date){
account.deposit(value, date);
}
@Given("a withdrawal of $value on $date")
public void givenAWithdrawalOf(Amount value, Date date){
account.withdrawal(value, date);
}
@When("she prints her bank statement")
public void whenSheChecksHerBankStatement(){
account.printStatement(printer);
}
@Then("she would see $statement")
public void thenSheWouldSee(String statement){
InOrder inOrder = Mockito.inOrder(printer);
inOrder.verify(printer).println("date | credit | debit | balance");
inOrder.verify(printer).println("14/01/2012 | | 500.00 | 2500.00");
inOrder.verify(printer).println("13/01/2012 | 2000.00 | | 3000.00");
inOrder.verify(printer).println("10/01/2012 | 1000.00 | | 1000.00");
}
}