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-1858: Added throw-not-found property for disabling in dev
- Loading branch information
Showing
10 changed files
with
272 additions
and
7 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
15 changes: 15 additions & 0 deletions
15
...ects/cas2-and-delius/src/dev/resources/messages/application-status-updated-not-found.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,15 @@ | ||
{ | ||
"eventType": "applications.cas2.application.status-updated", | ||
"version": 1, | ||
"description": "A CAS2 application has been updated", | ||
"detailUrl": "http://localhost:{wiremock.port}/approved-premises-api/events/cas2/application-status-updated/4444", | ||
"occurredAt": "2020-01-01T12:34:56Z[Europe/London]", | ||
"personReference": { | ||
"identifiers": [ | ||
{ | ||
"type": "CRN", | ||
"value": "A000001" | ||
} | ||
] | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
projects/cas2-and-delius/src/dev/resources/messages/application-submitted-bad-request.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,15 @@ | ||
{ | ||
"eventType": "applications.cas2.application.submitted", | ||
"version": 1, | ||
"description": "A CAS2 application has been submitted", | ||
"detailUrl": "http://localhost:{wiremock.port}/approved-premises-api/events/cas2/application-submitted/5555", | ||
"occurredAt": "2020-01-01T12:34:56Z[Europe/London]", | ||
"personReference": { | ||
"identifiers": [ | ||
{ | ||
"type": "CRN", | ||
"value": "A005555" | ||
} | ||
] | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
projects/cas2-and-delius/src/dev/resources/messages/application-submitted-not-found.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,15 @@ | ||
{ | ||
"eventType": "applications.cas2.application.submitted", | ||
"version": 1, | ||
"description": "A CAS2 application has been submitted", | ||
"detailUrl": "http://localhost:{wiremock.port}/approved-premises-api/events/cas2/application-submitted/3333", | ||
"occurredAt": "2020-01-01T12:34:56Z[Europe/London]", | ||
"personReference": { | ||
"identifiers": [ | ||
{ | ||
"type": "CRN", | ||
"value": "A003333" | ||
} | ||
] | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
...delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/NotFoundIntegrationTest.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,68 @@ | ||
package uk.gov.justice.digital.hmpps | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.containsString | ||
import org.hamcrest.Matchers.not | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.mockito.Mockito | ||
import org.mockito.kotlin.any | ||
import org.mockito.kotlin.verify | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.boot.test.system.CapturedOutput | ||
import org.springframework.boot.test.system.OutputCaptureExtension | ||
import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager | ||
import uk.gov.justice.digital.hmpps.telemetry.TelemetryService | ||
|
||
@SpringBootTest(properties = ["event.exception.throw-not-found: false"]) | ||
@ExtendWith(OutputCaptureExtension::class) | ||
internal class NotFoundIntegrationTest { | ||
@Value("\${messaging.consumer.queue}") | ||
lateinit var queueName: String | ||
|
||
@Autowired | ||
lateinit var channelManager: HmppsChannelManager | ||
|
||
@Autowired | ||
lateinit var wireMockServer: WireMockServer | ||
|
||
@MockBean | ||
lateinit var telemetryService: TelemetryService | ||
|
||
@Test | ||
fun `application submitted not found enabled`(output: CapturedOutput) { | ||
// Given a message | ||
val event = prepEvent("application-submitted-not-found", wireMockServer.port()) | ||
channelManager.getChannel(queueName).publishAndWait(event) | ||
//Assert that expected exception exists in output | ||
assertThat(output.all, not(containsString("No DomainEvent with an ID of 3333 could be found"))) | ||
//Assert that only 1 trackEvent for Notification Received has occurred | ||
verify(telemetryService, Mockito.times(1)).trackEvent(any(), any(), any()) | ||
} | ||
|
||
@Test | ||
fun `application status not found enabled`(output: CapturedOutput) { | ||
// Given a message | ||
val event = prepEvent("application-status-updated-not-found", wireMockServer.port()) | ||
channelManager.getChannel(queueName).publishAndWait(event) | ||
//Assert that expected exception exists in output | ||
assertThat(output.all, not(containsString("No DomainEvent with an ID of 4444 could be found"))) | ||
//Assert that only 1 trackEvent for Notification Received has occurred | ||
verify(telemetryService, Mockito.times(1)).trackEvent(any(), any(), any()) | ||
} | ||
|
||
@Test | ||
fun `application submitted bad request still thrown`(output: CapturedOutput) { | ||
// Given a message | ||
val event = prepEvent("application-submitted-bad-request", wireMockServer.port()) | ||
channelManager.getChannel(queueName).publishAndWait(event) | ||
//Assert that expected exception exists in output | ||
assertThat(output.all, containsString("Bad Request")) | ||
//Assert that only 1 trackEvent for Notification Received has occurred | ||
verify(telemetryService, Mockito.times(1)).trackEvent(any(), any(), any()) | ||
} | ||
} |
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