@Test public void testHttpError() throws Exception { Utils.setupHttpResponse("magento-graphql-error.json", httpClient, HttpStatus.SC_SERVICE_UNAVAILABLE); exceptionRule.expect(RuntimeException.class); exceptionRule.expectMessage("GraphQL query failed with response code 503"); dataService.execute("{dummy}", null); }
protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); } }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }  }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }  @Activate void activate(GraphqlDataServiceConfiguration conf); @Override ProductInterface getProductBySku(String sku, String storeView); @Override CategoryTree getCategoryById(Integer id, String storeView); @Override CategoryTree getCategoryByPath(String urlPath, String storeView); @Override List<ProductInterface> searchProducts(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override List<CategoryTree> searchCategories(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override CategoryProducts getCategoryProducts(Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override String getIdentifier(); }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }  @Activate void activate(GraphqlDataServiceConfiguration conf); @Override ProductInterface getProductBySku(String sku, String storeView); @Override CategoryTree getCategoryById(Integer id, String storeView); @Override CategoryTree getCategoryByPath(String urlPath, String storeView); @Override List<ProductInterface> searchProducts(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override List<CategoryTree> searchCategories(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override CategoryProducts getCategoryProducts(Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override String getIdentifier();  }