@Test public void testQueryExtensions() throws Exception { setUp(RelationType.RELATED_PRODUCTS, "graphql/magento-graphql-relatedproducts-result.json", false); AbstractProductsRetriever retriever = relatedProducts.getProductsRetriever(); retriever.extendProductQueryWith(p -> p.description(d -> d.html())); retriever.extendVariantQueryWith(v -> v.sku()); MagentoGraphqlClient client = (MagentoGraphqlClient) Whitebox.getInternalState(retriever, "client"); MagentoGraphqlClient clientSpy = Mockito.spy(client); Whitebox.setInternalState(retriever, "client", clientSpy); assertProducts(); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(clientSpy, times(1)).execute(captor.capture()); String expectedQuery = "{products(filter:{sku:{eq:\"24-MG01\"}}){items{__typename,related_products{__typename,sku,name,thumbnail{label,url},url_key,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},... on ConfigurableProduct{price_range{maximum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}}},... on ConfigurableProduct{variants{product{sku}}},description{html}}}}}"; Assert.assertEquals(expectedQuery, captor.getValue()); }
@Override public AbstractProductsRetriever getProductsRetriever() { return productsRetriever; }
RelatedProductsImpl implements ProductCarousel { @Override public AbstractProductsRetriever getProductsRetriever() { return productsRetriever; } }
RelatedProductsImpl implements ProductCarousel { @Override public AbstractProductsRetriever getProductsRetriever() { return productsRetriever; }  }
RelatedProductsImpl implements ProductCarousel { @Override public AbstractProductsRetriever getProductsRetriever() { return productsRetriever; }  @Override boolean isConfigured(); @Override List<ProductListItem> getProducts(); @Override AbstractProductsRetriever getProductsRetriever(); @Override String getTitleType(); }
RelatedProductsImpl implements ProductCarousel { @Override public AbstractProductsRetriever getProductsRetriever() { return productsRetriever; }  @Override boolean isConfigured(); @Override List<ProductListItem> getProducts(); @Override AbstractProductsRetriever getProductsRetriever(); @Override String getTitleType();  }