|
1 | 1 | package com.itasocialacademy.oitassist.taskassignment.controller; |
2 | 2 |
|
3 | 3 | import com.itasocialacademy.oitassist.ControllerUnitTest; |
| 4 | +import com.itasocialacademy.oitassist.competition.dao.enums.ExecutionStatus; |
4 | 5 | import com.itasocialacademy.oitassist.competition.exceptions.CompetitionHierarchyValidationException; |
5 | 6 | import com.itasocialacademy.oitassist.competition.exceptions.TourNotFoundException; |
6 | 7 | import com.itasocialacademy.oitassist.filemanager.api.dto.FileDetailsDTO; |
| 8 | +import com.itasocialacademy.oitassist.task.exceptions.TaskNotFoundException; |
7 | 9 | import com.itasocialacademy.oitassist.taskassignment.dao.enums.AssignmentVisibility; |
8 | 10 | import com.itasocialacademy.oitassist.taskassignment.dao.model.TaskRequirements; |
9 | 11 | import com.itasocialacademy.oitassist.taskassignment.dto.request.CreateAndAssignTaskRequestDTO; |
10 | 12 | import com.itasocialacademy.oitassist.taskassignment.dto.request.CreateTaskAssignmentRequestDTO; |
11 | 13 | import com.itasocialacademy.oitassist.taskassignment.dto.request.TaskRequirementsRequestDTO; |
12 | 14 | import com.itasocialacademy.oitassist.taskassignment.dto.request.UpdateTaskAssignmentRequestDTO; |
13 | 15 | import com.itasocialacademy.oitassist.taskassignment.dto.response.DetailedTaskAssignmentResponseDTO; |
| 16 | +import com.itasocialacademy.oitassist.taskassignment.dto.response.LinkedToursResponseDTO; |
14 | 17 | import com.itasocialacademy.oitassist.taskassignment.dto.response.TaskAssignmentResponseDTO; |
15 | 18 | import com.itasocialacademy.oitassist.taskassignment.exceptions.TaskAlreadyAssignedException; |
16 | 19 | import com.itasocialacademy.oitassist.taskassignment.exceptions.TaskAssignmentNotFoundException; |
@@ -274,6 +277,50 @@ void getByTour_tourNotFound_shouldReturn404() throws Exception { |
274 | 277 | .andExpect(status().isNotFound()); |
275 | 278 | } |
276 | 279 |
|
| 280 | + // GET /api/v1/tasks/{taskId}/linked-tours — getLinkedTours |
| 281 | + |
| 282 | + @Test |
| 283 | + void getLinkedTours_shouldReturnListAnd200() throws Exception { |
| 284 | + LinkedToursResponseDTO mockTourResponse = LinkedToursResponseDTO.builder() |
| 285 | + .tourId(10L) |
| 286 | + .title("Tour 1") |
| 287 | + .description("Description") |
| 288 | + .location("Location") |
| 289 | + .executionStatus(ExecutionStatus.SCHEDULED) |
| 290 | + .build(); |
| 291 | + |
| 292 | + when(assignmentService.getLinkedToursByTaskId(3L)) |
| 293 | + .thenReturn(List.of(mockTourResponse)); |
| 294 | + |
| 295 | + mockMvc.perform(get("/api/v1/tasks/{taskId}/linked-tours", 3L)) |
| 296 | + .andExpect(status().isOk()) |
| 297 | + .andExpect(jsonPath("$").isArray()) |
| 298 | + .andExpect(jsonPath("$[0].tourId").value(10L)) |
| 299 | + .andExpect(jsonPath("$[0].title").value("Tour 1")) |
| 300 | + .andExpect(jsonPath("$[0].description").value("Description")) |
| 301 | + .andExpect(jsonPath("$[0].location").value("Location")) |
| 302 | + .andExpect(jsonPath("$[0].executionStatus").value("SCHEDULED")); |
| 303 | + } |
| 304 | + |
| 305 | + @Test |
| 306 | + void getLinkedTours_taskNotFound_shouldReturn404() throws Exception { |
| 307 | + when(assignmentService.getLinkedToursByTaskId(99L)) |
| 308 | + .thenThrow(new TaskNotFoundException(99L)); |
| 309 | + |
| 310 | + mockMvc.perform(get("/api/v1/tasks/{taskId}/linked-tours", 99L)) |
| 311 | + .andExpect(status().isNotFound()); |
| 312 | + } |
| 313 | + |
| 314 | + @Test |
| 315 | + void getLinkedTours_tourNotFound_shouldReturn404() throws Exception { |
| 316 | + when(assignmentService.getLinkedToursByTaskId(3L)) |
| 317 | + .thenThrow(new TourNotFoundException(10L)); |
| 318 | + |
| 319 | + mockMvc.perform(get("/api/v1/tasks/{taskId}/linked-tours", 3L)) |
| 320 | + .andExpect(status().isNotFound()); |
| 321 | + } |
| 322 | + |
| 323 | + |
277 | 324 | // PATCH /api/v1/task-assignments/{assignmentId} — update |
278 | 325 |
|
279 | 326 | @Test |
|
0 commit comments