You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/TransactionTransferRequest.kt
@field:NotBlank(message = "Description must not be blank")
6
8
@Schema(description ="Description of the transaction.")
7
9
valdescription:String,
8
10
@Schema(
9
11
description ="Amount of money in pence, must be positive.",
10
12
example ="1234",
11
13
)
12
14
valamount:Int,
15
+
@field:NotBlank(message = "Client transaction ID must not be blank")
13
16
@Schema(description ="Client Transaction Id.")
14
17
valclientTransactionId:String,
18
+
@field:NotBlank(message = "Client unique ref must not be blank")
15
19
@Schema(description ="A reference unique to the client making the post. Maximum size 64 characters, only alphabetic, numeric, '-' and '_' are allowed.")
16
20
valclientUniqueRef:String,
21
+
@field:NotBlank(message = "From account must not be blank")
17
22
@Schema(description ="The account to move money from. Must be 'spends'.", example ="spends")
18
23
valfromAccount:String,
24
+
@field:NotBlank(message = "To account must not be blank")
19
25
@Schema(description ="The account to move money to. Must be 'savings'.", example ="savings")
Copy file name to clipboardexpand all lines: src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/TransactionsControllerTest.kt
+106-92
Original file line number
Diff line number
Diff line change
@@ -53,8 +53,6 @@ class TransactionsControllerTest(
53
53
val basePath = "/v1/prison/$prisonId/prisoners/$hmppsId"
54
54
val transactionsPath = "$basePath/accounts/$accountCode/transactions"
55
55
val transactionPath = "$basePath/transactions/$clientUniqueRef"
56
-
val postTransactionPath = "$basePath/transactions"
57
-
val postTransactionTransferPath = "$postTransactionPath/transfer"
58
56
val mockMvc = IntegrationAPIMockMvc(springMockMvc)
59
57
60
58
val type = "CANT"
@@ -64,7 +62,6 @@ class TransactionsControllerTest(
64
62
val postClientUniqueRef = "CLIENT121131-0_11"
65
63
val fromAccount = "spends"
66
64
val toAccount = "savings"
67
-
val exampleTransactionTransfer = TransactionTransferRequest(description, amount, clientTransactionId, postClientUniqueRef, fromAccount, toAccount)
68
65
69
66
val transactions =
70
67
Transactions(
@@ -225,6 +222,7 @@ class TransactionsControllerTest(
225
222
}
226
223
227
224
describe("POST transaction") {
225
+
val postTransactionPath = "$basePath/transactions"
228
226
val exampleTransaction = TransactionRequest(type, description, amount, clientTransactionId, postClientUniqueRef)
229
227
230
228
it("returns a response with a transaction ID") {
@@ -327,117 +325,133 @@ class TransactionsControllerTest(
327
325
}
328
326
}
329
327
330
-
// Post transaction transfer
328
+
describe("POST transaction/transfer") {
329
+
val postTransactionTransferPath = "$basePath/transactions/transfer"
330
+
val exampleTransactionTransfer = TransactionTransferRequest(description, amount, clientTransactionId, postClientUniqueRef, fromAccount, toAccount)
331
331
332
-
it("returns a response with a transaction ID, debit and credit transaction IDs") {
val result = mockMvc.performAuthorisedPost(postTransactionTransferPath, invalidTransactionTransfer)
396
+
result.response.run {
397
+
status.shouldBe(HttpStatus.BAD_REQUEST.value())
398
+
contentAsJson<ValidationErrorResponse>().validationErrors.shouldContainAll("Description must not be blank", "Client transaction ID must not be blank", "Client unique ref must not be blank", "From account must not be blank", "To account must not be blank")
399
+
}
400
+
}
394
401
395
-
val result = mockMvc.performAuthorisedPostWithCN(postTransactionTransferPath, "limited-prisons", exampleTransactionTransfer)
0 commit comments