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.
* PI-2110 * PI-2110 updated tests * PI-2110 added main address details * Formatting changes * Updated entity graph * PI-2110 * PI-2110 updated tests * PI-2110 added main address details * Formatting changes * Updated entity graph --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
645fc25
commit aeb48b2
Showing
12 changed files
with
486 additions
and
24 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
123 changes: 119 additions & 4 deletions
123
...-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.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 |
---|---|---|
@@ -1,15 +1,130 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integration.delius.person.entity.Person | ||
import uk.gov.justice.digital.hmpps.integration.delius.person.entity.PersonAddress | ||
import uk.gov.justice.digital.hmpps.integration.delius.person.entity.PersonDetail | ||
import uk.gov.justice.digital.hmpps.integration.delius.reference.entity.ReferenceData | ||
import java.time.LocalDate | ||
|
||
object PersonGenerator { | ||
val REGISTERED_PERSON = generate("R123456") | ||
val RELEASED_PERSON = generate("B123456") | ||
val CUSTODY_PERSON = generate("C123456") | ||
val REGISTERED_PERSON = | ||
generate("R123456", firstName = "Reginald", surname = "Regency", dob = LocalDate.now().minusYears(27)) | ||
val RELEASED_PERSON = | ||
generate("B123456", firstName = "Barry", surname = "Brown", dob = LocalDate.now().minusYears(39)) | ||
val CUSTODY_PERSON = | ||
generate("C123456", firstName = "Charles", surname = "Chaplin", dob = LocalDate.now().minusYears(42)) | ||
|
||
val GENDER = ReferenceDataGenerator.generate("GEN", "Gender") | ||
val ETHNICITY = ReferenceDataGenerator.generate("ETH", "Ethnicity") | ||
val LANGUAGE = ReferenceDataGenerator.generate("LAN", "Language") | ||
val RELIGION = ReferenceDataGenerator.generate("REL", "Religion") | ||
|
||
val MAIN_ADDRESS_STATUS = ReferenceDataGenerator.generate(PersonAddress.MAIN_STATUS_CODE, "Main Address") | ||
|
||
val DETAILED_PERSON = | ||
generate( | ||
crn = "D123456", | ||
firstName = "Daniel", | ||
secondName = "David", | ||
surname = "Danube", | ||
dob = LocalDate.now().minusYears(36), | ||
noms = "D1234YZ", | ||
pnc = "2011/0593710D", | ||
cro = "89861/11W", | ||
gender = GENDER, | ||
ethnicity = ETHNICITY, | ||
language = LANGUAGE, | ||
religion = RELIGION, | ||
emailAddress = "[email protected]", | ||
telephoneNumber = "0191 256 7234", | ||
mobileNumber = "07345617263" | ||
) | ||
|
||
val DETAIL_ADDRESS = generateAddress( | ||
DETAILED_PERSON.id, | ||
MAIN_ADDRESS_STATUS, | ||
addressNumber = "23", | ||
streetName = "Mantle Place", | ||
postcode = "H34 7TH" | ||
) | ||
|
||
fun generate( | ||
crn: String, | ||
noms: String? = null, | ||
pnc: String? = null, | ||
cro: String? = null, | ||
firstName: String, | ||
secondName: String? = null, | ||
thirdName: String? = null, | ||
surname: String, | ||
dob: LocalDate, | ||
telephoneNumber: String? = null, | ||
mobileNumber: String? = null, | ||
emailAddress: String? = null, | ||
gender: ReferenceData? = null, | ||
ethnicity: ReferenceData? = null, | ||
language: ReferenceData? = null, | ||
religion: ReferenceData? = null, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = PersonDetail( | ||
crn, | ||
noms, | ||
pnc, | ||
cro, | ||
firstName, | ||
secondName, | ||
thirdName, | ||
surname, | ||
dob, | ||
telephoneNumber, | ||
mobileNumber, | ||
emailAddress, | ||
gender, | ||
ethnicity, | ||
language, | ||
religion, | ||
softDeleted, | ||
id | ||
) | ||
|
||
fun generatePerson( | ||
crn: String, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Person(crn, softDeleted, id) | ||
} | ||
|
||
fun generateAddress( | ||
personId: Long, | ||
status: ReferenceData, | ||
noFixedAbode: Boolean = false, | ||
buildingName: String? = null, | ||
addressNumber: String? = null, | ||
streetName: String? = null, | ||
district: String? = null, | ||
town: String? = null, | ||
county: String? = null, | ||
postcode: String? = null, | ||
startDate: LocalDate = LocalDate.now().minusDays(1), | ||
endDate: LocalDate? = null, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = PersonAddress( | ||
personId, | ||
status, | ||
buildingName, | ||
addressNumber, | ||
streetName, | ||
district, | ||
town, | ||
county, | ||
postcode, | ||
noFixedAbode, | ||
startDate, | ||
endDate, | ||
softDeleted, | ||
id | ||
) | ||
} | ||
|
||
fun PersonDetail.asPerson() = Person(crn, softDeleted, 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
14 changes: 14 additions & 0 deletions
14
...asys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/ProbationCaseResource.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,14 @@ | ||
package uk.gov.justice.digital.hmpps.api | ||
|
||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.* | ||
import uk.gov.justice.digital.hmpps.service.ProbationCaseService | ||
|
||
@RestController | ||
@RequestMapping("probation-cases/{crn}") | ||
class ProbationCaseResource(private val probationCaseService: ProbationCaseService) { | ||
@PreAuthorize("hasRole('PROBATION_API__OASYS__CASE_DETAIL')") | ||
@GetMapping | ||
fun getCaseDetails(@PathVariable("crn") crn: String) = | ||
probationCaseService.findCase(crn) | ||
} |
Oops, something went wrong.