[R5] Add unit test for find doctor by id as well

This commit is contained in:
Mirna Gama 2024-01-06 18:41:53 -03:00 committed by Mirna Gama
parent 8fc3c28c9a
commit a99213b845
2 changed files with 27 additions and 0 deletions

View File

@ -100,6 +100,20 @@ public class DoctorControllerTest {
.andExpect(MockMvcResultMatchers.status().isBadRequest()).andDo(MockMvcResultHandlers.print());
}
/**
* Get doctor by id
*/
@Test
@DisplayName("Should get doctor by id and return http status OK")
public void testGetDoctor() throws Exception {
Long id = testDoctor.getId();
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1.0/doctors/{id}", id).contentType(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8"))
.andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print());
}
/**
* Get doctors with pagination
*/

View File

@ -96,6 +96,19 @@ public class DoctorServiceTest {
assertThrows(ConstraintViolationException.class, () -> doctorService.addDoctor(doctorDTO));
}
/**
* Finds a doctor by provided id.
*/
@Test
@DisplayName("Should find doctor by id")
public void testFindPatientById() throws Exception {
Doctor doctor = doctorService.findDoctorById(testDoctor.getId());
assertNotNull(doctor);
}
/**
* Finds doctors stored in the database with pagination
*/