Summary| Tags| Feature: feature/bookings/bookings.feature| Testing booking endpoint
Scenario: [1:37] Booking creation
ms: 2200
>>
Background:
3
* url baseUrl
1
09:23:07.628 karate.env system property was: dev
4
* def bookingRequest = read('classpath:json/request/booking/request.json')
51
5
* def bookingResponse = read('classpath:json/response/booking/response.json')
1
6
* def dataGenerator = Java.type('helpers.DataGenerator')
4
7
* configure logPrettyRequest = true
1
8
* configure logPrettyResponse = true
0
11
* def findRoom =
17
function() { while(true) { var dates = dataGenerator.getRandomPairOfDates() var res = karate.call('classpath:helpers/featuresHelpers/getrooms.feature', { checkin: dates.checkin, checkout: dates.checkout }) if(res.response.rooms && res.response.rooms.length > 0) { return { roomid: res.response.rooms[0].roomid, checkin: dates.checkin, checkout: dates.checkout } } karate.log('Trying new date... no rooms for :', dates.checkin); java.lang.Thread.sleep(500); } }
34
* def roomInfo = findRoom()
1373
>>
helpers.featuresHelpers.getrooms
1305
5
* url baseUrl
1
8
Given path 'room'
1
9
And param checkin = checkin
1
10
And param checkout = checkout
0
11
When method get
1303
09:23:08.375 request: 1 > GET https://automationintesting.online/api/room?checkin=2026-05-04&checkout=2026-05-06 1 > Accept: application/json 1 > Content-Type: application/json 1 > User-Agent: Karate-Automation-SEDET 1 > Host: automationintesting.online 1 > Connection: Keep-Alive 1 > Accept-Encoding: gzip,deflate 09:23:09.112 response time in milliseconds: 729 1 < 200 1 < Date: Mon, 23 Mar 2026 09:23:09 GMT 1 < Content-Type: application/json 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < Server: cloudflare 1 < vary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch 1 < x-railway-edge: railway/us-east4-eqdc4a 1 < x-railway-request-id: jOZF5l63SROvGF86ezItjw 1 < cf-cache-status: DYNAMIC 1 < Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800} 1 < Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=i9J57K4%2BznpkjJvoXN4U6bgq6r18HNOLMqKx%2BweqoLprSuGz7DTepdlS0pMQX4PHwKmXkhFwGjxDMhv077coxgQ0bbg0Sx%2FUNTyiuoH9tnvFpMZqlfBHbEeS"}]} 1 < CF-RAY: 9e0c602d2ba61b04-ORD 1 < alt-svc: h3=":443"; ma=86400 { "rooms": [ { "roomid": 1, "roomName": "101", "type": "Single", "accessible": true, "image": "/images/room1.jpg", "description": "Aenean porttitor mauris sit amet lacinia molestie. In posuere accumsan aliquet. Maecenas sit amet nisl massa. Interdum et malesuada fames ac ante.", "features": [ "TV", "WiFi", "Safe" ], "roomPrice": 100 }, { "roomid": 2, "roomName": "102", "type": "Double", "accessible": true, "image": "/images/room2.jpg", "description": "Vestibulum sollicitudin, lectus ac mollis consequat, lorem orci ultrices tellus, eleifend euismod tortor dui egestas erat. Phasellus et ipsum nisl. ", "features": [ "TV", "Radio", "Safe" ], "roomPrice": 150 }, { "roomid": 3, "roomName": "103", "type": "Suite", "accessible": true, "image": "/images/room3.jpg", "description": "Etiam metus metus, fringilla ac sagittis id, consequat vel neque. Nunc commodo quis nisl nec posuere. Etiam at accumsan ex. ", "features": [ "Radio", "WiFi", "Safe" ], "roomPrice": 225 } ] }
12
Then status 200
0
38
Given path 'booking'
1
# SET request json from the file with Random values
40
* set bookingRequest.roomid = parseInt(roomInfo.roomid)
5
41
* set bookingRequest.firstname = dataGenerator.getRandomFirstName()
171
42
* set bookingRequest.lastname = dataGenerator.getRandomLastName()
2
43
* set bookingRequest.depositpaid = dataGenerator.getRandomDepositpaid()
3
45
* set bookingRequest.bookingdates = { checkin: '#(roomInfo.checkin)', checkout: '#(roomInfo.checkout)' }
2
46
* print bookingRequest
2
09:23:09.305 [print] { "roomid": 1, "firstname": "Roman", "lastname": "Rolfson", "depositpaid": false, "bookingdates": { "checkin": "2026-05-04", "checkout": "2026-05-06" } }
47
And request bookingRequest
0
48
When method post
561
09:23:09.343 request: 1 > POST https://automationintesting.online/api/booking 1 > Accept: application/json 1 > Content-Type: application/json; charset=UTF-8 1 > User-Agent: Karate-Automation-SEDET 1 > Content-Length: 137 1 > Host: automationintesting.online 1 > Connection: Keep-Alive 1 > Accept-Encoding: gzip,deflate { "roomid": 1, "firstname": "Roman", "lastname": "Rolfson", "depositpaid": false, "bookingdates": { "checkin": "2026-05-04", "checkout": "2026-05-06" } } 09:23:09.865 response time in milliseconds: 521 1 < 201 1 < Date: Mon, 23 Mar 2026 09:23:09 GMT 1 < Content-Type: application/json 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < Server: cloudflare 1 < vary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch 1 < x-railway-edge: railway/us-east4-eqdc4a 1 < x-railway-request-id: jlPftaTAQP22aju7woOzXw 1 < cf-cache-status: DYNAMIC 1 < Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800} 1 < Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=XUxwZAOBYMqQi7tEsrpfRpPCJiP3fEYRcVD23SzlbCbyjBkk%2B2txn5RF3R%2FFPvjYm4zeCnV8u5JBHsf4xL3dzODvPOts05IF4HcZ4Cueo5W7DDp6D5xaBg%3D%3D"}]} 1 < CF-RAY: 9e0c602f88fd49f4-ORD 1 < alt-svc: h3=":443"; ma=86400 { "bookingid": 8, "roomid": 1, "firstname": "Roman", "lastname": "Rolfson", "depositpaid": false, "bookingdates": { "checkin": "2026-05-04", "checkout": "2026-05-06" } }
49
Then status 201
0
50
* print response
2
09:23:09.869 [print] { "bookingid": 8, "roomid": 1, "firstname": "Roman", "lastname": "Rolfson", "depositpaid": false, "bookingdates": { "checkin": "2026-05-04", "checkout": "2026-05-06" } }
51
And match response == '#(^bookingRequest)'
3