### Question:
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();  }### Answer:
@Test public void testMagentoError() throws Exception { Utils.setupHttpResponse("magento-graphql-error.json", httpClient, HttpStatus.SC_OK); GraphqlResponse<Query, Error> response = dataService.execute("{dummy}", null); assertEquals(1, response.getErrors().size()); Error error = response.getErrors().get(0); assertEquals("Cannot query field \"categoriess\" on type \"ProductInterface\".", error.getMessage()); assertEquals("graphql", error.getCategory()); assertEquals(1, error.getLocations().size()); Location location = error.getLocations().get(0); assertEquals(23, location.getLine().intValue()); assertEquals(9, location.getColumn().intValue()); }
@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); }
@Test public void testStoreCodeHeader() throws Exception { Utils.setupHttpResponse("magento-graphql-product.json", httpClient, HttpStatus.SC_OK); dataService.execute("{dummy}", STORE_CODE); List<Header> headers = Collections.singletonList(new BasicHeader(Constants.STORE_HEADER, STORE_CODE)); HeadersMatcher matcher = new HeadersMatcher(headers); Mockito.verify(httpClient, Mockito.times(1)).execute(Mockito.argThat(matcher)); }