Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class Result {
@SerializedName("variations_map")
private Object variationsMap;

@SerializedName("is_slotted")
private boolean isSlotted;

@SerializedName("labels")
private Map<String, Object> labels;

Expand Down Expand Up @@ -77,6 +80,13 @@ public Map<String, String> getStrategy() {
return strategy;
}

/**
* @return isSlotted boolean
*/
public boolean getIsSlotted() {
return isSlotted;
}

public void setValue(String value) {
this.value = value;
}
Expand Down Expand Up @@ -104,4 +114,8 @@ public void setLabels(Map<String, Object> labels) {
public void setStrategy(Map<String, String> strategy) {
this.strategy = strategy;
}

public void setIsSlotted(boolean isSlotted) {
this.isSlotted = isSlotted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,18 @@ public void createBrowseResponseShouldReturnAResultWithLabels() throws Exception
.get("display_name"),
"New Arrival");
}

@Test
public void createBrowseResponseShouldReturnAResultWithIsSlotted() throws Exception {
String string = Utils.getTestResource("response.browse.color.blue.json");
BrowseResponse response = ConstructorIO.createBrowseResponse(string);
assertEquals(
"search result [labels] exists",
response.getResponse().getResults().get(0).getIsSlotted(),
true);
assertEquals(
"search result [labels] exists",
response.getResponse().getResults().get(1).getIsSlotted(),
false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void autocompleteShouldReturnAResultWithOneFilter() throws Exception {
public void autocompleteShouldReturnAResultWithMultipleFilters() throws Exception {
ConstructorIO constructor = new ConstructorIO("", apiKey, true, null);
UserInfo userInfo = new UserInfo(3, "c62a-2a09-faie");
AutocompleteRequest request = new AutocompleteRequest("item1");
AutocompleteRequest request = new AutocompleteRequest("item2");
request.getFilters().put("group_id", Arrays.asList("All"));
request.getFilters().put("Brand", Arrays.asList("XYZ"));
AutocompleteResponse response = constructor.autocomplete(request, userInfo);
Expand Down Expand Up @@ -224,7 +224,8 @@ public void AutocompleteShouldReturnAResultProvidedVariationsMapAsArray() throws
variationsMap.addValueRule(
"size", VariationsMap.AggregationTypes.first, "data.facets.size");
variationsMap.setFilterBy(
"{\"and\":[{\"not\":{\"field\":\"data.brand\",\"value\":\"Best Brand\"}}]}");
"{\"and\":[{\"not\":{\"field\":\"data.brand\",\"type\":\"single\",\"value\":\"Best"
+ " Brand\"},\"type\":\"not\"}],\"type\":\"and\"}");
request.setVariationsMap(variationsMap);
AutocompleteResponse response = constructor.autocomplete(request, userInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ public void BrowseShouldReturnAResultProvidedVariationsMapAsArray() throws Excep
variationsMap.addValueRule(
"size", VariationsMap.AggregationTypes.first, "data.facets.size");
variationsMap.setFilterBy(
"{\"and\":[{\"not\":{\"field\":\"data.brand\",\"value\":\"Best Brand\"}}]}");
"{\"and\":[{\"not\":{\"field\":\"data.brand\",\"type\":\"single\",\"value\":\"Best"
+ " Brand\"},\"type\":\"not\"}],\"type\":\"and\"}");
request.setVariationsMap(variationsMap);
BrowseResponse response = constructor.browse(request, userInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void SearchShouldReturnAResultWithGroupId() throws Exception {
public void SearchShouldReturnAResultWithColorFacets() throws Exception {
ConstructorIO constructor = new ConstructorIO("", apiKey, true, null);
UserInfo userInfo = new UserInfo(3, "c62a-2a09-faie");
SearchRequest request = new SearchRequest("item1");
request.getFacets().put("Color", Arrays.asList("Blue"));
SearchRequest request = new SearchRequest("item2");
request.getFacets().put("Color", Arrays.asList("yellow"));
SearchResponse response = constructor.search(request, userInfo);
assertEquals("search results exist", response.getResponse().getResults().size(), 1);
assertEquals(
Expand Down Expand Up @@ -359,7 +359,8 @@ public void SearchShouldReturnAResultProvidedVariationsMapAsArray() throws Excep
variationsMap.addValueRule(
"size", VariationsMap.AggregationTypes.first, "data.facets.size");
variationsMap.setFilterBy(
"{\"and\":[{\"not\":{\"field\":\"data.brand\",\"value\":\"Best Brand\"}}]}");
"{\"and\":[{\"not\":{\"field\":\"data.brand\",\"type\":\"single\",\"value\":\"Best"
+ " Brand\"},\"type\":\"not\"}],\"type\":\"and\"}");
System.out.println(variationsMap.getFilterBy());
request.setVariationsMap(variationsMap);
SearchResponse response = constructor.search(request, userInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void hierarchicalFacet() throws Exception {
assertEquals(facet.getName(), "Size");
assertEquals(facet.getType(), "hierarchical");
assertEquals(facet.getOptions().get(0).getValue(), "Mens");
assertEquals(facet.getOptions().get(0).getOptions().get(0), "Mens/Small");
assertEquals(facet.getOptions().get(0).getOptions().get(0).getValue(), "Mens/Small");
assertNull(facet.getMax());
assertNull(facet.getMin());
assertNull(facet.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,18 @@ public void createSearchResponseShouldReturnAResultWithLabels() throws Exception
.get("display_name"),
"New Arrival");
}

@Test
public void createSearchResponseShouldReturnAResultWithIsSlotted() throws Exception {
String string = Utils.getTestResource("response.search.item.json");
SearchResponse response = ConstructorIO.createSearchResponse(string);
assertEquals(
"search result [isSlotted] exists",
response.getResponse().getResults().get(0).getIsSlotted(),
true);
assertEquals(
"search result [isSlotted] exists",
response.getResponse().getResults().get(1).getIsSlotted(),
false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@
"url": "https://demo.commercetools.com/en/aspesi-coat-I502997385098-blue.html",
"variation_id": "M0E20000000ECTT"
},
"is_slotted": false,
"is_slotted": true,
"matched_terms": [],
"value": "Coat Aspesi blue",
"variations": [{
Expand Down
Loading