Skip to content
Snippets Groups Projects

Controller tests

Merged Karolína Krommelová requested to merge controller-tests into main
1 file
+ 5
4
Compare changes
  • Side-by-side
  • Inline
@@ -62,7 +62,7 @@ class EmployeeControllerTest {
}
@Test
void updateEmployee_employeeFound_returnEmployee() throws Exception {
void updateEmployee_employeeFound_returnsEmployee() throws Exception {
UUID id = new UUID(0x1, 0xf);
Employee updatedEmployee = TestApiFactory.getEmployeeEntity();
Mockito.when(employeeFacade.updateEmployee(Mockito.eq(id), Mockito.any(EmployeeRequest.class))).thenReturn(updatedEmployee);
@@ -98,20 +98,21 @@ class EmployeeControllerTest {
void terminateEmployee_employeeFound() throws Exception {
UUID id = UUID.randomUUID();
Employee terminatedEmployee = TestApiFactory.getEmployeeEntity();
terminatedEmployee.setTerminated(LocalDate.now());
LocalDate date = LocalDate.now();
terminatedEmployee.setTerminated(date);
Mockito.when(employeeFacade.terminate(id)).thenReturn(terminatedEmployee);
mockMvc.perform(delete("/employee/{id}", id)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.terminated").exists())
.andExpect(jsonPath("$.terminated").value(LocalDate.now().toString()));
.andExpect(jsonPath("$.terminated").value(date.toString()));
Mockito.verify(employeeFacade, Mockito.times(1)).terminate(id);
}
@Test
void terminateEmployee_employeeNotFound_throwsEmployeeNotFoundException() throws Exception {
void terminateEmployee_employeeNotFound_404() throws Exception {
UUID id = UUID.randomUUID();
Mockito.when(employeeFacade.terminate(id)).thenThrow(new EmployeeNotFoundException());
Loading