Skip to content

Commit 1b63e6f

Browse files
committed
update metadata and external injection tests
1 parent 77f5326 commit 1b63e6f

File tree

3 files changed

+361
-2
lines changed

3 files changed

+361
-2
lines changed

tests/CTS/requests/composition-full/putComposition.json

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
}
6363
}
6464
},
65+
6566
{
6667
"parameters": {
6768
"compositionID": "my-external-injection-compo",
@@ -132,5 +133,155 @@
132133
}
133134
}
134135
}
136+
},
137+
138+
{
139+
"parameters": {
140+
"compositionID": "my-metadata-compo",
141+
"composition": {
142+
"objectID": "my-metadata-compo",
143+
"name": "my composition",
144+
"behavior": {
145+
"injection": {
146+
"main": {
147+
"source": {
148+
"search": {
149+
"index": "foo",
150+
"params": { "filters": "brand:adidas" }
151+
}
152+
}
153+
},
154+
"injectedItems": [
155+
{
156+
"key": "injectedItem1",
157+
"source": {
158+
"search": {
159+
"index": "foo",
160+
"params": {
161+
"filters": "brand:adidas"
162+
}
163+
}
164+
},
165+
"position": 2,
166+
"length": 1,
167+
"metadata": {
168+
"hits": {
169+
"addItemKey": true,
170+
"extra": {
171+
"my-string": "string",
172+
"my-bool": true,
173+
"my-number": 42,
174+
"my-object": { "sub-key": "sub-value" },
175+
"my-array": [1, 2, 3],
176+
"my-empty-object": {}
177+
}
178+
}
179+
}
180+
},
181+
{
182+
"key": "externalItem",
183+
"source": {
184+
"search": {
185+
"index": "foo",
186+
"params": {
187+
"filters": "brand:puma"
188+
}
189+
}
190+
},
191+
"position": 5,
192+
"length": 5,
193+
"metadata": {
194+
"hits": {
195+
"addItemKey": true,
196+
"extra": {
197+
"my-string": "string",
198+
"my-bool": true,
199+
"my-number": 42,
200+
"my-object": { "sub-key": "sub-value" },
201+
"my-array": [1, 2, 3],
202+
"my-empty-object": {}
203+
}
204+
}
205+
}
206+
}
207+
]
208+
}
209+
}
210+
}
211+
},
212+
"request": {
213+
"path": "/1/compositions/my-metadata-compo",
214+
"method": "PUT",
215+
"body": {
216+
"objectID": "my-metadata-compo",
217+
"name": "my composition",
218+
"behavior": {
219+
"injection": {
220+
"main": {
221+
"source": {
222+
"search": {
223+
"index": "foo",
224+
"params": { "filters": "brand:adidas" }
225+
}
226+
}
227+
},
228+
"injectedItems": [
229+
{
230+
"key": "injectedItem1",
231+
"source": {
232+
"search": {
233+
"index": "foo",
234+
"params": {
235+
"filters": "brand:adidas"
236+
}
237+
}
238+
},
239+
"position": 2,
240+
"length": 1,
241+
"metadata": {
242+
"hits": {
243+
"addItemKey": true,
244+
"extra": {
245+
"my-string": "string",
246+
"my-bool": true,
247+
"my-number": 42,
248+
"my-object": { "sub-key": "sub-value" },
249+
"my-array": [1, 2, 3],
250+
"my-empty-object": {}
251+
}
252+
}
253+
}
254+
},
255+
{
256+
"key": "externalItem",
257+
"source": {
258+
"search": {
259+
"index": "foo",
260+
"params": {
261+
"filters": "brand:puma"
262+
}
263+
}
264+
},
265+
"position": 5,
266+
"length": 5,
267+
"metadata": {
268+
"hits": {
269+
"addItemKey": true,
270+
"extra": {
271+
"my-string": "string",
272+
"my-bool": true,
273+
"my-number": 42,
274+
"my-object": { "sub-key": "sub-value" },
275+
"my-array": [1, 2, 3],
276+
"my-empty-object": {}
277+
}
278+
}
279+
}
280+
}
281+
]
282+
}
283+
}
284+
}
285+
}
135286
}
136287
]

