Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/docs/asciidoc/index-en-US.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ A `POST` request will create a new reminder.

operation::create-reminder[snippets='http-request,curl-request,http-response,request-body']

==== Create a reminder (Internal failure)

A `POST` request to create a reminder may result in an internal failure.

operation::create-reminder-scheduler-error[snippets='http-response']

==== Create a reminder (past date)

operation::create-reminder-past-date[snippets='http-response']
Expand Down
6 changes: 6 additions & 0 deletions src/docs/asciidoc/index-pt-BR.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ Uma requisição `POST` criará um novo lembrete.

operation::create-reminder[snippets='http-request,curl-request,http-response,request-body']

==== Criar um lembrete (Falha interna)

Uma requisição `POST` para criar um lembrete pode resultar em falha interna.

operation::create-reminder-scheduler-error[snippets='http-response']

==== Criar um lembrete (data no passado)

operation::create-reminder-past-date[snippets='http-response']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import br.com.springnoobs.reminderapi.reminder.dto.response.ReminderResponseDTO;
import br.com.springnoobs.reminderapi.reminder.exception.NotFoundException;
import br.com.springnoobs.reminderapi.reminder.exception.PastDueDateException;
import br.com.springnoobs.reminderapi.reminder.exception.ReminderSchedulerException;
import br.com.springnoobs.reminderapi.reminder.service.ReminderService;
import br.com.springnoobs.reminderapi.user.dto.request.ContactRequestDTO;
import br.com.springnoobs.reminderapi.user.dto.request.CreateUserRequestDTO;
Expand Down Expand Up @@ -128,6 +129,24 @@ void shouldReturnBadRequestWhenCreatingReminderWithPastDate() throws Exception {
.andDo(document("create-reminder-past-date"));
}

@Test
void shouldReturnInternalServerErrorWhenSchedulerFailsOnCreate() throws Exception {
CreateUserRequestDTO createUserRequestDTO = new CreateUserRequestDTO(
"First Name", "Last Name", new ContactRequestDTO("[email protected]", "123456789"));

var request = new CreateReminderRequestDTO("New Reminder", Instant.now().plusSeconds(60), createUserRequestDTO);

when(service.create(request)).thenThrow(new ReminderSchedulerException("Scheduler error on create"));

mockMvc.perform(post("/reminders")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(request)))
.andExpect(status().isInternalServerError())
.andExpect(jsonPath("$.title").value("Internal Server Error"))
.andExpect(jsonPath("$.detail").value("Scheduler error on create"))
.andDo(document("create-reminder-scheduler-error"));
}

@Test
void shouldUpdateReminderWhenRequestIsValid() throws Exception {
long reminderId = 1L;
Expand Down