Skip to content

Commit b24bc36

Browse files
committed
Transaction integration tests added and expected json response mocked
1 parent 7b973b0 commit b24bc36

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/main/resources/application-integration-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ authorisation:
101101
include:
102102
- "/v1/prison/prisoners/[^/]*$"
103103
- "/v1/prison/.*/prisoners/.*/accounts/.*/transactions"
104+
- "/v1/prison/.*/prisoners/.*/transactions/[^/]*$"
104105
filters:
105106
prisons:
106107
- ABC

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/integration/TransactionsIntegrationTest.kt

+21-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class TransactionsIntegrationTest : IntegrationTestBase() {
1111
val accountCode = "spends"
1212
final val fromDate = "2024-01-01"
1313
final val toDate = "2024-01-14"
14+
val clientUniqueRef = "ABC123456X"
1415
var dateQueryParams = "?from_date=$fromDate&to_date=$toDate"
1516

1617
@Test
@@ -32,7 +33,7 @@ class TransactionsIntegrationTest : IntegrationTestBase() {
3233
}
3334

3435
@Test
35-
fun `returns no results`() {
36+
fun `transactions returns no results`() {
3637
var wrongPrisonId = "XYZ"
3738
val headers = org.springframework.http.HttpHeaders()
3839
headers.set("subject-distinguished-name", "C=GB,ST=London,L=London,O=Home Office,CN=limited-prisons")
@@ -41,4 +42,23 @@ class TransactionsIntegrationTest : IntegrationTestBase() {
4142
get("/v1/prison/$wrongPrisonId/prisoners/$hmppsId/accounts/$accountCode/transactions").headers(headers),
4243
).andExpect(status().isNotFound)
4344
}
45+
46+
// transaction
47+
@Test
48+
fun `return a transaction for a prisoner`() {
49+
callApi("/v1/prison/$prisonId/prisoners/$hmppsId/transactions/$clientUniqueRef")
50+
.andExpect(status().isOk)
51+
.andExpect(content().json(getExpectedResponse("transaction-response")))
52+
}
53+
54+
@Test
55+
fun `transaction returns no result`() {
56+
var wrongPrisonId = "XYZ"
57+
val headers = org.springframework.http.HttpHeaders()
58+
headers.set("subject-distinguished-name", "C=GB,ST=London,L=London,O=Home Office,CN=limited-prisons")
59+
mockMvc
60+
.perform(
61+
get("/v1/prison/$wrongPrisonId/prisoners/$hmppsId/transactions/$clientUniqueRef").headers(headers),
62+
).andExpect(status().isNotFound)
63+
}
4464
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"data":
3+
{
4+
"id": "204564839-3",
5+
"type": {
6+
"code": "string",
7+
"desc": "string"
8+
},
9+
"description": "Transfer In Regular from caseload PVR",
10+
"amount": 12345,
11+
"date": "2016-10-21"
12+
}
13+
}

0 commit comments

Comments
 (0)