8000 Update cesql TCK tests (#603) · touchkey/sdk-java@62c55e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 62c55e7

Browse files
Cali0707vbhat6
authored andcommitted
Update cesql TCK tests (cloudevents#603)
Signed-off-by: Calum Murray <cmurray@redhat.com> Signed-off-by: vbhat6 <vinayas_bhat@intuit.com>
1 parent c92553c commit 62c55e7

File tree

4 files changed

+198
-6
lines changed

4 files changed

+198
-6
lines changed

sql/src/test/java/io/cloudevents/sql/TCKTestSuite.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public Stream<Map.Entry<String, TestCaseModel>> tckTestCases() {
115115
"parse_errors",
116116
"spec_examples",
117117
"string_builtin_functions",
118-
"sub_expression"
118+
"sub_expression",
119+
"subscriptions_api_recreations"
119120
).map(fileName -> "/tck/" + fileName + ".yaml");
120121

121122
return tckFiles

sql/src/test/resources/tck/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Each test definition includes:
1111

1212
* `name`: Name of the test case
1313
* `expression`: Expression to test.
14-
* `result`: Expected result (optional). Can be a boolean, an integer or a string.
15-
* `error`: Expected error (optional). If absent, no error is expected.
16-
* `event`: Input event (optional). If present, this is a valid event serialized in JSON format. If absent, when testing
14+
* `result`: Expected result (OPTIONAL). Can be a boolean, an integer or a string.
15+
* `error`: Expected error (OPTIONAL). If absent, no error is expected.
16+
* `event`: Input event (OPTIONAL). If present, this is a valid event serialized in JSON format. If absent, when testing
1717
the expression, any valid event can be passed.
18-
* `eventOverrides`: Overrides to the input event (optional). This might be used when `event` is missing, in order to
19-
define only some specific values, while the other (required) attributes can be any value.
18+
* `eventOverrides`: Overrides to the input event (OPTIONAL). This might be used when `event` is missing, in order to
19+
define only some specific values, while the other (REQUIRED) attributes can be any value.
2020

2121
The `error` values could be any of the following:
2222

sql/src/test/resources/tck/like_expression.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,26 @@ tests:
9393
eventOverrides:
9494
myext: "abc123123%456_dzf"
9595
result: false
96+
97+
- name: With type coercion from int (1)
98+
expression: "234 LIKE '23_'"
99+
result: true
100+
- name: With type coercion from int (2)
101+
expression: "2344 LIKE '23%'"
102+
result: true
103+
- name: With type coercion from int (3)
104+
expression: "2344 LIKE '23_'"
105+
result: false
106+
107+
- name: With type coercion from bool (1)
108+
expression: "TRUE LIKE 'tr%'"
109+
result: true
110+
- name: With type coercion from bool (2)
111+
expression: "TRUE LIKE '%ue'"
112+
result: true
113+
- name: With type coercion from bool (3)
114+
expression: "FALSE LIKE 'tr%'"
115+
result: false
116+
- name: With type coercion from bool (4)
117+
expression: "FALSE LIKE 'fal%'"
118+
result: true
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: SubscriptionsAPI Recreations
2+
tests:
3+
- name: Prefix filter (1)
4+
expression: "source LIKE 'https://%'"
5+
result: true
6+
eventOverrides:
7+
source: "https://example.com"
8+
- name: Prefix filter (2)
9+
expression: "source LIKE 'https://%'"
10+
result: false
11+
eventOverrides:
12+
source: "http://example.com"
13+
- name: Prefix filter on string extension
14+
expression: "myext LIKE 'custom%'"
15+
result: true
16+
eventOverrides:
17+
myext: "customext"
18+
- name: Prefix filter on missing string extension
19+
expression: "myext LIKE 'custom%'"
20+
error: missingAttribute
21+
22+
- name: Suffix filter (1)
23+
expression: "type like '%.error'"
24+
result: true
25+
eventOverrides:
26+
type: "com.github.error"
27+
- name: Suffix filter (2)
28+
expression: "type like '%.error'"
29+
result: false
30+
eventOverrides:
31+
type: "com.github.success"
32+
- name: Suffix filter on string extension
33+
expression: "myext LIKE '%ext'"
34+
result: true
35+
eventOverrides:
36+
myext: "customext"
37+
- name: Suffix filter on missing string extension
38+
expression: "myext LIKE '%ext'"
39+
error: missingAttribute
40+
41+
- name: Exact filter (1)
42+
expression: "id = 'myId'"
43+
result: true
44+
eventOverrides:
45+
id: "myId"
46+
- name: Exact filter (2)
47+
expression: "id = 'myId'"
48+
result: false
49+
eventOverrides:
50+
id: "notmyId"
51+
- name: Exact filter on string extension
52+
expression: "myext = 'customext'"
53+
result: true
54+
eventOverrides:
55+
myext: "customext"
56+
- name: Exact filter on missing string extension
57+
expression: "myext = 'customext'"
58+
error: missingAttribute
59+
60+
- name: Prefix filter AND Suffix filter (1)
61+
expression: "id LIKE 'my%' AND source LIKE '%.ca'"
62+
result: true
63+
eventOverrides:
64+
id: "myId"
65+
source: "http://www.some-website.ca"
66+
- name: Prefix filter AND Suffix filter (2)
67+
expression: "id LIKE 'my%' AND source LIKE '%.ca'"
68+
result: false
69+
eventOverrides:
70+
id: "myId"
71+
source: "http://www.some-website.com"
72+
- name: Prefix filter AND Suffix filter (3)
73+
expression: "myext LIKE 'custom%' AND type LIKE '%.error'"
74+
result: true
75+
eventOverrides:
76+
myext: "customext"
77+
type: "com.github.error"
78+
- name: Prefix AND Suffix filter (4)
79+
expression: "type LIKE 'example.%' AND myext LIKE 'custom%'"
80+
error: missingAttribute
81+
eventOverrides:
82+
type: "example.event.type"
83+
84+
- name: Prefix OR Suffix filter (1)
85+
expression: "id LIKE 'my%' OR source LIKE '%.ca'"
86+
result: true
87+
eventOverrides:
88+
id: "myId"
89+
source: "http://www.some-website.ca"
90+
- name: Prefix OR Suffix filter (2)
91+
expression: "id LIKE 'my%' OR source LIKE '%.ca'"
92+
result: true
93+
eventOverrides:
94+
id: "myId"
95+
source: "http://www.some-website.com"
96+
- name: Prefix OR Suffix filter (3)
97+
expression: "id LIKE 'my%' OR source LIKE '%.ca'"
98+
result: true
99+
eventOverrides:
100+
id: "notmyId"
101+
source: "http://www.some-website.ca"
102+
- name: Prefix OR Suffix filter (4)
103+
expression: "id LIKE 'my%' OR source LIKE '%.ca'"
104+
result: false
105+
eventOverrides:
106+
id: "notmyId"
107+
source: "http://www.some-website.com"
108+
109+
- name: Disjunctive Normal Form (1)
110+
expresion: "(id = 'myId' AND type LIKE '%.success') OR (id = 'notmyId' AND source LIKE 'http://%' AND type LIKE '%.warning')"
111+
result: true
112+
eventOverrides:
113+
id: "myId"
114+
type: "example.event.success"
115+
- name: Disjunctive Normal Form (2)
116+
expresion: "(id = 'myId' AND type LIKE '%.success') OR (id = 'notmyId' AND source LIKE 'http://%' AND type LIKE '%.warning')"
117+
result: true
118+
eventOverrides:
119+
id: "notmyId"
120+
type: "example.event.warning"
121+
source: "http://localhost.localdomain"
122+
- name: Disjunctive Normal Form (3)
123+
expresion: "(id = 'myId' AND type LIKE '%.success') OR (id = 'notmyId' AND source LIKE 'http://%' AND type LIKE '%.warning')"
124+
result: false
125+
eventOverrides:
126+
id: "notmyId"
127+
type: "example.event.warning"
128+
source: "https://localhost.localdomain"
129+
130+
- name: Conjunctive Normal Form (1)
131+
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning')"
132+
result: true
133+
eventOverrides:
134+
id: "myId"
135+
type: "example.event.warning"
136+
source: "http://localhost.localdomain"
137+
- name: Conjunctive Normal Form (2)
138+
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning')"
139+
result: true
140+
eventOverrides:
141+
id: "notmyId"
142+
type: "example.event.success"
143+
source: "http://localhost.localdomain"
144+
- name: Conjunctive Normal Form (3)
145+
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning')"
146+
result: false
147+
eventOverrides:
148+
id: "notmyId"
149+
type: "example.event.warning"
150+
source: "http://localhost.localdomain"
151+
- name: Conjunctive Normal Form (4)
152+
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning')"
153+
result: true
154+
eventOverrides:
155+
id: "myId"
156+
type: "example.event.success"
157+
source: "http://localhost.localdomain"
158+
- name: Conjunctive Normal Form (5)
159+
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning') AND (myext = 'customext')"
160+
error: missingAttribute
161+
eventOverrides:
162+
id: "myId"
163+
type: "example.event.success"
164+
source: "http://localhost.localdomain"
165+
166+
167+
168+

0 commit comments

Comments
 (0)
0