1
1
package com .company .crm .client ;
2
2
3
+ import static org .mockito .ArgumentMatchers .anyString ;
4
+ import static org .mockito .Mockito .doNothing ;
3
5
import static org .mockito .Mockito .times ;
4
6
import static org .mockito .Mockito .verify ;
5
7
import static org .mockito .Mockito .when ;
9
11
import org .dominokit .domino .ui .forms .TextBox ;
10
12
import org .dominokit .domino .ui .layout .Layout ;
11
13
import org .dominokit .domino .ui .lists .ListGroup ;
14
+ import org .junit .jupiter .api .BeforeEach ;
12
15
import org .junit .jupiter .api .Test ;
13
16
import org .junit .jupiter .api .extension .ExtendWith ;
14
17
import org .mockito .Answers ;
15
18
import org .mockito .Mock ;
19
+ import org .mockito .Mockito ;
16
20
import org .mockito .junit .jupiter .MockitoExtension ;
17
21
18
22
import com .company .crm .shared .PersonDto ;
@@ -44,11 +48,16 @@ public class HomeCompositeTest {
44
48
@ Mock
45
49
PersonRenderer personItemRenderer ;
46
50
47
- @ Test
48
- void handle_check_what_dialog_to_display () {
49
- HomeComposite homeComposite = new HomeComposite (nameTextBox , birthdateDateBox , personListGroup ,
51
+ HomeComposite homeComposite ;
52
+
53
+ @ BeforeEach
54
+ void setup () {
55
+ homeComposite = new HomeComposite (nameTextBox , birthdateDateBox , personListGroup ,
50
56
donePersonListGroup , personItemRenderer , addButton , layout , personCallbackApi );
57
+ }
51
58
59
+ @ Test
60
+ void handle_check_what_dialog_to_display_items_3 () {
52
61
PersonDto personDto = new PersonDto ();
53
62
54
63
when (personListGroup .getItems ().size ()).thenReturn (3 );
@@ -58,4 +67,34 @@ void handle_check_what_dialog_to_display() {
58
67
verify (donePersonListGroup , times (1 )).addItem (personDto );
59
68
}
60
69
70
+ @ Test
71
+ void handle_check_what_dialog_to_display_items_2 () {
72
+ HomeComposite homeCompositeSpy = Mockito .spy (homeComposite );
73
+
74
+ PersonDto personDto = new PersonDto ();
75
+
76
+ when (personListGroup .getItems ().size ()).thenReturn (2 );
77
+ doNothing ().when (homeCompositeSpy ).createWarningDialog ();
78
+
79
+ homeCompositeSpy .handleCheckOkClick (personDto );
80
+
81
+ verify (homeCompositeSpy , times (1 )).createWarningDialog ();
82
+ verify (donePersonListGroup , times (1 )).addItem (personDto );
83
+ }
84
+
85
+ @ Test
86
+ void handle_check_what_dialog_to_display_items_0 () {
87
+ HomeComposite homeCompositeSpy = Mockito .spy (homeComposite );
88
+
89
+ PersonDto personDto = new PersonDto ();
90
+
91
+ when (personListGroup .getItems ().size ()).thenReturn (0 );
92
+ doNothing ().when (homeCompositeSpy ).createErrorDialog (anyString ());
93
+
94
+ homeCompositeSpy .handleCheckOkClick (personDto );
95
+
96
+ verify (homeCompositeSpy , times (1 )).createErrorDialog (anyString ());
97
+ verify (donePersonListGroup , times (1 )).addItem (personDto );
98
+ }
99
+
61
100
}
0 commit comments