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-2584 Create contacts from emails * Enable AsyncApi * Fix integration test errors for approved-premises-and-delius * Added tests for duplicate emails
- Loading branch information
1 parent
4b369fc
commit f3e3c30
Showing
40 changed files
with
776 additions
and
86 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
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
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
31 changes: 28 additions & 3 deletions
31
...s/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.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,25 +1,50 @@ | ||
package uk.gov.justice.digital.hmpps.data | ||
|
||
import jakarta.annotation.PostConstruct | ||
import jakarta.persistence.EntityManager | ||
import jakarta.transaction.Transactional | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.boot.context.event.ApplicationReadyEvent | ||
import org.springframework.context.ApplicationListener | ||
import org.springframework.stereotype.Component | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.BUSINESS_INTERACTIONS | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.CONTACT_TYPES | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.DUPLICATE_STAFF_1 | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.DUPLICATE_STAFF_2 | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.MANAGER | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.MANAGER_STAFF | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.PERSON | ||
import uk.gov.justice.digital.hmpps.data.generator.Data.STAFF | ||
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator | ||
import uk.gov.justice.digital.hmpps.user.AuditUserRepository | ||
|
||
@Component | ||
@ConditionalOnProperty("seed.database") | ||
class DataLoader( | ||
private val auditUserRepository: AuditUserRepository | ||
private val auditUserRepository: AuditUserRepository, | ||
private val entityManager: EntityManager, | ||
) : ApplicationListener<ApplicationReadyEvent> { | ||
|
||
@PostConstruct | ||
fun saveAuditUser() { | ||
auditUserRepository.save(UserGenerator.AUDIT_USER) | ||
} | ||
|
||
@Transactional | ||
override fun onApplicationEvent(are: ApplicationReadyEvent) { | ||
// Perform dev/test database setup here, using JPA repositories and generator classes... | ||
listOf( | ||
PERSON, | ||
STAFF, | ||
STAFF.user, | ||
DUPLICATE_STAFF_1, | ||
DUPLICATE_STAFF_1.user, | ||
DUPLICATE_STAFF_2, | ||
DUPLICATE_STAFF_2.user, | ||
MANAGER_STAFF, | ||
MANAGER, | ||
*CONTACT_TYPES, | ||
*BUSINESS_INTERACTIONS, | ||
).forEach { | ||
entityManager.persist(it) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...stice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/Data.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,23 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.audit.BusinessInteraction | ||
import uk.gov.justice.digital.hmpps.audit.BusinessInteractionCode | ||
import uk.gov.justice.digital.hmpps.entity.* | ||
import uk.gov.justice.digital.hmpps.set | ||
import java.time.ZonedDateTime | ||
|
||
object Data { | ||
val PERSON = Person(id(), crn = "A000001") | ||
val STAFF = staffWithUser(StaffUser(id(), username = "test-user")) | ||
val DUPLICATE_STAFF_1 = staffWithUser(StaffUser(id(), username = "duplicate1")) | ||
val DUPLICATE_STAFF_2 = staffWithUser(StaffUser(id(), username = "duplicate2")) | ||
val MANAGER_STAFF = Staff(id()) | ||
val MANAGER = PersonManager(id(), PERSON, MANAGER_STAFF.id, 102, 103) | ||
val CONTACT_TYPES = ContactType.Code.entries.map { ContactType(id(), it.code) }.toTypedArray() | ||
val BUSINESS_INTERACTIONS = BusinessInteractionCode.entries | ||
.map { BusinessInteraction(id(), it.code, ZonedDateTime.now()) }.toTypedArray() | ||
|
||
private fun id() = IdGenerator.getAndIncrement() | ||
|
||
private fun staffWithUser(user: StaffUser) = Staff(id(), user = user).also { user.set("staff", it) } | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/justice-email-and-delius/src/dev/resources/messages/multiple-crns.json
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,7 @@ | ||
{ | ||
"id": "00000000-0000-0000-0000-000000000000", | ||
"subject": "RE: A000001 and B000002", | ||
"bodyContent": "Example message", | ||
"fromEmailAddress": "[email protected]", | ||
"receivedDateTime": "2020-01-01T12:34:56Z[Europe/London]" | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/justice-email-and-delius/src/dev/resources/messages/multiple-staff.json
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,7 @@ | ||
{ | ||
"id": "00000000-0000-0000-0000-000000000000", | ||
"subject": "RE: A000001", | ||
"bodyContent": "Example message", | ||
"fromEmailAddress": "[email protected]", | ||
"receivedDateTime": "2020-01-01T12:34:56Z[Europe/London]" | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/justice-email-and-delius/src/dev/resources/messages/no-crn.json
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,7 @@ | ||
{ | ||
"id": "00000000-0000-0000-0000-000000000000", | ||
"subject": "No CRN here!", | ||
"bodyContent": "Example message", | ||
"fromEmailAddress": "[email protected]", | ||
"receivedDateTime": "2020-01-01T12:34:56Z[Europe/London]" | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/justice-email-and-delius/src/dev/resources/messages/no-staff.json
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,7 @@ | ||
{ | ||
"id": "00000000-0000-0000-0000-000000000000", | ||
"subject": "RE: A000001", | ||
"bodyContent": "Example message", | ||
"fromEmailAddress": "[email protected]", | ||
"receivedDateTime": "2020-01-01T12:34:56Z[Europe/London]" | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/justice-email-and-delius/src/dev/resources/messages/non-justice-email.json
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,7 @@ | ||
{ | ||
"id": "00000000-0000-0000-0000-000000000000", | ||
"subject": "RE: A000001", | ||
"bodyContent": "Example message", | ||
"fromEmailAddress": "[email protected]", | ||
"receivedDateTime": "2020-01-01T12:34:56Z[Europe/London]" | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/justice-email-and-delius/src/dev/resources/messages/successful-message.json
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,7 @@ | ||
{ | ||
"id": "00000000-0000-0000-0000-000000000000", | ||
"subject": "RE: A000001", | ||
"bodyContent": "Example message", | ||
"fromEmailAddress": "[email protected]", | ||
"receivedDateTime": "2020-01-01T12:34:56Z[Europe/London]" | ||
} |
26 changes: 26 additions & 0 deletions
26
projects/justice-email-and-delius/src/dev/resources/schema.ldif
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,26 @@ | ||
dn: ou=Users,dc=moj,dc=com | ||
objectclass: top | ||
objectclass: organizationalUnit | ||
ou: Users | ||
|
||
dn: cn=test-user,ou=Users,dc=moj,dc=com | ||
objectclass: top | ||
objectclass: inetOrgPerson | ||
cn: test-user | ||
sn: test-user | ||
mail: [email protected] | ||
|
||
dn: cn=duplicate1,ou=Users,dc=moj,dc=com | ||
objectclass: top | ||
objectclass: inetOrgPerson | ||
cn: duplicate1 | ||
sn: duplicate1 | ||
mail: [email protected] | ||
|
||
dn: cn=duplicate2,ou=Users,dc=moj,dc=com | ||
objectclass: top | ||
objectclass: inetOrgPerson | ||
cn: duplicate2 | ||
sn: duplicate2 | ||
mail: [email protected] | ||
|
Oops, something went wrong.