|
13 | 13 | import br.com.springnoobs.reminderapi.reminder.dto.response.ReminderResponseDTO; |
14 | 14 | import br.com.springnoobs.reminderapi.reminder.exception.NotFoundException; |
15 | 15 | import br.com.springnoobs.reminderapi.reminder.exception.PastDueDateException; |
| 16 | +import br.com.springnoobs.reminderapi.reminder.exception.ReminderSchedulerException; |
16 | 17 | import br.com.springnoobs.reminderapi.reminder.service.ReminderService; |
17 | 18 | import br.com.springnoobs.reminderapi.user.dto.request.ContactRequestDTO; |
18 | 19 | import br.com.springnoobs.reminderapi.user.dto.request.CreateUserRequestDTO; |
@@ -128,6 +129,24 @@ void shouldReturnBadRequestWhenCreatingReminderWithPastDate() throws Exception { |
128 | 129 | .andDo(document("create-reminder-past-date")); |
129 | 130 | } |
130 | 131 |
|
| 132 | + @Test |
| 133 | + void shouldReturnInternalServerErrorWhenSchedulerFailsOnCreate() throws Exception { |
| 134 | + CreateUserRequestDTO createUserRequestDTO = new CreateUserRequestDTO( |
| 135 | + "First Name", "Last Name", new ContactRequestDTO("email@test.com", "123456789")); |
| 136 | + |
| 137 | + var request = new CreateReminderRequestDTO("New Reminder", Instant.now().plusSeconds(60), createUserRequestDTO); |
| 138 | + |
| 139 | + when(service.create(request)).thenThrow(new ReminderSchedulerException("Scheduler error on create")); |
| 140 | + |
| 141 | + mockMvc.perform(post("/reminders") |
| 142 | + .contentType(MediaType.APPLICATION_JSON) |
| 143 | + .content(objectMapper.writeValueAsString(request))) |
| 144 | + .andExpect(status().isInternalServerError()) |
| 145 | + .andExpect(jsonPath("$.title").value("Internal Server Error")) |
| 146 | + .andExpect(jsonPath("$.detail").value("Scheduler error on create")) |
| 147 | + .andDo(document("create-reminder-scheduler-error")); |
| 148 | + } |
| 149 | + |
131 | 150 | @Test |
132 | 151 | void shouldUpdateReminderWhenRequestIsValid() throws Exception { |
133 | 152 | long reminderId = 1L; |
|
0 commit comments