-
Notifications
You must be signed in to change notification settings - Fork 0
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
[ESWE-1181] ID mappings for Employer, Reference Data #23
Conversation
rickchoijd
commented
Jan 29, 2025
- (dynamic) ID mappings for Employer
- (static) ID mappings for Reference Data (used by Employer)
- relevant integration tests (JPA repository)
- Flyway migrations for new table and materialised view
- (dynamic) ID mappings for Employer - (static) ID mappings for Reference Data (used by Employer) - relevant integration tests (JPA repository) - Flyway migrations for new table and materialised view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a base class for JPA Repository (integration) tests without Flyway.
Similar to JobsBoard backend, we split integration tests into two sets, 1 general and 1 JPA/Repository specific.
Two sets of test run in different PostgreSQL containers (if not reusing a already-running DB)
private val refDataMappingsForTests: List<RefDataMapping> | ||
get() = mapOf( | ||
"employer_status" to mapOf( | ||
"KEY_PARTNER" to 1L, | ||
"GOLD" to 2, | ||
"SILVER" to 3, | ||
), | ||
"employer_sector" to mapOf( | ||
"ADMIN_SUPPORT" to 14L, | ||
"AGRICULTURE" to 1, | ||
"ARTS_ENTERTAINMENT" to 18, | ||
"CONSTRUCTION" to 6, | ||
"EDUCATION" to 16, | ||
"ENERGY" to 4, | ||
"FINANCE" to 11, | ||
"HEALTH_SOCIAL" to 17, | ||
"HOSPITALITY_CATERING" to 9, | ||
"LOGISTICS" to 8, | ||
"MANUFACTURING" to 3, | ||
"MINING" to 2, | ||
"OTHER" to 19, | ||
"PROFESSIONALS_SCIENTISTS_TECHNICIANS" to 13, | ||
"PROPERTY" to 12, | ||
"PUBLIC_ADMIN_DEFENCE" to 15, | ||
"WASTE_MANAGEMENT" to 5, | ||
"RETAIL" to 7, | ||
"TECHNOLOGY" to 10, | ||
), | ||
).map { (refData, mapping) -> mapping.map { (value, externalId) -> RefDataMapping(refData, value, externalId) } } | ||
.flatten() | ||
} | ||
|
||
@Repository | ||
internal interface RefDataMappingTestOnlyRepository : JpaRepository<RefDataMapping, RefDataMappingKey> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These mappings is to feed testing data for the "Materialised View" in absence of Flyway (which create it via repeatable migration)
This repository is thus created only for JPA Repository tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing configuration for JPA Repository tests
|
||
@Repository | ||
interface EmployerExternalIdRepository : JpaRepository<EmployerExternalId, ExternalIdKey> { | ||
fun findByKeyId(id: String): EmployerExternalId? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look up by internal ID
@Repository | ||
interface EmployerExternalIdRepository : JpaRepository<EmployerExternalId, ExternalIdKey> { | ||
fun findByKeyId(id: String): EmployerExternalId? | ||
fun findByKeyExternalId(externalId: Long): EmployerExternalId? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look up by external ID
import uk.gov.justice.digital.hmpps.jobsboardintegrationapi.shared.domain.ReadOnlyRepository | ||
|
||
@Entity | ||
@Table(name = "ref_data_mappings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually not a table but a materialised view (MV) with static data in DB
This restrict only known reference data.
Maintenance shall be done via Flyway's repeatable migration of this MV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helper (base) class to help injecting audit fields (timestamps)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A read-only repository interface, is added for the static materialised view of Reference Data mappings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a repeatable migration of Flyway.
This is the maintenance point of reference data mappings with MN.
Unique indexes have been added to reinforce unique mapping either direction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Versioned migration of Flyway
This version is expected to hold all relevant DB changes until it was promoted to production/live DB.
Next change will be adding Job ID's mapping table