Skip to content

Commit

Permalink
Extend the SearchBuilder to support selecting the DataType(s)
Browse files Browse the repository at this point in the history
Change-Id: I8d41a7e7cb0dd948b0ce699aaa04beb510d5dbc7
  • Loading branch information
msomhorst committed Nov 20, 2015
1 parent 8a8de84 commit 17b9802
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ class OpenApiClientIntegrationSpec extends Specification {
product.offerData.offers.size() >= 1
}

def 'Return products and categories'() {
def results = OpenApiClient.withDefaultClient(apiKey).searchBuilder()
.term('harry potter')
.dataType(QueryDataType.DataType.PRODUCTS)
.dataType(QueryDataType.DataType.CATEGORIES)
.search()

expect:
results.totalResultSize >= 1
results.products.size() > 0
results.categories.size() > 0
results.refinementGroups.size() == 0
}

def 'Return only refinements'() {
def results = OpenApiClient.withDefaultClient(apiKey).searchBuilder()
.term('harry potter')
.dataType(QueryDataType.DataType.REFINEMENTS)
.search()

expect:
results.totalResultSize >= 1
results.products.size() == 0
results.categories.size() == 0
results.refinementGroups.size() > 0
}

def 'Can find out if the OpenAPI is healthy'() {
def status = OpenApiClient.withDefaultClient(apiKey).getHealthStatus()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public SearchBuilder category(String id) {
return new SearchBuilder(this);
}

public SearchBuilder dataType(QueryDataType.DataType dataType) {
dataTypes.add(dataType);
return new SearchBuilder(this);
}

public SearchBuilder allOffers() {
offerTypes.add(ALL);
return new SearchBuilder(this);
Expand Down

0 comments on commit 17b9802

Please sign in to comment.