UpdateAccountBeanTest.java
2.33 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
package org.legrog.web.account;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
import org.legrog.entities.AccountProperty;
import org.legrog.entities.AccountRole;
import org.legrog.entities.DisplayNameMask;
import org.legrog.test.MockitoExtension;
import org.legrog.web.xyz.SharedService;
import org.mockito.Mock;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
/**
* Created by jai on 15/11/16.
*/
@DisplayName("Update Account Bean")
@ExtendWith(MockitoExtension.class)
@RunWith(JUnitPlatform.class)
public class UpdateAccountBeanTest {
UpdateAccountBean updateUserBean;
@BeforeEach
public void setUp(@Mock AccountService userService, @Mock SharedService sharedService) throws Exception {
updateUserBean = new UpdateAccountBean(userService, sharedService) ;
}
@Test
@DisplayName("depends on Shared Service and Account Service")
public void testDependencies() {
assertThat(updateUserBean).isNotNull();
}
@Nested
@DisplayName("post construct method")
class init {
private List<DisplayNameMask> displayNameMasks;
private List<AccountProperty> userProperties;
private List<AccountRole> accountRoles;
@BeforeEach
public void setUp(@Mock SharedService sharedService) {
when(sharedService.getAllDisplayNameMasks()).thenReturn(displayNameMasks);
when(sharedService.getAvailableUserProperties()).thenReturn(userProperties);
when(sharedService.getAvailableUserRoles()).thenReturn(accountRoles);
}
@Test
@DisplayName("should set lists of available masks, account roles, and account properties from shared service")
public void testList(@Mock SharedService sharedService) {
updateUserBean.init();
assertThat(updateUserBean.getAllDisplayNameMasks()).isEqualTo(displayNameMasks);
assertThat(updateUserBean.getAvailableUserProperties()).isEqualTo(userProperties);
assertThat(updateUserBean.getAvailableAccountRoles()).isEqualTo(accountRoles);
}
}
}