generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seed LAO Test Data for Approved Premises (#3960)
This commit enhances the approved-premises-and-delius seed data to include two new offenders and two new users to supports testing of LAO access in Approved Premises. Two new users and cases are added: * LAOFULLACCESS - has access to the excluded case X400000 * LAORESTRICTED - does not have access to the restricted case X400001
- Loading branch information
1 parent
2f7ff5d
commit 1382861
Showing
5 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...lius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/LimitedAccessGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.data.MutableLimitedAccessPerson | ||
import uk.gov.justice.digital.hmpps.entity.Exclusion | ||
import uk.gov.justice.digital.hmpps.entity.LimitedAccessPerson | ||
import uk.gov.justice.digital.hmpps.entity.LimitedAccessUser | ||
import uk.gov.justice.digital.hmpps.entity.Restriction | ||
import uk.gov.justice.digital.hmpps.integrations.delius.person.ProbationCase | ||
import uk.gov.justice.digital.hmpps.integrations.delius.staff.StaffUser | ||
import java.time.LocalDateTime | ||
|
||
object LimitedAccessGenerator { | ||
val FULL_ACCESS_USER = generateLaoUser(StaffGenerator.LAO_FULL_ACCESS_USER) | ||
val LIMITED_ACCESS_USER = generateLaoUser(StaffGenerator.LAO_RESTRICTED_USER) | ||
val EXCLUDED_CASE = | ||
generateLaoPerson(ProbationCaseGenerator.CASE_LAO_EXCLUSION, exclusionMessage = "This case has an exclusion") | ||
val RESTRICTED_CASE = generateLaoPerson( | ||
ProbationCaseGenerator.CASE_LAO_RESTRICTED, | ||
restrictionMessage = "This case has an restriction" | ||
) | ||
|
||
fun generateLaoUser(staffUser: StaffUser) = LimitedAccessUser(staffUser.username, staffUser.id) | ||
|
||
fun generateLaoPerson( | ||
probationCase: ProbationCase, | ||
exclusionMessage: String? = null, | ||
restrictionMessage: String? = null, | ||
) = MutableLimitedAccessPerson(probationCase.crn, exclusionMessage, restrictionMessage, probationCase.id) | ||
|
||
fun generateExclusion( | ||
person: LimitedAccessPerson, | ||
user: LimitedAccessUser = LIMITED_ACCESS_USER, | ||
endDateTime: LocalDateTime? = null, | ||
id: Long = IdGenerator.getAndIncrement(), | ||
) = Exclusion(person, user, endDateTime, id) | ||
|
||
fun generateRestriction( | ||
person: LimitedAccessPerson, | ||
user: LimitedAccessUser = FULL_ACCESS_USER, | ||
endDateTime: LocalDateTime? = null, | ||
id: Long = IdGenerator.getAndIncrement(), | ||
) = Restriction(person, user, endDateTime, id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters