generated from ministryofjustice/hmpps-template-kotlin
-
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.
- Loading branch information
1 parent
27c2daf
commit 8e4a7c1
Showing
11 changed files
with
86 additions
and
51 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
58 changes: 58 additions & 0 deletions
58
src/test/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/integration/DomainEventTest.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,58 @@ | ||
package uk.gov.justice.digital.hmpps.breachnoticeapi.integration | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.awaitility.Awaitility | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Nested | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import software.amazon.awssdk.services.sns.model.MessageAttributeValue | ||
import software.amazon.awssdk.services.sns.model.PublishRequest | ||
import uk.gov.justice.digital.hmpps.breachnoticeapi.entity.BreachNoticeEntity | ||
import uk.gov.justice.digital.hmpps.breachnoticeapi.model.BreachNotice | ||
import uk.gov.justice.digital.hmpps.breachnoticeapi.repository.BreachNoticeRepository | ||
import java.util.concurrent.TimeUnit | ||
|
||
class DomainEventTest : IntegrationTestBase() { | ||
|
||
@Autowired | ||
private lateinit var breachNoticeRepository: BreachNoticeRepository | ||
|
||
@Nested | ||
@DisplayName("GET /breach-notice/{parameter}") | ||
inner class BreachNoticeTestEntityEndpoint { | ||
|
||
@Test | ||
fun `merge event should update CRN for active breach notice`() { | ||
webTestClient.post() | ||
.uri("/breach-notice") | ||
.headers(setAuthorisation(roles = listOf("ROLE_BREACH_NOTICE"))) | ||
.bodyValue(BreachNotice(crn = "X000101")) | ||
.exchange() | ||
.expectStatus() | ||
.isCreated | ||
|
||
val breachNotice = breachNoticeRepository.findByCrn("X000101").single() | ||
assertThat(breachNotice.crn).isEqualTo("X000101") | ||
assertThat(breachNotice.id).isNotNull() | ||
|
||
val message: String = "{\"eventType\":\"probation-case.merge.completed\",\"version\":1,\"occurredAt\":\"2025-03-04T10:30:07.329287Z\",\"description\":\"A merge has been completed on the probation case\",\"additionalInformation\":{\"sourceCRN\":\"X000101\",\"targetCRN\":\"X000102\"},\"personReference\":{\"identifiers\":[{\"type\":\"CRN\",\"value\":\"X000102\"}]}}\n" | ||
|
||
val responseFuture = inboundSnsClient.publish( | ||
PublishRequest.builder().topicArn("arn:aws:sns:eu-west-2:000000000000:hmppsbreachnoticetopic").message(message).messageAttributes( | ||
mapOf("eventType" to MessageAttributeValue.builder().dataType("String").stringValue("probation-case.merge.completed").build()), | ||
).build(), | ||
) | ||
val response = responseFuture.get(10, TimeUnit.SECONDS) | ||
|
||
assertThat(response.messageId()).isNotNull() | ||
|
||
Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted { | ||
val breachNoticeUpdated: BreachNoticeEntity = breachNoticeRepository.findById(breachNotice.id).orElse(null) | ||
assertThat(breachNoticeUpdated).isNotNull | ||
assertThat(breachNoticeUpdated.crn).isEqualTo("X000102") | ||
assertThat(breachNoticeUpdated.id).isNotNull() | ||
} | ||
} | ||
} | ||
} |
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
6 changes: 0 additions & 6 deletions
6
src/test/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/integration/NotFoundTest.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
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
6 changes: 0 additions & 6 deletions
6
...kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/integration/health/HealthCheckTest.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
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