2
2
3
3
import groovy .text .SimpleTemplateEngine ;
4
4
import groovy .text .Template ;
5
- import org .junit . Assert ;
5
+ import org .hamcrest . Matchers ;
6
6
import org .junit .Before ;
7
7
import org .junit .Test ;
8
- import org .mockito .internal .matchers .Contains ;
9
8
import org .openmrs .ui .framework .UiFrameworkException ;
10
9
import org .openmrs .ui .framework .fragment .action .FragmentActionResult ;
11
10
import org .openmrs .ui .framework .fragment .action .SuccessResult ;
25
24
import java .util .HashMap ;
26
25
import java .util .Map ;
27
26
27
+ import static org .hamcrest .MatcherAssert .assertThat ;
28
+ import static org .junit .Assert .assertNotNull ;
29
+ import static org .junit .Assert .assertNull ;
30
+
28
31
public class FragmentFactoryTest {
29
32
30
33
FragmentFactory factory ;
@@ -61,9 +64,9 @@ public void configureModel(FragmentContext pageContext) {
61
64
*/
62
65
@ Test
63
66
public void getController_shouldGetAControllerFromTheSpecifiedProvider () throws Exception {
64
- Assert . assertNotNull (factory .getController (new FragmentRequest ("somemodule" , "somefragment" )));
65
- Assert . assertNull (factory .getController (new FragmentRequest ("somemodule" , "otherfragment" )));
66
- Assert . assertNull (factory .getController (new FragmentRequest ("othermodule" , "somefragment" )));
67
+ assertNotNull (factory .getController (new FragmentRequest ("somemodule" , "somefragment" )));
68
+ assertNull (factory .getController (new FragmentRequest ("somemodule" , "otherfragment" )));
69
+ assertNull (factory .getController (new FragmentRequest ("othermodule" , "somefragment" )));
67
70
}
68
71
69
72
/**
@@ -72,9 +75,9 @@ public void getController_shouldGetAControllerFromTheSpecifiedProvider() throws
72
75
*/
73
76
@ Test
74
77
public void getController_shouldGetAControllerFromAnyProviderIfNoneSpecified () throws Exception {
75
- Assert . assertNotNull (factory .getController (new FragmentRequest ("*" , "somefragment" )));
76
- Assert . assertNotNull (factory .getController (new FragmentRequest ("*" , "otherfragment" )));
77
- Assert . assertNull (factory .getController (new FragmentRequest ("*" , "nothingwiththisname" )));
78
+ assertNotNull (factory .getController (new FragmentRequest ("*" , "somefragment" )));
79
+ assertNotNull (factory .getController (new FragmentRequest ("*" , "otherfragment" )));
80
+ assertNull (factory .getController (new FragmentRequest ("*" , "nothingwiththisname" )));
78
81
}
79
82
80
83
/**
@@ -92,9 +95,9 @@ public void getController_shouldFailIfAnInvalidProviderIsSpecified() throws Exce
92
95
*/
93
96
@ Test
94
97
public void getView_shouldGetAViewFromTheRequestedProvider () throws Exception {
95
- Assert . assertNotNull (factory .getView (new FragmentRequest ("somemodule" , "somefragment" ), null ));
96
- Assert . assertNull (factory .getView (new FragmentRequest ("somemodule" , "otherfragment" ), null ));
97
- Assert . assertNull (factory .getView (new FragmentRequest ("othermodule" , "somefragment" ), null ));
98
+ assertNotNull (factory .getView (new FragmentRequest ("somemodule" , "somefragment" ), null ));
99
+ assertNull (factory .getView (new FragmentRequest ("somemodule" , "otherfragment" ), null ));
100
+ assertNull (factory .getView (new FragmentRequest ("othermodule" , "somefragment" ), null ));
98
101
}
99
102
100
103
/**
@@ -103,9 +106,9 @@ public void getView_shouldGetAViewFromTheRequestedProvider() throws Exception {
103
106
*/
104
107
@ Test
105
108
public void getView_shouldGetAViewFromAnyProviderIfNoneIsSpecified () throws Exception {
106
- Assert . assertNotNull (factory .getView (new FragmentRequest ("*" , "somefragment" ), null ));
107
- Assert . assertNotNull (factory .getView (new FragmentRequest ("*" , "otherfragment" ), null ));
108
- Assert . assertNull (factory .getView (new FragmentRequest ("*" , "nothingwiththisname" ), null ));
109
+ assertNotNull (factory .getView (new FragmentRequest ("*" , "somefragment" ), null ));
110
+ assertNotNull (factory .getView (new FragmentRequest ("*" , "otherfragment" ), null ));
111
+ assertNull (factory .getView (new FragmentRequest ("*" , "nothingwiththisname" ), null ));
109
112
}
110
113
111
114
/**
@@ -125,7 +128,7 @@ public void process_shouldSetCustomModelProperties() throws Exception {
125
128
FragmentContext fragmentContext = new FragmentContext (fragmentRequest , pageContext );
126
129
127
130
String result = factory .process (fragmentContext );
128
- Assert . assertThat (result , new Contains ( "Testing Success!!!" ));
131
+ assertThat (result , Matchers . containsString (( "Testing Success!!!" ) ));
129
132
}
130
133
131
134
private PageContext buildPageContext () {
@@ -322,22 +325,22 @@ public String render(FragmentContext context) throws PageAction {
322
325
public class ControllerAndActionThatTakeIntegerType {
323
326
324
327
public void controller (Integer injected , Long notInjected ) {
325
- Assert . assertNotNull ("Integer argument was not injected" , injected );
326
- Assert . assertNull ("Long argument should not have been injected" , notInjected );
328
+ assertNotNull ("Integer argument was not injected" , injected );
329
+ assertNull ("Long argument should not have been injected" , notInjected );
327
330
}
328
331
329
332
public FragmentActionResult action (Integer injected , Long notInjected ) {
330
- Assert . assertNotNull ("Integer argument was not injected" , injected );
331
- Assert . assertNull ("Long argument should not have been injected" , notInjected );
333
+ assertNotNull ("Integer argument was not injected" , injected );
334
+ assertNull ("Long argument should not have been injected" , notInjected );
332
335
return new SuccessResult ();
333
336
}
334
337
}
335
338
336
339
public class ActionThatTakeServletRequestResponse {
337
340
338
341
public FragmentActionResult action (HttpServletRequest httpRequest , HttpServletResponse httpResponse ) {
339
- Assert . assertNotNull ("HttpServletRequest argument was not injected" , httpRequest );
340
- Assert . assertNotNull ("HttpServletResponse argument was not injected" , httpResponse );
342
+ assertNotNull ("HttpServletRequest argument was not injected" , httpRequest );
343
+ assertNotNull ("HttpServletResponse argument was not injected" , httpResponse );
341
344
return new SuccessResult ();
342
345
}
343
346
}
0 commit comments