- define
expectioansin./mocks - refer to the
payments.jsonandtransactions.jsonexamples
docker compose up -dcurl "http://localhost:1080/transactions?transactionRef=XVJ3KF9" | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 132 100 132 0 0 425 0 --:--:-- --:--:-- --:--:-- 425
{
"transactionId": "945c47d1-203f-49ca-896a-5279d8075785",
"transactionRef": "XVJ3KF9",
"amount": 65000,
"charges": 75
}
curl -X POST "http://localhost:1080/payments" -H 'Content-Type: application/json' -d '{"counterpartyIBAN": "CH8089144265645434356", "amount": 15000}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 121 100 59 100 62 1401 1473 --:--:-- --:--:-- --:--:-- 2880
{
"status": "accepted",
"transactionRef": "XVJ3KF9"
}- enable proxy mode and start the
mockserver
mockserver:
...
command: -logLevel DEBUG -serverPort 1080 -proxyRemotePort 80 -proxyRemoteHost integration
...- build the mocks (proxy mode will record the
expectations)
curl -H "X-Token:$(uuidgen)" http://localhost:8089/ | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 73 100 73 0 0 160 0 --:--:-- --:--:-- --:--:-- 159
{
"source": "integration-service",
"processed": "2024-08-18T10:39:39.655213"
}- extract and load the
expectations
curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=RECORDED_EXPECTATIONS&format=JSON" -o ./mocks/recording.json- remove
X-Tokenheader
cat <<< $(jq 'del(.[].httpRequest.headers["X-Token"])' ./mocks/recording.json) > ./mocks/recording.json
- disable the proxy mode and restart
mockserver
mockserver:
...
# command: -logLevel DEBUG -serverPort 1080 -proxyRemotePort 80 -proxyRemoteHost integration
...- bring down the
integrationservice - re-initate the same request (response will be by the mock, instead of
integrationservice)
curl http://localhost:8089/ | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 73 100 73 0 0 229 0 --:--:-- --:--:-- --:--:-- 229
{
"source": "integration-service",
"processed": "2024-08-18T10:39:39.655213"
}
date
Sun Aug 18 13:45:41 +03 2024