Skip to content

Commit a274656

Browse files
committed
[ESWE-1080] Fix lint-code formatting issues
1 parent d148492 commit a274656

File tree

4 files changed

+50
-48
lines changed

4 files changed

+50
-48
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/ExpressionInterestController.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,5 @@ class ExpressionInterestController(
6565
}
6666
}
6767

68-
fun getVerifiedNomisNumber(nomisNumberResponse: Response<NomisNumber?>): String? {
69-
return nomisNumberResponse.data?.nomisNumber
70-
}
68+
fun getVerifiedNomisNumber(nomisNumberResponse: Response<NomisNumber?>) = nomisNumberResponse.data?.nomisNumber
7169
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception
22

3-
class MessageFailedException(msg: String) : RuntimeException(msg)
3+
class MessageFailedException(
4+
msg: String,
5+
) : RuntimeException(msg)

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/ExpressionInterestService.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class ExpressionInterestService(
3131
)
3232

3333
eoiQueueSqsClient.sendMessage(
34-
SendMessageRequest.builder()
34+
SendMessageRequest
35+
.builder()
3536
.queueUrl(eoiQueueUrl)
3637
.messageBody(messageBody)
3738
.build(),

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/ExpressionInterestServiceTest.kt

+44-43
Original file line numberDiff line numberDiff line change
@@ -19,59 +19,60 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ExpressionO
1919
import uk.gov.justice.hmpps.sqs.HmppsQueue
2020
import uk.gov.justice.hmpps.sqs.HmppsQueueService
2121

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>()
2627

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+
}
3233

33-
val service = ExpressionInterestService(mockQueueService, mockObjectMapper)
34+
val service = ExpressionInterestService(mockQueueService, mockObjectMapper)
3435

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+
}
3940

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"}"""
4445

45-
whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage>()))
46-
.thenReturn(messageBody)
46+
whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage>()))
47+
.thenReturn(messageBody)
4748

48-
service.sendExpressionOfInterest(expressionInterest)
49+
service.sendExpressionOfInterest(expressionInterest)
4950

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+
}
5960

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")
6263

63-
whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage>()))
64-
.thenReturn("""{"jobId":"12345","verifiedHmppsId":"H1234"}""")
64+
whenever(mockObjectMapper.writeValueAsString(any<ExpressionOfInterestMessage>()))
65+
.thenReturn("""{"jobId":"12345","verifiedHmppsId":"H1234"}""")
6566

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"))
6869

69-
val exception =
70-
shouldThrow<MessageFailedException> {
71-
service.sendExpressionOfInterest(expressionInterest)
72-
}
70+
val exception =
71+
shouldThrow<MessageFailedException> {
72+
service.sendExpressionOfInterest(expressionInterest)
73+
}
7374

74-
exception.message shouldBe "Failed to send message to SQS"
75+
exception.message shouldBe "Failed to send message to SQS"
76+
}
7577
}
76-
}
77-
})
78+
})

0 commit comments

Comments
 (0)