diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AppointmentOutcomeIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AppointmentOutcomeIntegrationTest.kt index df3c6e4494..aba4f46e0a 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AppointmentOutcomeIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AppointmentOutcomeIntegrationTest.kt @@ -1,8 +1,8 @@ package uk.gov.justice.digital.hmpps +import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc @@ -21,6 +21,7 @@ import uk.gov.justice.digital.hmpps.data.generator.OffenderManagerGenerator.STAF import uk.gov.justice.digital.hmpps.data.generator.OffenderManagerGenerator.TEAM import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.AppointmentRepository +import uk.gov.justice.digital.hmpps.test.CustomMatchers.isCloseTo import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @@ -77,7 +78,14 @@ class AppointmentOutcomeIntegrationTest { @Test fun `outcome updated`() { val response = createAppointment() - val request = Outcome(response.appointments[0].id, "ATTC", false, "my notes") + val createdAppointment = appointmentRepository.findById(response.appointments[0].id).get() + + assertNull(createdAppointment.attended) + assertNull(createdAppointment.notes) + assertNull(createdAppointment.outcomeId) + assertNull(createdAppointment.sensitive) + + val request = Outcome(response.appointments[0].id, "ATTC", notes = "my notes") mockMvc .perform(MockMvcRequestBuilders.patch("/appointment") @@ -86,14 +94,24 @@ class AppointmentOutcomeIntegrationTest { ) .andExpect(MockMvcResultMatchers.status().isOk) - val appointment = appointmentRepository.findById(response.appointments[0].id).get() - assertEquals("Y", appointment.attended) - assertEquals(request.notes, appointment.notes) - assertEquals(ATTENDED_COMPLIED.id, appointment.outcomeId) - assertFalse(appointment.sensitive!!) + val updatedAppointment = appointmentRepository.findById(response.appointments[0].id).get() + assertEquals("Y", updatedAppointment.attended) + assertEquals(request.notes, updatedAppointment.notes) + assertEquals(ATTENDED_COMPLIED.id, updatedAppointment.outcomeId) + assertFalse(updatedAppointment.sensitive!!) + + assertThat(updatedAppointment.type.code, equalTo(createdAppointment.type.code)) + assertThat(updatedAppointment.date, equalTo(createdAppointment.date)) + assertThat(updatedAppointment.startTime, isCloseTo(createdAppointment.startTime)) + assertThat(updatedAppointment.externalReference, equalTo(createdAppointment.externalReference)) + assertThat(updatedAppointment.eventId, equalTo(createdAppointment.eventId)) + assertThat(updatedAppointment.createdByUserId, equalTo(createdAppointment.createdByUserId)) + assertThat(updatedAppointment.staffId, equalTo(createdAppointment.staffId)) + assertThat(updatedAppointment.probationAreaId, equalTo(createdAppointment.probationAreaId)) + assertThat(updatedAppointment.officeLocationId, equalTo(createdAppointment.officeLocationId)) - appointmentRepository.delete(appointment) + appointmentRepository.delete(updatedAppointment) } private fun createAppointment() = mockMvc.perform(