@@ -19,59 +19,60 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ExpressionO
19
19
import uk.gov.justice.hmpps.sqs.HmppsQueue
20
20
import uk.gov.justice.hmpps.sqs.HmppsQueueService
21
21
22
- class ExpressionInterestServiceTest : DescribeSpec ({
23
- val mockQueueService = mock<HmppsQueueService >()
24
- val mockSqsClient = mock<SqsAsyncClient >()
25
- val mockObjectMapper = mock<ObjectMapper >()
22
+ class ExpressionInterestServiceTest :
23
+ DescribeSpec ({
24
+ val mockQueueService = mock<HmppsQueueService >()
25
+ val mockSqsClient = mock<SqsAsyncClient >()
26
+ val mockObjectMapper = mock<ObjectMapper >()
26
27
27
- val eoiQueue =
28
- mock<HmppsQueue > {
29
- on { sqsClient } doReturn mockSqsClient
30
- on { queueUrl } doReturn " https://test-queue-url"
31
- }
28
+ val eoiQueue =
29
+ mock<HmppsQueue > {
30
+ on { sqsClient } doReturn mockSqsClient
31
+ on { queueUrl } doReturn " https://test-queue-url"
32
+ }
32
33
33
- val service = ExpressionInterestService (mockQueueService, mockObjectMapper)
34
+ val service = ExpressionInterestService (mockQueueService, mockObjectMapper)
34
35
35
- beforeTest {
36
- reset(mockQueueService, mockSqsClient, mockObjectMapper)
37
- whenever(mockQueueService.findByQueueId("eoi-queue")).thenReturn(eoiQueue)
38
- }
36
+ beforeTest {
37
+ reset(mockQueueService, mockSqsClient, mockObjectMapper)
38
+ whenever(mockQueueService.findByQueueId(" eoi-queue" )).thenReturn(eoiQueue)
39
+ }
39
40
40
- describe("sendExpressionOfInterest") {
41
- it("should send a valid message successfully to SQS ") {
42
- val expressionInterest = ExpressionInterest (jobId = "12345", hmppsId = "H1234 ")
43
- val messageBody = """ {"jobId":"12345","verifiedHmppsId":"H1234"}"""
41
+ describe(" sendExpressionOfInterest" ) {
42
+ it(" should send a valid message successfully to SQS" ) {
43
+ val expressionInterest = ExpressionInterest (jobId = " 12345" , hmppsId = " H1234" )
44
+ val messageBody = """ {"jobId":"12345","verifiedHmppsId":"H1234"}"""
44
45
45
- whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage >()))
46
- .thenReturn(messageBody)
46
+ whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage >()))
47
+ .thenReturn(messageBody)
47
48
48
- service.sendExpressionOfInterest(expressionInterest)
49
+ service.sendExpressionOfInterest(expressionInterest)
49
50
50
- verify(mockSqsClient).sendMessage(
51
- argThat<SendMessageRequest > { request: SendMessageRequest ? ->
52
- (
53
- request?.queueUrl() == "https://test-queue-url" &&
54
- request.messageBody() == messageBody
55
- )
56
- },
57
- )
58
- }
51
+ verify(mockSqsClient).sendMessage(
52
+ argThat<SendMessageRequest > { request: SendMessageRequest ? ->
53
+ (
54
+ request?.queueUrl() == " https://test-queue-url" &&
55
+ request.messageBody() == messageBody
56
+ )
57
+ },
58
+ )
59
+ }
59
60
60
- it("should throw MessageFailedException when SQS fails") {
61
- val expressionInterest = ExpressionInterest (jobId = "12345", hmppsId = "H1234 ")
61
+ it(" should throw MessageFailedException when SQS fails" ) {
62
+ val expressionInterest = ExpressionInterest (jobId = " 12345" , hmppsId = " H1234" )
62
63
63
- whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage >()))
64
- .thenReturn("""{"jobId":"12345","verifiedHmppsId":"H1234 "}""")
64
+ whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage >()))
65
+ .thenReturn(""" {"jobId":"12345","verifiedHmppsId":"H1234"}""" )
65
66
66
- whenever(mockSqsClient.sendMessage(any<SendMessageRequest >()))
67
- .thenThrow(RuntimeException ("Failed to send message to SQS "))
67
+ whenever(mockSqsClient.sendMessage(any<SendMessageRequest >()))
68
+ .thenThrow(RuntimeException (" Failed to send message to SQS" ))
68
69
69
- val exception =
70
- shouldThrow<MessageFailedException > {
71
- service.sendExpressionOfInterest(expressionInterest)
72
- }
70
+ val exception =
71
+ shouldThrow<MessageFailedException > {
72
+ service.sendExpressionOfInterest(expressionInterest)
73
+ }
73
74
74
- exception.message shouldBe " Failed to send message to SQS"
75
+ exception.message shouldBe " Failed to send message to SQS"
76
+ }
75
77
}
76
- }
77
- })
78
+ })
0 commit comments