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
@@ -1,6 +1,8 @@
package io.constructor.client.models;

import com.google.gson.annotations.SerializedName;

import java.util.List;
import java.util.Map;

/** Constructor.io Filter Facet Option ... uses Gson/Reflection to load data in */
Expand All @@ -24,6 +26,9 @@ public class FilterFacetOption {
@SerializedName("range")
private Object[] range; // Array to hold two values of either Number or "inf", "-inf"

@SerializedName("options")
private List<FilterFacetOption> options;

/**
* @return the counts
*/
Expand Down Expand Up @@ -66,6 +71,13 @@ public Object[] getRange() {
return range;
}

/**
* @return the options
*/
public List<FilterFacetOption> getOptions() {
return options;
}

public void setCount(Integer count) {
this.count = count;
}
Expand All @@ -89,4 +101,8 @@ public void setValue(String value) {
public void setRange(Object[] range) {
this.range = range;
}

public void setOptions(List<FilterFacetOption> options) {
this.options = options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public void rangeFacet() throws Exception {
assertEquals(facet.getStatus().size(), 0);
}

@Test
public void hierarchicalFacet() throws Exception {
String string = Utils.getTestResource("facet.hierarchical.json");
FilterFacet facet = new Gson().fromJson(string, FilterFacet.class);
assertEquals(facet.getDisplayName(), "Size");
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");
assertNull(facet.getMax());
assertNull(facet.getMin());
assertNull(facet.getStatus());
}

@Test
public void rangeFacetSelected() throws Exception {
String string = Utils.getTestResource("facet.range.selected.json");
Expand Down
39 changes: 39 additions & 0 deletions constructorio-client/src/test/resources/facet.hierarchical.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"display_name": "Size",
"name": "Size",
"options": [
{
"count": 5,
"data": {},
"display_name": "Mens",
"status": "",
"value": "Mens",
"options": [
{
"count": 5,
"data": {},
"display_name": "Small",
"status": "",
"value": "Mens/Small"
}
]
},
{
"count": 4,
"data": {},
"display_name": "Womens",
"status": "",
"value": "Womens",
"options": [
{
"count": 4,
"data": {},
"display_name": "Medium",
"status": "",
"value": "Womens/Medium"
}
]
}
],
"type": "hierarchical"
}
Loading