forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment-service-mock.feature
33 lines (26 loc) · 1017 Bytes
/
payment-service-mock.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Feature: payment service mock
Background:
* def nextId = call read('increment.js')
* def payments = {}
* def QueueUtils = Java.type('mock.contract.QueueUtils')
* configure cors = true
Scenario: pathMatches('/payments') && methodIs('post')
* def payment = request
* def id = nextId()
* set payment.id = id
* payments[id + ''] = payment
* def response = payment
* string json = { paymentId: '#(id)', status: 'shipped' }
* QueueUtils.send(queueName, json, 25)
Scenario: pathMatches('/payments')
* def response = $payments.*
Scenario: pathMatches('/payments/{id}') && methodIs('put')
* payments[pathParams.id] = request
* def response = request
Scenario: pathMatches('/payments/{id}') && methodIs('delete')
* karate.remove('payments', pathParams.id)
Scenario: pathMatches('/payments/{id}')
* def response = payments[pathParams.id]
Scenario: pathMatches('/')
* def responseHeaders = { 'Content-Type': 'text/html' }
* def response = read('payments.html')