Skip to content

Commit

Permalink
MAN-109 - update integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj committed Nov 1, 2024
1 parent 3288cd0 commit 1487088
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,14 @@ class CreateAppointmentIntegrationTests {
appointmentRepository.delete(appointment)
}

@Test
fun `create multiple appointments`() {
@ParameterizedTest
@MethodSource("createMultipleAppointments")
fun `create multiple appointments`(createAppointment: CreateAppointment) {
val person = PersonGenerator.PERSON_1

val uuid = UUID.randomUUID()
val response = mockMvc.perform(
post("/appointments/${person.crn}")
.withToken()
.withJson(
CreateAppointment(
CreateAppointment.Type.HomeVisitToCaseNS,
ZonedDateTime.now(),
numberOfAppointments = 3,
eventId = PersonGenerator.EVENT_1.id,
uuid = uuid
)
))
.withJson(createAppointment))
.andDo(print())
.andExpect(MockMvcResultMatchers.status().isCreated)
.andReturn().response.contentAsJson<AppointmentDetail>()
Expand All @@ -135,7 +126,7 @@ class CreateAppointmentIntegrationTests {
assertThat(appointments[2].date, equalTo(LocalDate.now().plusDays(2)))

//check for unique external reference
val externalRef = "urn:uk:gov:hmpps:manage-supervision-service:appointment:$uuid"
val externalRef = "urn:uk:gov:hmpps:manage-supervision-service:appointment:${createAppointment.uuid}"
assertThat(appointments[0].externalReference, equalTo(externalRef))
assertNotEquals(externalRef, appointments[1].externalReference)
assertNotEquals(externalRef, appointments[2].externalReference)
Expand Down Expand Up @@ -163,5 +154,23 @@ class CreateAppointmentIntegrationTests {
uuid = UUID.randomUUID()
)
)

@JvmStatic
fun createMultipleAppointments() = listOf(
CreateAppointment(
CreateAppointment.Type.HomeVisitToCaseNS,
ZonedDateTime.now(),
numberOfAppointments = 3,
eventId = PersonGenerator.EVENT_1.id,
uuid = UUID.randomUUID()
),
CreateAppointment(
CreateAppointment.Type.HomeVisitToCaseNS,
ZonedDateTime.now(),
until = ZonedDateTime.now().plusDays(3),
eventId = PersonGenerator.EVENT_1.id,
uuid = UUID.randomUUID()
)
)
}
}

0 comments on commit 1487088

Please sign in to comment.