1717import org .openmrs .module .webservices .rest .web .RestConstants ;
1818import org .springframework .beans .factory .annotation .Autowired ;
1919import org .springframework .http .MediaType ;
20- import org .springframework .http .ResponseEntity ;
2120import org .springframework .test .context .ContextConfiguration ;
2221import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
2322import org .springframework .test .context .web .WebAppConfiguration ;
2726import org .springframework .test .web .servlet .setup .MockMvcBuilders ;
2827import org .springframework .web .context .WebApplicationContext ;
2928
29+ import javax .servlet .http .Cookie ;
3030import java .util .ArrayList ;
3131import java .util .Collections ;
3232import java .util .HashSet ;
@@ -68,7 +68,7 @@ public void shouldReturn200OKWhenMatchingPatientFound() throws Exception {
6868 ExistingPatient existingPatient = new ExistingPatient ("sam tom" , "35" , "null, null" , "M" , "3f81c3b4-04fc-4311-9b50-b863fbe023dc" , "9123456780" );
6969 when (existingPatientService .getMatchingPatients ("+91-9876543210" ))
7070 .thenReturn (new ArrayList <>());
71- when (existingPatientService .getMatchingPatients (anyString (), anyInt (), anyString ()))
71+ when (existingPatientService .getMatchingPatients (anyString (),anyString (), anyInt (), anyString ()))
7272 .thenReturn (patients );
7373 when (existingPatientService .getMatchingPatientDetails (new HashSet <>(patients )))
7474 .thenReturn (Collections .singletonList (existingPatient ));
@@ -78,6 +78,7 @@ public void shouldReturn200OKWhenMatchingPatientFound() throws Exception {
7878 .param ("patientYearOfBirth" , "1985" )
7979 .param ("patientGender" , "M" )
8080 .param ("phoneNumber" , "+91-9876543210" )
81+ .cookie (new Cookie ("bahmni.user.location" , "{\" name\" :\" General Ward\" ,\" uuid\" :\" baf7bd38-d225-11e4-9c67-080027b662ec\" }" ))
8182 .accept (MediaType .APPLICATION_JSON ))
8283 .andExpect (status ().isOk ());
8384 }
@@ -87,14 +88,15 @@ public void shouldReturnNoRecordsWhenNoMatchingPatientFound() throws Exception {
8788 List <Patient > patients = new ArrayList <>();
8889 when (existingPatientService .getMatchingPatients ("+91-9876543210" ))
8990 .thenReturn (new ArrayList <>());
90- when (existingPatientService .getMatchingPatients (anyString (), anyInt (), anyString ()))
91+ when (existingPatientService .getMatchingPatients (anyString (),anyString (), anyInt (), anyString ()))
9192 .thenReturn (patients );
9293
9394 MvcResult mvcResult = mockMvc .perform (get (String .format ("/rest/%s/hip/existingPatients" , RestConstants .VERSION_1 ))
9495 .param ("patientName" , "sam tom" )
9596 .param ("patientYearOfBirth" , "1985" )
9697 .param ("patientGender" , "M" )
9798 .param ("phoneNumber" , "+91-9876543210" )
99+ .cookie (new Cookie ("bahmni.user.location" , "{\" name\" :\" General Ward\" ,\" uuid\" :\" baf7bd38-d225-11e4-9c67-080027b662ec\" }" ))
98100 .accept (MediaType .APPLICATION_JSON ))
99101 .andReturn ();
100102
0 commit comments