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.
Browse files
Browse the repository at this point in the history
* PI-1915: Added probation-case/crn endpoint
- Loading branch information
Showing
13 changed files
with
827 additions
and
171 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
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 |
---|---|---|
@@ -1,17 +1,88 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person | ||
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.PersonManager | ||
import uk.gov.justice.digital.hmpps.api.model.DocumentType | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DISABILITY_CONDITION_1 | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DISABILITY_TYPE_1 | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.ETHNICITY | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.GENDER_IDENTITY | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.GENDER_MALE | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.IMMIGRATION_STATUS | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.LANGUAGE_ENG | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.NATIONALITY | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.PROVISION_CATEGORY_1 | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.PROVISION_TYPE_1 | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.RELIGION | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.SECOND_NATIONALITY | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.SEXUAL_ORIENTATION | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.TITLE | ||
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.* | ||
import java.time.LocalDate | ||
import java.time.ZonedDateTime | ||
|
||
object PersonGenerator { | ||
val PARTITION_AREA = PartitionArea(IdGenerator.getAndIncrement(), "Partition Area") | ||
val NEW_TO_PROBATION = generate("N123456") | ||
val CURRENTLY_MANAGED = generate("C123456") | ||
val CURRENTLY_MANAGED = generate("C123456", currentDisposal = true) | ||
val PREVIOUSLY_MANAGED = generate("P123456") | ||
val NO_SENTENCE = generate("U123456") | ||
val PROVISION_1 = generateProvision(CURRENTLY_MANAGED.id, null) | ||
val DISABILITY_1 = generateDisability(CURRENTLY_MANAGED.id, null) | ||
|
||
fun generate(crn: String, softDeleted: Boolean = false, id: Long = IdGenerator.getAndIncrement()) = | ||
Person(crn, softDeleted, id) | ||
val PREVIOUS_CONVICTION_DOC = DocumentEntityGenerator.generateDocument( | ||
personId = CURRENTLY_MANAGED.id, | ||
primaryKeyId = null, | ||
DocumentType.PREVIOUS_CONVICTION.name, | ||
null | ||
) | ||
|
||
fun generate( | ||
crn: String, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement(), | ||
currentDisposal: Boolean = false | ||
) = | ||
Person( | ||
id = id, | ||
crn = crn, | ||
softDeleted = softDeleted, | ||
emailAddress = "[email protected]", | ||
currentDisposal = currentDisposal, | ||
currentExclusion = false, | ||
currentRestriction = false, | ||
currentHighestRiskColour = "RED", | ||
dateOfBirth = LocalDate.of(1977, 8, 12), | ||
partitionArea = PARTITION_AREA, | ||
allowSms = true, | ||
mobileNumber = "07876545678", | ||
telephoneNumber = "0161786567", | ||
forename = "TestForename", | ||
secondName = "MiddleName", | ||
thirdName = "OtherMiddleName", | ||
gender = GENDER_MALE, | ||
surname = "TestSurname", | ||
preferredName = "Other name", | ||
offenderDetails = "Some details", | ||
genderIdentity = GENDER_IDENTITY, | ||
genderIdentityDescription = "Some self described gender identity", | ||
ethnicity = ETHNICITY, | ||
immigrationStatus = IMMIGRATION_STATUS, | ||
nationality = NATIONALITY, | ||
language = LANGUAGE_ENG, | ||
languageConcerns = "A concern", | ||
requiresInterpreter = false, | ||
currentRemandStatus = "Remand Status", | ||
secondNationality = SECOND_NATIONALITY, | ||
sexualOrientation = SEXUAL_ORIENTATION, | ||
religion = RELIGION, | ||
niNumber = "JK002213K", | ||
pnc = "1234567890123", | ||
nomsNumber = "NOMS123", | ||
croNumber = "CRO123", | ||
immigrationNumber = "IMA123", | ||
mostRecentPrisonerNumber = "PRS123", | ||
previousSurname = "Previous", | ||
title = TITLE | ||
) | ||
|
||
fun generatePersonManager(person: Person) = | ||
PersonManager( | ||
|
@@ -22,4 +93,26 @@ object PersonGenerator { | |
ProviderGenerator.DEFAULT, | ||
ZonedDateTime.now() | ||
) | ||
|
||
fun generateProvision(personId: Long, end: LocalDate?) = Provision( | ||
id = IdGenerator.getAndIncrement(), | ||
personId = personId, | ||
type = PROVISION_TYPE_1, | ||
startDate = LocalDate.now().minusDays(1), | ||
lastUpdated = LocalDate.now().minusDays(1), | ||
category = PROVISION_CATEGORY_1, | ||
notes = null, | ||
finishDate = end, | ||
) | ||
|
||
fun generateDisability(personId: Long, end: LocalDate?) = Disability( | ||
id = IdGenerator.getAndIncrement(), | ||
personId = personId, | ||
type = DISABILITY_TYPE_1, | ||
startDate = LocalDate.now().minusDays(1), | ||
lastUpdated = ZonedDateTime.now().minusDays(1), | ||
condition = DISABILITY_CONDITION_1, | ||
notes = null, | ||
finishDate = end, | ||
) | ||
} |
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
Oops, something went wrong.