1616import static org .hamcrest .Matchers .is ;
1717import static org .hamcrest .Matchers .notNullValue ;
1818import static org .hamcrest .Matchers .nullValue ;
19+ import static org .mockito .Mockito .lenient ;
20+ import static org .mockito .Mockito .mock ;
21+ import static org .mockito .Mockito .mockStatic ;
1922import static org .mockito .Mockito .verify ;
23+ import static org .mockito .Mockito .when ;
2024import static org .openmrs .module .queue .web .resources .parser .QueueEntrySearchCriteriaParser .SEARCH_PARAM_ENDED_ON_OR_AFTER ;
2125import static org .openmrs .module .queue .web .resources .parser .QueueEntrySearchCriteriaParser .SEARCH_PARAM_ENDED_ON_OR_BEFORE ;
2226import static org .openmrs .module .queue .web .resources .parser .QueueEntrySearchCriteriaParser .SEARCH_PARAM_HAS_VISIT ;
3438import static org .openmrs .module .queue .web .resources .parser .QueueEntrySearchCriteriaParser .SEARCH_PARAM_STARTED_ON_OR_BEFORE ;
3539import static org .openmrs .module .queue .web .resources .parser .QueueEntrySearchCriteriaParser .SEARCH_PARAM_STATUS ;
3640import static org .openmrs .module .queue .web .resources .parser .QueueEntrySearchCriteriaParser .SEARCH_PARAM_VISIT ;
37- import static org .powermock .api .mockito .PowerMockito .mock ;
38- import static org .powermock .api .mockito .PowerMockito .mockStatic ;
39- import static org .powermock .api .mockito .PowerMockito .when ;
4041
4142import javax .servlet .http .HttpServletRequest ;
4243
4748import java .util .Map ;
4849import java .util .Optional ;
4950
50- import org .junit .Before ;
51- import org .junit .Test ;
52- import org .junit .runner . RunWith ;
51+ import org .junit .jupiter . api . BeforeEach ;
52+ import org .junit .jupiter . api . Test ;
53+ import org .junit .jupiter . api . extension . ExtendWith ;
5354import org .mockito .ArgumentCaptor ;
5455import org .mockito .Mock ;
56+ import org .mockito .junit .jupiter .MockitoExtension ;
5557import org .openmrs .Concept ;
5658import org .openmrs .Location ;
5759import org .openmrs .Patient ;
7779import org .openmrs .module .webservices .rest .web .representation .DefaultRepresentation ;
7880import org .openmrs .module .webservices .rest .web .representation .FullRepresentation ;
7981import org .openmrs .module .webservices .rest .web .representation .RefRepresentation ;
80- import org .powermock .core .classloader .annotations .PrepareForTest ;
81- import org .powermock .modules .junit4 .PowerMockRunner ;
8282
83- @ RunWith (PowerMockRunner .class )
84- @ PrepareForTest ({ Context .class , RestUtil .class })
83+ @ ExtendWith (MockitoExtension .class )
8584public class QueueEntryResourceTest extends BaseQueueResourceTest <QueueEntry , QueueEntryResource > {
8685
8786 private static final String QUEUE_ENTRY_UUID = "6hje567a-fca0-11e5-9e59-08002719a7" ;
@@ -122,26 +121,26 @@ public class QueueEntryResourceTest extends BaseQueueResourceTest<QueueEntry, Qu
122121
123122 ArgumentCaptor <QueueEntrySearchCriteria > queueEntryArgumentCaptor ;
124123
125- @ Before
124+ @ BeforeEach
126125 public void prepareMocks () {
127- mockStatic (RestUtil .class );
128- mockStatic (Context .class );
129- when (queueServicesWrapper .getQueueService ()).thenReturn (queueService );
130- when (queueServicesWrapper .getQueueEntryService ()).thenReturn (queueEntryService );
131- when (queueServicesWrapper .getQueueRoomService ()).thenReturn (queueRoomService );
132- when (queueServicesWrapper .getRoomProviderMapService ()).thenReturn (roomProviderMapService );
133- when (queueServicesWrapper .getConceptService ()).thenReturn (conceptService );
134- when (queueServicesWrapper .getLocationService ()).thenReturn (locationService );
135- when (queueServicesWrapper .getPatientService ()).thenReturn (patientService );
126+ setRestUtil ( mockStatic (RestUtil .class ) );
127+ setContext ( mockStatic (Context .class ) );
128+ lenient (). when (queueServicesWrapper .getQueueService ()).thenReturn (queueService );
129+ lenient (). when (queueServicesWrapper .getQueueEntryService ()).thenReturn (queueEntryService );
130+ lenient (). when (queueServicesWrapper .getQueueRoomService ()).thenReturn (queueRoomService );
131+ lenient (). when (queueServicesWrapper .getRoomProviderMapService ()).thenReturn (roomProviderMapService );
132+ lenient (). when (queueServicesWrapper .getConceptService ()).thenReturn (conceptService );
133+ lenient (). when (queueServicesWrapper .getLocationService ()).thenReturn (locationService );
134+ lenient (). when (queueServicesWrapper .getPatientService ()).thenReturn (patientService );
136135
137136 //By pass authentication
138- when (Context . isAuthenticated () ).thenReturn (true );
137+ getContext (). when (Context :: isAuthenticated ).thenReturn (true );
139138
140- when (Context .getRegisteredComponents (QueueServicesWrapper .class ))
139+ getContext (). when (() -> Context .getRegisteredComponents (QueueServicesWrapper .class ))
141140 .thenReturn (Collections .singletonList (queueServicesWrapper ));
142141
143142 QueueEntrySearchCriteriaParser searchCriteriaParser = new QueueEntrySearchCriteriaParser (queueServicesWrapper );
144- when (Context .getRegisteredComponents (QueueEntrySearchCriteriaParser .class ))
143+ getContext (). when (() -> Context .getRegisteredComponents (QueueEntrySearchCriteriaParser .class ))
145144 .thenReturn (Collections .singletonList (searchCriteriaParser ));
146145
147146 resource = new QueueEntryResource ();
@@ -152,9 +151,9 @@ public void prepareMocks() {
152151
153152 requestContext = mock (RequestContext .class );
154153 request = mock (HttpServletRequest .class );
155- when (requestContext .getRequest ()).thenReturn (request );
154+ lenient (). when (requestContext .getRequest ()).thenReturn (request );
156155 parameterMap = new HashMap <>();
157- when (request .getParameterMap ()).thenReturn (parameterMap );
156+ lenient (). when (request .getParameterMap ()).thenReturn (parameterMap );
158157 queueEntryArgumentCaptor = ArgumentCaptor .forClass (QueueEntrySearchCriteria .class );
159158 }
160159
0 commit comments