Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated conducted by #497

Merged
merged 2 commits into from
Dec 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ data class CompletedReview(
val createdBy: String,
val createdAt: Instant,
val createdAtPrison: String,
val updatedBy: String,
val updatedAt: Instant,
val updatedAtPrison: String,
val conductedBy: ReviewConductedBy?,
val reviewScheduleReference: UUID?,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ fun aValidCompletedReview(
createdBy: String = "asmith_gen",
createdAt: Instant = Instant.now(),
createdAtPrison: String = "BXI",
updatedBy: String = "bjones_gen",
updatedAt: Instant = Instant.now(),
updatedAtPrison: String = "BXI",
conductedBy: ReviewConductedBy? = ReviewConductedBy(name = "Barnie Jones", role = "Peer mentor"),
reviewScheduleReference: UUID? = null,
): CompletedReview =
Expand All @@ -30,4 +33,7 @@ fun aValidCompletedReview(
createdAtPrison = createdAtPrison,
conductedBy = conductedBy,
reviewScheduleReference = reviewScheduleReference,
updatedBy = updatedBy,
updatedAt = updatedAt,
updatedAtPrison = updatedAtPrison,
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ReviewEntityMapper {
createdAtPrison = createdAtPrison,
conductedBy = toReviewConductedBy(this),
reviewScheduleReference = reviewScheduleReference,
updatedBy = updatedBy!!,
updatedAt = updatedAt!!,
updatedAtPrison = updatedAtPrison,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class CompletedActionPlanReviewResponseMapper(
createdByDisplayName = userService.getUserDetails(createdBy).name,
createdAt = instantMapper.toOffsetDateTime(createdAt)!!,
createdAtPrison = createdAtPrison,
updatedBy = updatedBy,
updatedByDisplayName = userService.getUserDetails(updatedBy).name,
updatedAt = instantMapper.toOffsetDateTime(updatedAt)!!,
updatedAtPrison = updatedAtPrison,
reviewScheduleReference = reviewScheduleReference,
)
}
Expand Down
19 changes: 18 additions & 1 deletion src/main/resources/static/openapi/EducationAndWorkPlanAPI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,24 @@ components:
example: '2023-06-19T09:39:44Z'
createdAtPrison:
type: string
description: The identifier of the prison that the prisoner was resident at when the Review was ented in the system.
description: The identifier of the prison that the prisoner was resident at when the Review was entered in the system.
example: 'BXI'
updatedBy:
type: string
description: The DPS username of the person who updated the Review in the system.
example: 'asmith_gen'
updatedByDisplayName:
type: string
description: The display name of the person who updated the Review in the system.
example: 'Alex Smith'
updatedAt:
type: string
format: date-time
description: An ISO-8601 timestamp representing when the Review was updated in the system.
example: '2023-06-19T09:39:44Z'
updatedAtPrison:
type: string
description: The identifier of the prison that the prisoner was resident at when the Review was updated in the system.
example: 'BXI'
conductedBy:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class ReviewEntityMapperTest {
// Given
val reference = UUID.randomUUID()
val createdAt = Instant.now()
val updatedAt = Instant.now()

val reviewEntity = aValidReviewEntity(
reference = reference,
conductedBy = "Barnie Jones",
conductedByRole = "Peer mentor",
createdAt = createdAt,
updatedAt = updatedAt,
)
val reviewScheduleReference = reviewEntity.reviewScheduleReference

Expand All @@ -41,6 +43,7 @@ class ReviewEntityMapperTest {
note = expectedNote,
conductedBy = ReviewConductedBy(name = "Barnie Jones", role = "Peer mentor"),
createdAt = createdAt,
updatedAt = updatedAt,
reviewScheduleReference = reviewScheduleReference,
)

Expand All @@ -56,12 +59,14 @@ class ReviewEntityMapperTest {
// Given
val reference = UUID.randomUUID()
val createdAt = Instant.now()
val updatedAt = Instant.now()

val reviewEntity = aValidReviewEntity(
reference = reference,
conductedBy = null,
conductedByRole = null,
createdAt = createdAt,
updatedAt = updatedAt,
)

val reviewScheduleReference = reviewEntity.reviewScheduleReference
Expand All @@ -76,6 +81,7 @@ class ReviewEntityMapperTest {
note = expectedNote,
conductedBy = null,
createdAt = createdAt,
updatedAt = updatedAt,
reviewScheduleReference = reviewScheduleReference,
)

Expand All @@ -98,6 +104,9 @@ class ReviewEntityMapperTest {
createdBy = reviewCreatedBy,
createdAt = reviewCreatedAt,
createdAtPrison = reviewCreatedAtPrison,
updatedBy = reviewCreatedBy,
updatedAt = reviewCreatedAt,
updatedAtPrison = reviewCreatedAtPrison,
)

val reviewScheduleReference = reviewEntity.reviewScheduleReference
Expand Down Expand Up @@ -126,6 +135,9 @@ class ReviewEntityMapperTest {
createdBy = reviewCreatedBy,
createdAt = reviewCreatedAt,
createdAtPrison = reviewCreatedAtPrison,
updatedBy = reviewCreatedBy,
updatedAt = reviewCreatedAt,
updatedAtPrison = reviewCreatedAtPrison,
reviewScheduleReference = reviewScheduleReference,
note = aValidNoteDto(
reference = noteReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import uk.gov.justice.digital.hmpps.educationandworkplanapi.app.resource.mapper.
import uk.gov.justice.digital.hmpps.educationandworkplanapi.app.service.ManageUserService
import uk.gov.justice.digital.hmpps.educationandworkplanapi.resource.model.note.aValidNoteResponse
import uk.gov.justice.digital.hmpps.educationandworkplanapi.resource.model.review.aValidCompletedActionPlanReviewResponse
import java.time.Instant
import java.time.ZoneOffset

@ExtendWith(MockitoExtension::class)
Expand All @@ -40,11 +41,15 @@ class CompletedActionPlanReviewResponseMapperTest {
// Given
val reference = aValidReference()
val note = aValidNoteDto()
val createdAt = Instant.now()
val updatedAt = Instant.now()
val completedReview = aValidCompletedReview(
reference = reference,
note = note,
createdBy = "asmith_gen",
conductedBy = ReviewConductedBy("Barnie Jones", "Peer mentor"),
createdAt = createdAt,
updatedAt = updatedAt,
)

given(userService.getUserDetails(any())).willReturn(
Expand All @@ -59,7 +64,8 @@ class CompletedActionPlanReviewResponseMapperTest {
val expected = aValidCompletedActionPlanReviewResponse(
reference = reference,
note = expectedNote,
createdAt = completedReview.createdAt.atOffset(ZoneOffset.UTC),
createdAt = instantMapper.toOffsetDateTime(createdAt)!!,
updatedAt = instantMapper.toOffsetDateTime(updatedAt)!!,
conductedBy = "Barnie Jones",
conductedByRole = "Peer mentor",
)
Expand All @@ -71,6 +77,5 @@ class CompletedActionPlanReviewResponseMapperTest {
assertThat(actual).isEqualTo(expected)
verify(noteResourceMapper).fromDomainToModel(note)
verify(userService).getUserDetails("asmith_gen")
verify(instantMapper).toOffsetDateTime(completedReview.createdAt)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ class InductionScheduleResponseAssert(actual: InductionScheduleResponse?) :
isNotNull
with(actual!!) {
val createdAtRounded = createdAt.truncatedTo(ChronoUnit.MILLIS)
if (createdAtRounded.isBefore(dateTime)) {
failWithMessage("Expected createdAt to be after $dateTime, but was $createdAt")
val dateTimeRounded = dateTime.truncatedTo(ChronoUnit.MILLIS)
if (createdAtRounded.isBefore(dateTimeRounded)) {
failWithMessage("Expected createdAt to be after $dateTimeRounded, but was $createdAtRounded")
}
}
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ fun aValidCompletedActionPlanReviewResponse(
createdByDisplayName: String = "Alex Smith",
createdAt: OffsetDateTime = OffsetDateTime.now(),
createdAtPrison: String = "BXI",
updatedBy: String = "bjones_gen",
updatedByDisplayName: String = "Alex Smith",
updatedAt: OffsetDateTime = OffsetDateTime.now(),
updatedAtPrison: String = "BXI",
conductedBy: String? = "Barnie Jones",
conductedByRole: String? = "Peer mentor",
): CompletedActionPlanReviewResponse =
Expand All @@ -30,4 +34,8 @@ fun aValidCompletedActionPlanReviewResponse(
createdByDisplayName = createdByDisplayName,
createdAt = createdAt,
createdAtPrison = createdAtPrison,
updatedBy = updatedBy,
updatedAt = updatedAt,
updatedAtPrison = updatedAtPrison,
updatedByDisplayName = updatedByDisplayName,
)