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

APS-1516 Update Test APs, Teams & Key Workers #4457

Merged
merged 2 commits into from
Nov 22, 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 @@ -86,11 +86,11 @@ class DataLoader(
moveOnCategoryRepository.save(ReferenceDataGenerator.MC05)
registerTypeRepository.saveAll(ReferenceDataGenerator.REGISTER_TYPES.values)

addressRepository.saveAll(listOf(AddressGenerator.Q001, AddressGenerator.Q002, AddressGenerator.Q710))
addressRepository.saveAll(AddressGenerator.ALL_ADDRESSES)
boroughRepository.save(ProbationCaseGenerator.BOROUGH)
probationAreaRepository.save(ProbationAreaGenerator.DEFAULT)
probationAreaRepository.save(ProbationAreaGenerator.N58_SW)
approvedPremisesRepository.save(ApprovedPremisesGenerator.DEFAULT)
approvedPremisesRepository.saveAll(ApprovedPremisesGenerator.ALL_APS)
// add a duplicate AP for testing selectable query
approvedPremisesRepository.save(
ApprovedPremisesGenerator.generate(
Expand All @@ -99,45 +99,37 @@ class DataLoader(
selectable = false
)
)
approvedPremisesRepository.save(ApprovedPremisesGenerator.NO_STAFF)
approvedPremisesRepository.save(ApprovedPremisesGenerator.E2E_TEST)
officeLocationRepository.save(OfficeLocationGenerator.DEFAULT)
apGroupLinkRepository.saveAll(ApprovedPremisesGenerator.AP_GROUP_LINKS)

lduRepository.save(TeamGenerator.AP_TEAM_LDU)
teamRepository.save(TeamGenerator.APPROVED_PREMISES_TEAM)
teamRepository.save(TeamGenerator.APPROVED_PREMISES_TEAM_WITH_NO_STAFF)
teamRepository.save(TeamGenerator.NON_APPROVED_PREMISES_TEAM)
teamRepository.save(TeamGenerator.UNALLOCATED)
teamRepository.save(TeamGenerator.E2E_TEST_TEAM)
staffRepository.save(
StaffGenerator.generate(
"Key-worker",
"KEY0001",
teams = listOf(TeamGenerator.APPROVED_PREMISES_TEAM, TeamGenerator.E2E_TEST_TEAM),
approvedPremises = listOf(ApprovedPremisesGenerator.DEFAULT, ApprovedPremisesGenerator.E2E_TEST)
teamRepository.saveAll(TeamGenerator.ALL_TEAMS)

(1..3).forEach {
staffRepository.save(
StaffGenerator.generate(
"Key-worker $it",
"KEY000$it",
teams = TeamGenerator.ALL_AP_TEAMS,
approvedPremises = ApprovedPremisesGenerator.ALL_STAFFED_APS
)
)
)
}

staffRepository.save(
StaffGenerator.generate(
"Not key-worker",
"KEY0002",
teams = listOf(TeamGenerator.APPROVED_PREMISES_TEAM)
)
)
staffRepository.save(
StaffGenerator.generate(
"Not key-worker and not in AP team",
"KEY0003",
teams = listOf(TeamGenerator.NON_APPROVED_PREMISES_TEAM)
"NOTKEY1",
teams = TeamGenerator.ALL_AP_TEAMS,
approvedPremises = emptyList(),
)
)

staffRepository.save(
StaffGenerator.generate(
"Unallocated",
TeamGenerator.APPROVED_PREMISES_TEAM.code + "U",
teams = listOf(TeamGenerator.APPROVED_PREMISES_TEAM)
teams = TeamGenerator.ALL_AP_TEAMS
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,170 @@ object AddressGenerator {
postcode = "MB01 3TD"
)

val Q001 = generateAddress("", "1", "Promise Street", "", "Make Believe", "", "MB01 1PS", "01234567890")
val Q002 = generateAddress("", "2", "Future Street", "", "Make Believe", "", "MB02 2PS", "01234567891")
val Q710 = generateAddress("Test AP 10", "10", "Hope Street", "", "Make Believe", "", "MB03 3PS", "01234567892")
val Q001 = generateAddress(
addressNumber = "1",
streetName = "Promise Street",
postcode = "MB01 1PS",
telephoneNumber = "01234567890"
)
val Q002 = generateAddress(
addressNumber = "2",
streetName = "Future Street",
postcode = "MB02 2PS",
telephoneNumber = "01234567891"
)
val Q005 = generateAddress(
addressNumber = "5",
streetName = "New Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567005"
)
val Q049 = generateAddress(
addressNumber = "49",
streetName = "New Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567049"
)
val Q095 = generateAddress(
addressNumber = "9",
streetName = "New Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567095"
)
val Q701 = generateAddress(
addressNumber = "1",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567701"
)
val Q702 = generateAddress(
addressNumber = "2",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567702"
)
val Q703 = generateAddress(
addressNumber = "3",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567703"
)
val Q704 = generateAddress(
addressNumber = "4",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567704"
)
val Q705 = generateAddress(
addressNumber = "5",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567705"
)
val Q706 = generateAddress(
addressNumber = "6",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567706"
)
val Q707 = generateAddress(
addressNumber = "7",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567707"
)
val Q708 = generateAddress(
addressNumber = "8",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567708"
)
val Q709 = generateAddress(
addressNumber = "9",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567709"
)
val Q710 = generateAddress(
addressNumber = "10",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567710"
)
val Q711 = generateAddress(
addressNumber = "11",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567711"
)
val Q712 = generateAddress(
addressNumber = "12",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567712"
)
val Q713 = generateAddress(
addressNumber = "13",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567713"
)
val Q714 = generateAddress(
addressNumber = "14",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567714"
)
val Q715 = generateAddress(
addressNumber = "15",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567715"
)
val Q716 = generateAddress(
addressNumber = "16",
streetName = "Hope Street",
postcode = "MB03 3PS",
telephoneNumber = "01234567716"
)

fun generateAddress(
buildingName: String? = null,
addressNumber: String? = null,
val ALL_ADDRESSES = listOf(
Q001,
Q002,
Q005,
Q049,
Q095,
Q701,
Q702,
Q703,
Q704,
Q705,
Q706,
Q707,
Q708,
Q709,
Q710,
Q711,
Q712,
Q713,
Q714,
Q715,
Q716
)

private fun generateAddress(
buildingName: String? = "",
addressNumber: String? = "",
streetName: String? = null,
district: String? = null,
town: String? = null,
county: String? = null,
district: String? = "",
town: String? = "Make Believe",
county: String? = "",
postcode: String? = null,
telephoneNumber: String? = null,
id: Long = IdGenerator.getAndIncrement()
) = Address(id, buildingName, addressNumber, streetName, district, town, county, postcode, telephoneNumber)

fun generatePersonAddress(
private fun generatePersonAddress(
personId: Long = PersonGenerator.DEFAULT.id,
type: ReferenceData = ReferenceDataGenerator.OWNER_ADDRESS_TYPE,
status: ReferenceData = ReferenceDataGenerator.MAIN_ADDRESS_STATUS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,38 @@ import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceD
object ApprovedPremisesGenerator {
val DEFAULT = generate(ReferenceDataGenerator.NHC_Q001, AddressGenerator.Q001)
val NO_STAFF = generate(ReferenceDataGenerator.NHC_Q002, AddressGenerator.Q002)
val E2E_TEST = generate(ReferenceDataGenerator.NHC_Q710, AddressGenerator.Q710)
val AP_GROUP_LINKS = listOf(generateGroupLink(DEFAULT), generateGroupLink(NO_STAFF))

val AP_Q005 = generate(ReferenceDataGenerator.NHC_Q005, AddressGenerator.Q005)
val AP_Q049 = generate(ReferenceDataGenerator.NHC_Q049, AddressGenerator.Q049)
val AP_Q095 = generate(ReferenceDataGenerator.NHC_Q095, AddressGenerator.Q095)
val AP_Q701 = generate(ReferenceDataGenerator.NHC_Q701, AddressGenerator.Q701)
val AP_Q702 = generate(ReferenceDataGenerator.NHC_Q702, AddressGenerator.Q702)
val AP_Q703 = generate(ReferenceDataGenerator.NHC_Q703, AddressGenerator.Q703)
val AP_Q704 = generate(ReferenceDataGenerator.NHC_Q704, AddressGenerator.Q704)
val AP_Q705 = generate(ReferenceDataGenerator.NHC_Q705, AddressGenerator.Q705)
val AP_Q706 = generate(ReferenceDataGenerator.NHC_Q706, AddressGenerator.Q706)
val AP_Q707 = generate(ReferenceDataGenerator.NHC_Q707, AddressGenerator.Q707)
val AP_Q708 = generate(ReferenceDataGenerator.NHC_Q708, AddressGenerator.Q708)
val AP_Q709 = generate(ReferenceDataGenerator.NHC_Q709, AddressGenerator.Q709)
val AP_Q710 = generate(ReferenceDataGenerator.NHC_Q710, AddressGenerator.Q710)
val AP_Q711 = generate(ReferenceDataGenerator.NHC_Q711, AddressGenerator.Q711)
val AP_Q712 = generate(ReferenceDataGenerator.NHC_Q712, AddressGenerator.Q712)
val AP_Q713 = generate(ReferenceDataGenerator.NHC_Q713, AddressGenerator.Q713)
val AP_Q714 = generate(ReferenceDataGenerator.NHC_Q714, AddressGenerator.Q714)
val AP_Q715 = generate(ReferenceDataGenerator.NHC_Q715, AddressGenerator.Q715)
val AP_Q716 = generate(ReferenceDataGenerator.NHC_Q716, AddressGenerator.Q716)

val ALL_STAFFED_APS = listOf(
DEFAULT, AP_Q005, AP_Q049, AP_Q095,
AP_Q701, AP_Q702, AP_Q703, AP_Q704, AP_Q705, AP_Q706, AP_Q707, AP_Q708, AP_Q709, AP_Q710,
AP_Q711, AP_Q712, AP_Q713, AP_Q714, AP_Q715, AP_Q716
)

val ALL_APS = listOf(
NO_STAFF
) + ALL_STAFFED_APS

fun generate(
code: ReferenceData,
address: Address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,30 @@ object ReferenceDataGenerator {
val OWNER_ADDRESS_TYPE = generate("A01A", ADDRESS_TYPE.id, "Householder")
val MAIN_ADDRESS_STATUS = generate("M", ADDRESS_STATUS.id, "Main Address")
val PREV_ADDRESS_STATUS = generate("P", ADDRESS_STATUS.id, "Previous Address")

val NHC_Q001 = generate("Q001", HOSTEL_CODE.id)
val NHC_Q002 = generate("Q002", HOSTEL_CODE.id)

val NHC_Q005 = generate("Q005", HOSTEL_CODE.id)
val NHC_Q049 = generate("Q049", HOSTEL_CODE.id)
val NHC_Q095 = generate("Q095", HOSTEL_CODE.id)
val NHC_Q701 = generate("Q701", HOSTEL_CODE.id)
val NHC_Q702 = generate("Q702", HOSTEL_CODE.id)
val NHC_Q703 = generate("Q703", HOSTEL_CODE.id)
val NHC_Q704 = generate("Q704", HOSTEL_CODE.id)
val NHC_Q705 = generate("Q705", HOSTEL_CODE.id)
val NHC_Q706 = generate("Q706", HOSTEL_CODE.id)
val NHC_Q707 = generate("Q707", HOSTEL_CODE.id)
val NHC_Q708 = generate("Q708", HOSTEL_CODE.id)
val NHC_Q709 = generate("Q709", HOSTEL_CODE.id)
val NHC_Q710 = generate("Q710", HOSTEL_CODE.id)
val NHC_Q711 = generate("Q711", HOSTEL_CODE.id)
val NHC_Q712 = generate("Q712", HOSTEL_CODE.id)
val NHC_Q713 = generate("Q713", HOSTEL_CODE.id)
val NHC_Q714 = generate("Q714", HOSTEL_CODE.id)
val NHC_Q715 = generate("Q715", HOSTEL_CODE.id)
val NHC_Q716 = generate("Q716", HOSTEL_CODE.id)

val STAFF_GRADE = generate("TEST", DatasetGenerator.STAFF_GRADE.id, "Test staff grade")

val REFERRAL_DATE_TYPE = generate("CRC", ALL_DATASETS[DatasetCode.AP_REFERRAL_DATE_TYPE]!!.id)
Expand Down Expand Up @@ -87,7 +108,25 @@ object ReferenceDataGenerator {
PREV_ADDRESS_STATUS,
NHC_Q001,
NHC_Q002,
NHC_Q005,
NHC_Q049,
NHC_Q095,
NHC_Q701,
NHC_Q702,
NHC_Q703,
NHC_Q704,
NHC_Q705,
NHC_Q706,
NHC_Q707,
NHC_Q708,
NHC_Q709,
NHC_Q710,
NHC_Q711,
NHC_Q712,
NHC_Q713,
NHC_Q714,
NHC_Q715,
NHC_Q716,
STAFF_GRADE,
REFERRAL_DATE_TYPE,
REFERRAL_GROUP,
Expand Down
Loading
Loading