-
Notifications
You must be signed in to change notification settings - Fork 29
/
BankControllerBasicTest.java
53 lines (37 loc) · 1.23 KB
/
BankControllerBasicTest.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
package com.jayway.controller;
import com.jayway.service.AccountService;
import com.jayway.service.ImmutableAccount;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class BankControllerBasicTest {
@Mock
AccountService accountServiceMock;
@Mock
ImmutableAccount immutableAccountMock;
@InjectMocks
BankController bankController;
@Test
public void shouldGetAccount() {
when(accountServiceMock.get(1)).thenReturn(immutableAccountMock);
ImmutableAccount account = bankController.get(1);
assertThat(account, is(immutableAccountMock));
}
@Test
public void shouldDepositToAccount() {
bankController.deposit(1, new Amount(50));
verify(accountServiceMock).deposit(1, 50);
}
@Test
public void shouldDeleteAccount() {
bankController.delete(1);
verify(accountServiceMock).deleteAccount(1);
}
}