-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-service-conformity.feature
129 lines (126 loc) · 6.55 KB
/
check-service-conformity.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Feature:
Background:
* def now = function(){ return java.lang.System.currentTimeMillis() }
* def account_name = 'Conformity-' + now()
* url 'http://localhost:8080/'
Scenario: Healthcheck
Given path 'healthcheck'
When method head
Scenario: Simple Conformity Scenario - API Behavior and Cache agressive check
# Create an account
Given path 'api/accounts'
And header Content-Type = 'application/json'
And request { login: #(account_name) }
When method post
Then match [200, 201, 204] contains responseStatus
Then match response contains { id: #uuid, login: #(account_name)}
Then def account_id = response.id
# Create list linked to the account
Given path 'api/accounts',account_id,'lists'
And header Content-Type = 'application/json'
And def list_name = 'List-' + now()
And request { name: #(list_name) }
When method post
Then match [200, 201, 204] contains responseStatus
Then match response contains { id: #uuid, name: #(list_name) }
Then def list_id = response.id
# Create 1 task on the list
Given path 'api/lists',list_id,'tasks'
And header Content-Type = 'application/json'
And def task_name = 'Task-' + now()
And def task_description = 'Description-' + now()
And request { name: #(task_name), description: #(task_description) }
When method post
Then match [200, 201, 204] contains responseStatus
Then match response contains { id: #uuid, name: #(task_name), description: #(task_description)}
Then def task_id = response.id
# Check current list content
Given path 'api/accounts',account_id,'lists'
And header Content-Type = 'application/json'
And param page = 0
When method get
Then match [200, 201, 204] contains responseStatus
Then match response[0] contains { id: #(list_id), name: #(list_name), tasks: #notnull }
Then match response[0].tasks[0] contains { id: #(task_id), name: #(task_name), description: #(task_description) }
# Check stats
Given path 'api/stats'
And header Content-Type = 'application/json'
When method get
Then match [200, 201, 204] contains responseStatus
Then def sub_result = karate.filter(response, x => { return x.account_id == account_id } )
Then match sub_result[0] contains { account_id: #(account_id), account_login: #(account_name), list_count:1, task_avg:1 }
# Create a 2nd task on the list
Given path 'api/lists',list_id,'tasks'
And header Content-Type = 'application/json'
And def task_name_2 = 'Task-' + now()
And def task_description_2 = 'Description-' + now()
And request { name: #(task_name_2), description: #(task_description_2) }
When method post
Then match [200, 201, 204] contains responseStatus
Then match response contains { id: #uuid, name: #(task_name_2), description: #(task_description_2) }
Then def task_id_2 = response.id
# Check current list content - should be 2 tasks
Given path 'api/accounts',account_id,'lists'
And header Content-Type = 'application/json'
And param page = 0
When method get
Then match [200, 201, 204] contains responseStatus
Then match response[0] contains { id: #(list_id), name: #(list_name), tasks: #notnull }
Then def r = karate.filter(response[0].tasks, x => { return x.id == task_id } )
Then match r[0] contains { id: #(task_id), name: #(task_name), description: #(task_description) }
Then def r = karate.filter(response[0].tasks, x => { return x.id == task_id_2 } )
Then match r[0] contains { id: #(task_id_2), name: #(task_name_2), description: #(task_description_2) }
# Create a 2nd list on the account
Given path 'api/accounts',account_id,'lists'
And header Content-Type = 'application/json'
And def list_name_2 = 'List-' + now()
And request { name: #(list_name_2) }
When method post
Then match [200, 201, 204] contains responseStatus
Then match response contains { id: #uuid, name: #(list_name_2) }
Then def list_id_2 = response.id
# Check current lists content - should be 2 tasks
Given path 'api/accounts',account_id,'lists'
And header Content-Type = 'application/json'
And param page = 0
When method get
Then match [200, 201, 204] contains responseStatus
Then def lr1 = karate.filter(response, x => { return x.id == list_id } )
Then match lr1[0] contains { id: #(list_id), name: #(list_name), tasks: #notnull }
Then def r = karate.filter(lr1[0].tasks, x => { return x.id == task_id } )
Then match r[0] contains { id: #(task_id), name: #(task_name), description: #(task_description) }
Then def r = karate.filter(lr1[0].tasks, x => { return x.id == task_id_2 } )
Then match r[0] contains { id: #(task_id_2), name: #(task_name_2), description: #(task_description_2) }
Then def lr2 = karate.filter(response, x => { return x.id == list_id_2 } )
Then match lr2[0] contains { id: #(list_id_2), name: #(list_name_2), account_id: #(account_id) }
# Create 1 task on the 2nd list
Given path 'api/lists',list_id_2,'tasks'
And header Content-Type = 'application/json'
And request { name: #(task_name), description: #(task_description) }
When method post
Then match [200, 201, 204] contains responseStatus
Then match response contains { id: #uuid, name: #(task_name), description: #(task_description)}
Then def task_id_1_2 = response.id
# Check current lists content - should be 2 tasks
Given path 'api/accounts',account_id,'lists'
And header Content-Type = 'application/json'
And param page = 0
When method get
Then match [200, 201, 204] contains responseStatus
Then def lr1 = karate.filter(response, x => { return x.id == list_id } )
Then match lr1[0] contains { id: #(list_id), name: #(list_name), tasks: #notnull }
Then def r = karate.filter(lr1[0].tasks, x => { return x.id == task_id } )
Then match r[0] contains { id: #(task_id), name: #(task_name), description: #(task_description) }
Then def r = karate.filter(lr1[0].tasks, x => { return x.id == task_id_2 } )
Then match r[0] contains { id: #(task_id_2), name: #(task_name_2), description: #(task_description_2)}
Then def lr2 = karate.filter(response, x => { return x.id == list_id_2 } )
Then match lr2[0] contains { id: #(list_id_2), name: #(list_name_2), tasks: #notnull }
Then def r = karate.filter(lr2[0].tasks, x => { return x.id == task_id_1_2 } )
Then match r[0] contains { id: #(task_id_1_2), name: #(task_name), description: #(task_description)}
# Check stats
Given path 'api/stats'
And header Content-Type = 'application/json'
When method get
Then match [200, 201, 204] contains responseStatus
Then def sub_result = karate.filter(response, x => { return x.account_id == account_id } )
Then match sub_result[0] contains { account_id: #(account_id), account_login: #(account_name), list_count:2, task_avg:1.5 }