tests/CTS/requests/composition-full/putCompositionRule.json

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,203 @@
7676
}
7777
}
7878
}
79+
},
80+
81+
{
82+
"parameters": {
83+
"compositionID": "compositionID",
84+
"objectID": "ruleID",
85+
"compositionRule": {
86+
"objectID": "ruleID",
87+
"conditions": [
88+
{
89+
"anchoring": "is",
90+
"pattern": "test"
91+
}
92+
],
93+
"consequence": {
94+
"behavior": {
95+
"injection": {
96+
"main": {
97+
"source": {
98+
"search": {
99+
"index": "foo"
100+
}
101+
}
102+
},
103+
"injectedItems": [
104+
{
105+
"key": "injectedItem1",
106+
"source": {
107+
"search": {
108+
"index": "foo",
109+
"params": {
110+
"filters": "brand:adidas"
111+
}
112+
}
113+
},
114+
"position": 2,
115+
"length": 1,
116+
"metadata": {
117+
"hits": {
118+
"addItemKey": true,
119+
"extra": {
120+
"my-string": "string",
121+
"my-bool": true,
122+
"my-number": 42,
123+
"my-object": { "sub-key": "sub-value" },
124+
"my-array": [1, 2, 3],
125+
"my-empty-object": {}
126+
}
127+
}
128+
}
129+
}
130+
]
131+
}
132+
}
133+
}
134+
}
135+
},
136+
"request": {
137+
"path": "/1/compositions/compositionID/rules/ruleID",
138+
"method": "PUT",
139+
"body": {
140+
"objectID": "ruleID",
141+
"conditions": [
142+
{
143+
"anchoring": "is",
144+
"pattern": "test"
145+
}
146+
],
147+
"consequence": {
148+
"behavior": {
149+
"injection": {
150+
"main": {
151+
"source": {
152+
"search": {
153+
"index": "foo"
154+
}
155+
}
156+
},
157+
"injectedItems": [
158+
{
159+
"key": "injectedItem1",
160+
"source": {
161+
"search": {
162+
"index": "foo",
163+
"params": {
164+
"filters": "brand:adidas"
165+
}
166+
}
167+
},
168+
"position": 2,
169+
"length": 1,
170+
"metadata": {
171+
"hits": {
172+
"addItemKey": true,
173+
"extra": {
174+
"my-string": "string",
175+
"my-bool": true,
176+
"my-number": 42,
177+
"my-object": { "sub-key": "sub-value" },
178+
"my-array": [1, 2, 3],
179+
"my-empty-object": {}
180+
}
181+
}
182+
}
183+
}
184+
]
185+
}
186+
}
187+
}
188+
}
189+
}
190+
},
191+
192+
{
193+
"parameters": {
194+
"compositionID": "compositionID",
195+
"objectID": "ruleID",
196+
"compositionRule": {
197+
"objectID": "ruleID",
198+
"description": "my description",
199+
"tags": ["tag1", "tag2"],
200+
"enabled": true,
201+
"validity": [{ "from": 1704063600, "until": 1704083600 }],
202+
"conditions": [
203+
{ "anchoring": "contains", "pattern": "harry" },
204+
{ "anchoring": "contains", "pattern": "potter" }
205+
],
206+
"consequence": {
207+
"behavior": {
208+
"injection": {
209+
"main": {
210+
"source": {
211+
"search": {
212+
"index": "my-index",
213+
"params": { "filters": "brand:adidas" }
214+
}
215+
}
216+
},
217+
"injectedItems": [
218+
{
219+
"key": "injectedItem",
220+
"source": {
221+
"search": {
222+
"index": "my-index",
223+
"params": { "filters": "brand:adidas" }
224+
}
225+
},
226+
"position": 0,
227+
"length": 3
228+
}
229+
]
230+
}
231+
}
232+
}
233+
}
234+
},
235+
"request": {
236+
"path": "/1/compositions/compositionID/rules/ruleID",
237+
"method": "PUT",
238+
"body": {
239+
"objectID": "ruleID",
240+
"description": "my description",
241+
"tags": ["tag1", "tag2"],
242+
"enabled": true,
243+
"validity": [{ "from": 1704063600, "until": 1704083600 }],
244+
"conditions": [
245+
{ "anchoring": "contains", "pattern": "harry" },
246+
{ "anchoring": "contains", "pattern": "potter" }
247+
],
248+
"consequence": {
249+
"behavior": {
250+
"injection": {
251+
"main": {
252+
"source": {
253+
"search": {
254+
"index": "my-index",
255+
"params": { "filters": "brand:adidas" }
256+
}
257+
}
258+
},
259+
"injectedItems": [
260+
{
261+
"key": "injectedItem",
262+
"source": {
263+
"search": {
264+
"index": "my-index",
265+
"params": { "filters": "brand:adidas" }
266+
}
267+
},
268+
"position": 0,
269+
"length": 3
270+
}
271+
]
272+
}
273+
}
274+
}
275+
}
276+
}
79277
}
80278
]

tests/CTS/requests/composition-full/search.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
{
3030
"objectID": "my-object-2",
3131
"metadata": {
32-
"my-key": "my-value"
32+
"my-string": "string",
33+
"my-bool": true,
34+
"my-number": 42,
35+
"my-object": { "sub-key": "sub-value" },
36+
"my-array": [1, 2, 3],
37+
"my-empty-object": {}
3338
}
3439
}
3540
]
@@ -53,7 +58,12 @@
5358
{
5459
"objectID": "my-object-2",
5560
"metadata": {
56-
"my-key": "my-value"
61+
"my-string": "string",
62+
"my-bool": true,
63+
"my-number": 42,
64+
"my-object": { "sub-key": "sub-value" },
65+
"my-array": [1, 2, 3],
66+
"my-empty-object": {}
5767
}
5868
}
5969
]

0 commit comments

Comments
 (0)