Skip to content
Open
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
@@ -0,0 +1,75 @@
package io.constructor.client.models;

import com.google.gson.annotations.SerializedName;

/** Constructor.io Related Browse Page - uses Gson/Reflection to load data in */
public class RelatedBrowsePage {

@SerializedName("filter_name")
private String filterName;

@SerializedName("filter_value")
private String filterValue;

@SerializedName("display_name")
private String displayName;

@SerializedName("image_url")
private String imageUrl;

/**
* @return the filter name
*/
public String getFilterName() {
return filterName;
}

/**
* @return the filter value
*/
public String getFilterValue() {
return filterValue;
}

/**
* @return the display name
*/
public String getDisplayName() {
return displayName;
}

/**
* @return the image URL
*/
public String getImageUrl() {
return imageUrl;
}

/**
* @param filterName the filter name to set
*/
public void setFilterName(String filterName) {
this.filterName = filterName;
}

/**
* @param filterValue the filter value to set
*/
public void setFilterValue(String filterValue) {
this.filterValue = filterValue;
}

/**
* @param displayName the display name to set
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}

/**
* @param imageUrl the image URL to set
*/
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.constructor.client.models;

import com.google.gson.annotations.SerializedName;

/** Constructor.io Related Search - uses Gson/Reflection to load data in */
public class RelatedSearch {

@SerializedName("query")
private String query;

/**
* @return the related search query
*/
public String getQuery() {
return query;
}

/**
* @param query the related search query to set
*/
public void setQuery(String query) {
this.query = query;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class SearchResponseInner extends BaseResultsResponse {
@SerializedName("features")
private List<Feature> features;

@SerializedName("related_searches")
private List<RelatedSearch> relatedSearches;

@SerializedName("related_browse_pages")
private List<RelatedBrowsePage> relatedBrowsePages;

/**
* @return redirect data
*/
Expand Down Expand Up @@ -47,4 +53,32 @@ public void setRefinedContent(List<RefinedContent> refinedContent) {
public void setFeatures(List<Feature> features) {
this.features = features;
}

/**
* @return list of related searches
*/
public List<RelatedSearch> getRelatedSearches() {
return relatedSearches;
}

/**
* @return list of related browse pages
*/
public List<RelatedBrowsePage> getRelatedBrowsePages() {
return relatedBrowsePages;
}

/**
* @param relatedSearches list of related searches to set
*/
public void setRelatedSearches(List<RelatedSearch> relatedSearches) {
this.relatedSearches = relatedSearches;
}

/**
* @param relatedBrowsePages list of related browse pages to set
*/
public void setRelatedBrowsePages(List<RelatedBrowsePage> relatedBrowsePages) {
this.relatedBrowsePages = relatedBrowsePages;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public void TaskRequestWithInvalidTokenShouldError() throws Exception {
TaskRequest request = new TaskRequest(String.valueOf(task_id));

thrown.expect(ConstructorException.class);
thrown.expectMessage(
"[HTTP 401] Invalid auth_token. If you've forgotten your token, you can generate a"
+ " new one at app.constructor.io/dashboard");
thrown.expectMessage(StringContains.containsString("[HTTP 401] Unauthorized"));
Task response = constructor.task(request);
}

Expand All @@ -89,9 +87,7 @@ public void TaskAsJSONRequestWithInvalidTokenShouldError() throws Exception {
TaskRequest request = new TaskRequest(String.valueOf(task_id));

thrown.expect(ConstructorException.class);
thrown.expectMessage(
"[HTTP 401] Invalid auth_token. If you've forgotten your token, you can generate a"
+ " new one at app.constructor.io/dashboard");
thrown.expectMessage(StringContains.containsString("[HTTP 401] Unauthorized"));
String response = constructor.taskAsJson(request);
}

Expand All @@ -103,7 +99,7 @@ public void TaskRequestWithInvalidApiKeyShouldError() throws Exception {
thrown.expect(ConstructorException.class);
thrown.expectMessage(
StringContains.containsString(
"[HTTP 401] You have supplied an invalid `key` or `autocomplete_key`."));
"[HTTP 400] You have supplied an invalid `key` or `autocomplete_key`."));
Task response = constructor.task(request);
}

Expand All @@ -115,7 +111,7 @@ public void TaskAsJSONRequestWithInvalidApiKeyShouldError() throws Exception {
thrown.expect(ConstructorException.class);
thrown.expectMessage(
StringContains.containsString(
"[HTTP 401] You have supplied an invalid `key` or `autocomplete_key`."));
"[HTTP 400] You have supplied an invalid `key` or `autocomplete_key`."));
String response = constructor.taskAsJson(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void AllTasksShouldReturnErrorWithInvalidApiKey() throws Exception {

thrown.expect(ConstructorException.class);
thrown.expectMessage(
"[HTTP 401] You have supplied an invalid `key` or `autocomplete_key`. You can find"
"[HTTP 400] You have supplied an invalid `key` or `autocomplete_key`. You can find"
+ " your key at app.constructor.io/dashboard/accounts/api_integration.");
AllTasksResponse response = constructor.allTasks(request);
}
Expand All @@ -218,9 +218,7 @@ public void AllTasksShouldReturnErrorWithInvalidApiToken() throws Exception {
AllTasksRequest request = new AllTasksRequest();

thrown.expect(ConstructorException.class);
thrown.expectMessage(
"[HTTP 401] Invalid auth_token. If you've forgotten your token, you can generate a"
+ " new one at app.constructor.io/dashboard");
thrown.expectMessage(StringContains.containsString("[HTTP 401] Unauthorized"));
AllTasksResponse response = constructor.allTasks(request);
}

Expand All @@ -232,7 +230,7 @@ public void AllTasksAsJSONShouldReturnErrorWithInvalidApiKey() throws Exception
thrown.expect(ConstructorException.class);
thrown.expectMessage(
StringContains.containsString(
"[HTTP 401] You have supplied an invalid `key` or `autocomplete_key`."));
"[HTTP 400] You have supplied an invalid `key` or `autocomplete_key`."));
String response = constructor.allTasksAsJson(request);
}

Expand All @@ -242,9 +240,7 @@ public void AllTasksAsJSONShouldReturnErrorWithInvalidApiToken() throws Exceptio
AllTasksRequest request = new AllTasksRequest();

thrown.expect(ConstructorException.class);
thrown.expectMessage(
"[HTTP 401] Invalid auth_token. If you've forgotten your token, you can generate a"
+ " new one at app.constructor.io/dashboard");
thrown.expectMessage(StringContains.containsString("[HTTP 401] Unauthorized"));
String response = constructor.allTasksAsJson(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,64 @@ public void createSearchResponseShouldReturnAResultWithVariationSlice() throws E
.get(0),
"801764002");
}

