@@ -40,18 +40,27 @@ class RecommendTest extends AlgoliaTest {
4040 describe(" test recommend payload" ) {
4141
4242 it(" should produce valid recommendation query payload" ) {
43- (get recommendations RecommendationsQuery (
43+ val queryRelatedProducts = RecommendationsQuery (
44+ indexName = " products" ,
45+ model = " related-products" ,
46+ objectID = " B018APC4LE" ,
47+ maxRecommendations = Some (10 ),
48+ queryParameters = Some (Query (attributesToRetrieve = Some (Seq (" *" ))))
49+ )
50+ val queryBoughtTogether = RecommendationsQuery (
4451 indexName = " products" ,
4552 model = " bought-together" ,
4653 objectID = " B018APC4LE" ,
4754 maxRecommendations = Some (10 ),
4855 queryParameters = Some (Query (attributesToRetrieve = Some (Seq (" *" ))))
49- )).build() should be(
56+ )
57+ (get recommendations List (queryRelatedProducts, queryBoughtTogether))
58+ .build() should be(
5059 HttpPayload (
5160 POST ,
5261 Seq (" 1" , " indexes" , " *" , " recommendations" ),
5362 body = Some (
54- " {\" indexName\" :\" products\" ,\" model\" :\" bought-together\" ,\" objectID\" :\" B018APC4LE\" ,\" threshold\" :0,\" maxRecommendations\" :10,\" queryParameters\" :{\" attributesToRetrieve\" :[\" *\" ]}}"
63+ " {\" requests \" :[{ \" indexName\" :\" products\" ,\" model\" :\" related-products \" , \" objectID \" : \" B018APC4LE \" , \" threshold \" :0, \" maxRecommendations \" :10, \" queryParameters \" :{ \" attributesToRetrieve \" :[ \" * \" ]}},{ \" indexName \" : \" products \" , \" model \" : \" bought-together\" ,\" objectID\" :\" B018APC4LE\" ,\" threshold\" :0,\" maxRecommendations\" :10,\" queryParameters\" :{\" attributesToRetrieve\" :[\" *\" ]}}] }"
5564 ),
5665 isSearch = true ,
5766 requestOptions = None
@@ -60,18 +69,20 @@ class RecommendTest extends AlgoliaTest {
6069 }
6170
6271 it(" should produce valid related products query payload" ) {
63- (get relatedProducts RelatedProductsQuery (
64- indexName = " products" ,
65- objectID = " B018APC4LE" ,
66- threshold = 10 ,
67- maxRecommendations = Some (10 ),
68- queryParameters = Some (Query (attributesToRetrieve = Some (Seq (" *" ))))
72+ (get relatedProducts List (
73+ RelatedProductsQuery (
74+ indexName = " products" ,
75+ objectID = " B018APC4LE" ,
76+ threshold = 10 ,
77+ maxRecommendations = Some (10 ),
78+ queryParameters = Some (Query (attributesToRetrieve = Some (Seq (" *" ))))
79+ )
6980 )).build() should be(
7081 HttpPayload (
7182 POST ,
7283 Seq (" 1" , " indexes" , " *" , " recommendations" ),
7384 body = Some (
74- " {\" indexName\" :\" products\" ,\" objectID\" :\" B018APC4LE\" ,\" threshold\" :10,\" maxRecommendations\" :10,\" queryParameters\" :{\" attributesToRetrieve\" :[\" *\" ]},\" model\" :\" related-products\" }"
85+ " {\" requests \" :[{ \" indexName\" :\" products\" ,\" objectID\" :\" B018APC4LE\" ,\" threshold\" :10,\" maxRecommendations\" :10,\" queryParameters\" :{\" attributesToRetrieve\" :[\" *\" ]},\" model\" :\" related-products\" }] }"
7586 ),
7687 isSearch = true ,
7788 requestOptions = None
@@ -80,18 +91,20 @@ class RecommendTest extends AlgoliaTest {
8091 }
8192
8293 it(" should produce valid frequently bought together query payload" ) {
83- (get frequentlyBoughtTogether FrequentlyBoughtTogetherQuery (
84- indexName = " products" ,
85- objectID = " B018APC4LE" ,
86- threshold = 10 ,
87- maxRecommendations = Some (10 ),
88- queryParameters = Some (Query (attributesToRetrieve = Some (Seq (" *" ))))
94+ (get frequentlyBoughtTogether List (
95+ FrequentlyBoughtTogetherQuery (
96+ indexName = " products" ,
97+ objectID = " B018APC4LE" ,
98+ threshold = 10 ,
99+ maxRecommendations = Some (10 ),
100+ queryParameters = Some (Query (attributesToRetrieve = Some (Seq (" *" ))))
101+ )
89102 )).build() should be(
90103 HttpPayload (
91104 POST ,
92105 Seq (" 1" , " indexes" , " *" , " recommendations" ),
93106 body = Some (
94- " {\" indexName\" :\" products\" ,\" objectID\" :\" B018APC4LE\" ,\" threshold\" :10,\" maxRecommendations\" :10,\" queryParameters\" :{\" attributesToRetrieve\" :[\" *\" ]},\" model\" :\" bought-together\" }"
107+ " {\" requests \" :[{ \" indexName\" :\" products\" ,\" objectID\" :\" B018APC4LE\" ,\" threshold\" :10,\" maxRecommendations\" :10,\" queryParameters\" :{\" attributesToRetrieve\" :[\" *\" ]},\" model\" :\" bought-together\" }] }"
95108 ),
96109 isSearch = true ,
97110 requestOptions = None
0 commit comments