29
29
import static org .junit .Assert .assertEquals ;
30
30
import static org .junit .Assert .assertFalse ;
31
31
import static org .junit .Assert .assertTrue ;
32
- import static org .powermock .api .mockito .PowerMockito .mock ;
33
- import static org .powermock .api .mockito .PowerMockito .when ;
32
+ import static org .mockito .Mockito .when ;
33
+ import static org .mockito .Mockito .mock ;
34
+ import static org .mockito .Mockito .doThrow ;
34
35
35
36
/**
36
37
* Tests the {@link SearchIndexController} controller
@@ -74,7 +75,7 @@ public void rebuildSearchIndex_shouldReturnTrueForSuccessIfTheUpdateDoesNotFail(
74
75
when (userContext .isAuthenticated ()).thenReturn (true );
75
76
assertTrue (Context .getUserContext ().isAuthenticated ());
76
77
77
- Mockito . when (contextDao .updateSearchIndexAsync ()).thenReturn (null );
78
+ when (contextDao .updateSearchIndexAsync ()).thenReturn (null );
78
79
Map <String , Object > response = controller .rebuildSearchIndex ();
79
80
assertEquals (true , response .get ("success" ));
80
81
}
@@ -89,7 +90,7 @@ public void rebuildSearchIndex_shouldReturnFalseForSuccessIfARuntimeExceptionIsT
89
90
when (userContext .isAuthenticated ()).thenReturn (true );
90
91
assertTrue (Context .getUserContext ().isAuthenticated ());
91
92
92
- Mockito . doThrow (new RuntimeException ("boom" )).when (contextDao ).updateSearchIndexAsync ();
93
+ doThrow (new RuntimeException ("boom" )).when (contextDao ).updateSearchIndexAsync ();
93
94
Map <String , Object > response = controller .rebuildSearchIndex ();
94
95
assertEquals (false , response .get ("success" ));
95
96
}
@@ -104,7 +105,7 @@ public void rebuildSearchIndex_shouldReturnFalseForSuccessIfAUnAuthenticatedUser
104
105
when (userContext .isAuthenticated ()).thenReturn (false );
105
106
assertFalse (Context .getUserContext ().isAuthenticated ());
106
107
107
- Mockito . when (contextDao .updateSearchIndexAsync ()).thenReturn (null );
108
+ when (contextDao .updateSearchIndexAsync ()).thenReturn (null );
108
109
Map <String , Object > response = controller .rebuildSearchIndex ();
109
110
assertEquals (false , response .get ("success" ));
110
111
}
@@ -115,7 +116,7 @@ public void rebuildSearchIndex_shouldReturnFalseForSuccessIfAUnAuthenticatedUser
115
116
*/
116
117
@ Test
117
118
public void getStatus_shouldReturnInProgressForStatusIfRebuildSearchIndexIsInProgress () throws Exception {
118
- Mockito . when (contextDao .updateSearchIndexAsync ()).thenAnswer ((Answer <Future >) invocationOnMock -> {
119
+ when (contextDao .updateSearchIndexAsync ()).thenAnswer ((Answer <Future >) invocationOnMock -> {
119
120
Future <String > future = mock (FutureTask .class );
120
121
when (future .isDone ()).thenReturn (false );
121
122
return future ;
@@ -131,7 +132,7 @@ public void getStatus_shouldReturnInProgressForStatusIfRebuildSearchIndexIsInPro
131
132
*/
132
133
@ Test
133
134
public void getStatus_shouldReturnSuccessForStatusIfRebuildSearchIndexIsCompletedSuccessfully () throws Exception {
134
- Mockito . when (contextDao .updateSearchIndexAsync ()).thenAnswer ((Answer <Future >) invocationOnMock -> {
135
+ when (contextDao .updateSearchIndexAsync ()).thenAnswer ((Answer <Future >) invocationOnMock -> {
135
136
Future <String > future = mock (FutureTask .class );
136
137
when (future .isDone ()).thenReturn (true );
137
138
when (future .isCancelled ()).thenReturn (false );
@@ -148,7 +149,7 @@ public void getStatus_shouldReturnSuccessForStatusIfRebuildSearchIndexIsComplete
148
149
*/
149
150
@ Test
150
151
public void getStatus_shouldReturnErrorForStatusIfRebuildSearchIndexIsCompletedUnsuccessfully () throws Exception {
151
- Mockito . when (contextDao .updateSearchIndexAsync ()).thenAnswer ((Answer <Future >) invocationOnMock -> {
152
+ when (contextDao .updateSearchIndexAsync ()).thenAnswer ((Answer <Future >) invocationOnMock -> {
152
153
Future <String > future = mock (FutureTask .class );
153
154
when (future .isDone ()).thenReturn (true );
154
155
when (future .isCancelled ()).thenReturn (true );
0 commit comments