@Test
public void createSearchResponseShouldReturnAResultWithRelatedSearches() throws Exception {
String string = Utils.getTestResource("response.search.item.json");
SearchResponse response = ConstructorIO.createSearchResponse(string);
assertEquals(
"search result [related searches] exists",
response.getResponse().getRelatedSearches().size(),
2);
assertEquals(
"search result related search [query] exists",
response.getResponse().getRelatedSearches().get(0).getQuery(),
"related item search");
assertEquals(
"search result related search [query] second item exists",
response.getResponse().getRelatedSearches().get(1).getQuery(),
"similar products");
}

@Test
public void createSearchResponseShouldReturnAResultWithRelatedBrowsePages() throws Exception {
String string = Utils.getTestResource("response.search.item.json");
SearchResponse response = ConstructorIO.createSearchResponse(string);
assertEquals(
"search result [related browse pages] exists",
response.getResponse().getRelatedBrowsePages().size(),
2);
assertEquals(
"search result related browse page [filter name] exists",
response.getResponse().getRelatedBrowsePages().get(0).getFilterName(),
"group_id");
assertEquals(
"search result related browse page [filter value] exists",
response.getResponse().getRelatedBrowsePages().get(0).getFilterValue(),
"electronics");
assertEquals(
"search result related browse page [display name] exists",
response.getResponse().getRelatedBrowsePages().get(0).getDisplayName(),
"Electronics");
assertEquals(
"search result related browse page [image url] exists",
response.getResponse().getRelatedBrowsePages().get(0).getImageUrl(),
"https://example.com/electronics.jpg");
assertEquals(
"search result related browse page [filter name] exists",
response.getResponse().getRelatedBrowsePages().get(1).getFilterName(),
"Brand");
assertEquals(
"search result related browse page [filter value] exists",
response.getResponse().getRelatedBrowsePages().get(1).getFilterValue(),
"sample_brand");
assertEquals(
"search result related browse page [display name] exists",
response.getResponse().getRelatedBrowsePages().get(1).getDisplayName(),
"Sample Brand Products");
assertEquals(
"search result related browse page [image url] exists",
response.getResponse().getRelatedBrowsePages().get(1).getImageUrl(),
"https://example.com/sample_brand.jpg");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,29 @@
"name": "query_items_ctr_and_l2r",
"display_name": "CTR & LTR"
}
}]
}],
"related_searches": [
{
"query": "related item search"
},
{
"query": "similar products"
}
],
"related_browse_pages": [
{
"filter_name": "group_id",
"filter_value": "electronics",
"display_name": "Electronics",
"image_url": "https://example.com/electronics.jpg"
},
{
"filter_name": "Brand",
"filter_value": "sample_brand",
"display_name": "Sample Brand Products",
"image_url": "https://example.com/sample_brand.jpg"
}
]
},
"result_id": "7938b9e8-369b-4f0c-ae74-69b85dcb5b12",
"request": {
Expand Down
Loading