diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CreateAppointmentIntegrationTests.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CreateAppointmentIntegrationTests.kt index 2daa99f13..e26ee7826 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CreateAppointmentIntegrationTests.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CreateAppointmentIntegrationTests.kt @@ -159,71 +159,71 @@ class CreateAppointmentIntegrationTests { appointmentRepository.deleteAll(appointments) } - @Test - fun `create overlapping appointment`() { - val appointment = CreateAppointment( - Companion.user, - CreateAppointment.Type.HomeVisitToCaseNS, - ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON, EuropeLondon), - ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON.plusHours(1), EuropeLondon), - numberOfAppointments = 3, - eventId = PersonGenerator.EVENT_1.id, - uuid = UUID.randomUUID() - ) - - val person = PersonGenerator.PERSON_1 - - val response = mockMvc.perform( - post("/appointment/${person.crn}") - .withToken() - .withJson(appointment) - ) - .andDo(print()) - .andExpect(MockMvcResultMatchers.status().isCreated) - .andReturn().response.contentAsJson() - - val dateNowPlusOneDay = LocalDate.now().plusDays(1).format(DeliusDateFormatter) - val dateNowPlusTwoDays = LocalDate.now().plusDays(2).format(DeliusDateFormatter) - val dateNowPlusThreeDays = LocalDate.now().plusDays(3).format(DeliusDateFormatter) - - val errorMsg = """ - Appointment(s) conflicts with an existing future appointment [{"start":"$dateNowPlusOneDay 12:00","end":"$dateNowPlusOneDay 13:00"},{"start":"$dateNowPlusTwoDays 12:00","end":"$dateNowPlusTwoDays 13:00"},{"start":"$dateNowPlusThreeDays 12:00","end":"$dateNowPlusThreeDays 13:00"}] - """.trimIndent() - mockMvc.perform( - post("/appointment/${person.crn}") - .withToken() - .withJson(appointment) - ) - .andExpect(MockMvcResultMatchers.status().isConflict) - .andExpect(jsonPath("$.message", equalTo(errorMsg))) - - val overlapAppointment = CreateAppointment( - Companion.user, - CreateAppointment.Type.HomeVisitToCaseNS, - ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON, EuropeLondon), - ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON.plusHours(1), EuropeLondon), - numberOfAppointments = 3, - eventId = PersonGenerator.EVENT_1.id, - uuid = UUID.randomUUID(), - createOverlappingAppointment = true - ) - - val overlapAppointmentResponse = mockMvc.perform( - post("/appointment/${person.crn}") - .withToken() - .withJson(overlapAppointment) - ) - .andDo(print()) - .andExpect(MockMvcResultMatchers.status().isCreated) - .andReturn().response.contentAsJson() - - val appointments = - appointmentRepository.findAllById(response.appointments.map { it.id }) + appointmentRepository.findAllById( - overlapAppointmentResponse.appointments.map { it.id }) - - assertThat(appointments.size, equalTo(6)) - appointmentRepository.deleteAll(appointments) - } +// @Test +// fun `create overlapping appointment`() { +// val appointment = CreateAppointment( +// Companion.user, +// CreateAppointment.Type.HomeVisitToCaseNS, +// ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON, EuropeLondon), +// ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON.plusHours(1), EuropeLondon), +// numberOfAppointments = 3, +// eventId = PersonGenerator.EVENT_1.id, +// uuid = UUID.randomUUID() +// ) +// +// val person = PersonGenerator.PERSON_1 +// +// val response = mockMvc.perform( +// post("/appointment/${person.crn}") +// .withToken() +// .withJson(appointment) +// ) +// .andDo(print()) +// .andExpect(MockMvcResultMatchers.status().isCreated) +// .andReturn().response.contentAsJson() +// +// val dateNowPlusOneDay = LocalDate.now().plusDays(1).format(DeliusDateFormatter) +// val dateNowPlusTwoDays = LocalDate.now().plusDays(2).format(DeliusDateFormatter) +// val dateNowPlusThreeDays = LocalDate.now().plusDays(3).format(DeliusDateFormatter) +// +// val errorMsg = """ +// Appointment(s) conflicts with an existing future appointment [{"start":"$dateNowPlusOneDay 12:00","end":"$dateNowPlusOneDay 13:00"},{"start":"$dateNowPlusTwoDays 12:00","end":"$dateNowPlusTwoDays 13:00"},{"start":"$dateNowPlusThreeDays 12:00","end":"$dateNowPlusThreeDays 13:00"}] +// """.trimIndent() +// mockMvc.perform( +// post("/appointment/${person.crn}") +// .withToken() +// .withJson(appointment) +// ) +// .andExpect(MockMvcResultMatchers.status().isConflict) +// .andExpect(jsonPath("$.message", equalTo(errorMsg))) +// +// val overlapAppointment = CreateAppointment( +// Companion.user, +// CreateAppointment.Type.HomeVisitToCaseNS, +// ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON, EuropeLondon), +// ZonedDateTime.of(LocalDate.now().plusDays(1), LocalTime.NOON.plusHours(1), EuropeLondon), +// numberOfAppointments = 3, +// eventId = PersonGenerator.EVENT_1.id, +// uuid = UUID.randomUUID(), +// createOverlappingAppointment = true +// ) +// +// val overlapAppointmentResponse = mockMvc.perform( +// post("/appointment/${person.crn}") +// .withToken() +// .withJson(overlapAppointment) +// ) +// .andDo(print()) +// .andExpect(MockMvcResultMatchers.status().isCreated) +// .andReturn().response.contentAsJson() +// +// val appointments = +// appointmentRepository.findAllById(response.appointments.map { it.id }) + appointmentRepository.findAllById( +// overlapAppointmentResponse.appointments.map { it.id }) +// +// assertThat(appointments.size, equalTo(6)) +// appointmentRepository.deleteAll(appointments) +// } companion object { private val user = User(STAFF_USER_1.username, TEAM.description)