From 8a8de84da96ae16c1938f21918b853801f9af5a5 Mon Sep 17 00:00:00 2001 From: Maarten Somhorst Date: Fri, 20 Nov 2015 08:25:52 +0100 Subject: [PATCH 1/2] Update XSD with http://api.bol.com/openapi-4.0.0.xsd Change-Id: I16781834cb88b2b20511876666f1ff466ddba355 --- subprojects/schema/src/main/xsd/openapi-4.0.0.xsd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/schema/src/main/xsd/openapi-4.0.0.xsd b/subprojects/schema/src/main/xsd/openapi-4.0.0.xsd index e950ad4..9324867 100644 --- a/subprojects/schema/src/main/xsd/openapi-4.0.0.xsd +++ b/subprojects/schema/src/main/xsd/openapi-4.0.0.xsd @@ -75,6 +75,7 @@ + @@ -98,6 +99,7 @@ + @@ -131,6 +133,7 @@ + @@ -265,6 +268,7 @@ + From 17b9802517c040a7e147b2dbc5f86cf6795f65ac Mon Sep 17 00:00:00 2001 From: Maarten Somhorst Date: Fri, 20 Nov 2015 09:00:59 +0100 Subject: [PATCH 2/2] Extend the SearchBuilder to support selecting the DataType(s) Change-Id: I8d41a7e7cb0dd948b0ce699aaa04beb510d5dbc7 --- .../OpenApiClientIntegrationSpec.groovy | 27 +++++++++++++++++++ .../java/com/bol/openapi/SearchBuilder.java | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/subprojects/client/src/integrationTest/groovy/com/bol/openapi/OpenApiClientIntegrationSpec.groovy b/subprojects/client/src/integrationTest/groovy/com/bol/openapi/OpenApiClientIntegrationSpec.groovy index 5ec6252..071c45c 100644 --- a/subprojects/client/src/integrationTest/groovy/com/bol/openapi/OpenApiClientIntegrationSpec.groovy +++ b/subprojects/client/src/integrationTest/groovy/com/bol/openapi/OpenApiClientIntegrationSpec.groovy @@ -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() diff --git a/subprojects/client/src/main/java/com/bol/openapi/SearchBuilder.java b/subprojects/client/src/main/java/com/bol/openapi/SearchBuilder.java index b17d44d..21ce13a 100644 --- a/subprojects/client/src/main/java/com/bol/openapi/SearchBuilder.java +++ b/subprojects/client/src/main/java/com/bol/openapi/SearchBuilder.java @@ -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);