Skip to content

Commit f065e8c

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

File tree

3 files changed

+369
-2
lines changed

3 files changed

+369
-2
lines changed

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

Lines changed: 155 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,159 @@
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-null": null,
177+
"my-empty-object": {}
178+
}
179+
}
180+
}
181+
},
182+
{
183+
"key": "externalItem",
184+
"source": {
185+
"search": {
186+
"index": "foo",
187+
"params": {
188+
"filters": "brand:puma"
189+
}
190+
}
191+
},
192+
"position": 5,
193+
"length": 5,
194+
"metadata": {
195+
"hits": {
196+
"addItemKey": true,
197+
"extra": {
198+
"my-string": "string",
199+
"my-bool": true,
200+
"my-number": 42,
201+
"my-object": { "sub-key": "sub-value" },
202+
"my-array": [1, 2, 3],
203+
"my-null": null,
204+
"my-empty-object": {}
205+
}
206+
}
207+
}
208+
}
209+
]
210+
}
211+
}
212+
}
213+
},
214+
"request": {
215+
"path": "/1/compositions/my-metadata-compo",
216+
"method": "PUT",
217+
"body": {
218+
"objectID": "my-metadata-compo",
219+
"name": "my composition",
220+
"behavior": {
221+
"injection": {
222+
"main": {
223+
"source": {
224+
"search": {
225+
"index": "foo",
226+
"params": { "filters": "brand:adidas" }
227+
}
228+
}
229+
},
230+
"injectedItems": [
231+
{
232+
"key": "injectedItem1",
233+
"source": {
234+
"search": {
235+
"index": "foo",
236+
"params": {
237+
"filters": "brand:adidas"
238+
}
239+
}
240+
},
241+
"position": 2,
242+
"length": 1,
243+
"metadata": {
244+
"hits": {
245+
"addItemKey": true,
246+
"extra": {
247+
"my-string": "string",
248+
"my-bool": true,
249+
"my-number": 42,
250+
"my-object": { "sub-key": "sub-value" },
251+
"my-array": [1, 2, 3],
252+
"my-null": null,
253+
"my-empty-object": {}
254+
}
255+
}
256+
}
257+
},
258+
{
259+
"key": "externalItem",
260+
"source": {
261+
"search": {
262+
"index": "foo",
263+
"params": {
264+
"filters": "brand:puma"
265+
}
266+
}
267+
},
268+
"position": 5,
269+
"length": 5,
270+
"metadata": {
271+
"hits": {
272+
"addItemKey": true,
273+
"extra": {
274+
"my-string": "string",
275+
"my-bool": true,
276+
"my-number": 42,
277+
"my-object": { "sub-key": "sub-value" },
278+
"my-array": [1, 2, 3],
279+
"my-null": null,
280+
"my-empty-object": {}
281+
}
282+
}
283+
}
284+
}
285+
]
286+
}
287+
}
288+
}
289+
}
135290
}
136291
]

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

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,205 @@
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-null": null,
126+
"my-empty-object": {}
127+
}
128+
}
129+
}
130+
}
131+
]
132+
}
133+
}
134+
}
135+
}
136+
},
137+
"request": {
138+
"path": "/1/compositions/compositionID/rules/ruleID",
139+
"method": "PUT",
140+
"body": {
141+
"objectID": "ruleID",
142+
"conditions": [
143+
{
144+
"anchoring": "is",
145+
"pattern": "test"
146+
}
147+
],
148+
"consequence": {
149+
"behavior": {
150+
"injection": {
151+
"main": {
152+
"source": {
153+
"search": {
154+
"index": "foo"
155+
}
156+
}
157+
},
158+
"injectedItems": [
159+
{
160+
"key": "injectedItem1",
161+
"source": {
162+
"search": {
163+
"index": "foo",
164+
"params": {
165+
"filters": "brand:adidas"
166+
}
167+
}
168+
},
169+
"position": 2,
170+
"length": 1,
171+
"metadata": {
172+
"hits": {
173+
"addItemKey": true,
174+
"extra": {
175+
"my-string": "string",
176+
"my-bool": true,
177+
"my-number": 42,
178+
"my-object": { "sub-key": "sub-value" },
179+
"my-array": [1, 2, 3],
180+
"my-null": null,
181+
"my-empty-object": {}
182+
}
183+
}
184+
}
185+
}
186+
]
187+
}
188+
}
189+
}
190+
}
191+
}
192+
},
193+
194+
{
195+
"parameters": {
196+
"compositionID": "compositionID",
197+
"objectID": "ruleID",
198+
"compositionRule": {
199+
"objectID": "ruleID",
200+
"description": "my description",
201+
"tags": ["tag1", "tag2"],
202+
"enabled": true,
203+
"validity": [{ "from": 1704063600, "until": 1704083600 }],
204+
"conditions": [
205+
{ "anchoring": "contains", "pattern": "harry" },
206+
{ "anchoring": "contains", "pattern": "potter" }
207+
],
208+
"consequence": {
209+
"behavior": {
210+
"injection": {
211+
"main": {
212+
"source": {
213+
"search": {
214+
"index": "my-index",
215+
"params": { "filters": "brand:adidas" }
216+
}
217+
}
218+
},
219+
"injectedItems": [
220+
{
221+
"key": "injectedItem",
222+
"source": {
223+
"search": {
224+
"index": "my-index",
225+
"params": { "filters": "brand:adidas" }
226+
}
227+
},
228+
"position": 0,
229+
"length": 3
230+
}
231+
]
232+
}
233+
}
234+
}
235+
}
236+
},
237+
"request": {
238+
"path": "/1/compositions/compositionID/rules/ruleID",
239+
"method": "PUT",
240+
"body": {
241+
"objectID": "ruleID",
242+
"description": "my description",
243+
"tags": ["tag1", "tag2"],
244+
"enabled": true,
245+
"validity": [{ "from": 1704063600, "until": 1704083600 }],
246+
"conditions": [
247+
{ "anchoring": "contains", "pattern": "harry" },
248+
{ "anchoring": "contains", "pattern": "potter" }
249+
],
250+
"consequence": {
251+
"behavior": {
252+
"injection": {
253+
"main": {
254+
"source": {
255+
"search": {
256+
"index": "my-index",
257+
"params": { "filters": "brand:adidas" }
258+
}
259+
}
260+
},
261+
"injectedItems": [
262+
{
263+
"key": "injectedItem",
264+
"source": {
265+
"search": {
266+
"index": "my-index",
267+
"params": { "filters": "brand:adidas" }
268+
}
269+
},
270+
"position": 0,
271+
"length": 3
272+
}
273+
]
274+
}
275+
}
276+
}
277+
}
278+
}
79279
}
80280
]

0 commit comments

Comments
 (0)