Java Code Examples for org.apache.sling.api.scripting.SlingBindings#put()
The following examples show how to use
org.apache.sling.api.scripting.SlingBindings#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphqlServletTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
@Test public void testProductCarouselModel() throws ServletException { Resource resource = prepareModel(PRODUCT_CAROUSEL_RESOURCE); String[] productSkuList = (String[]) resource.getValueMap().get("product"); // The HTL script uses an alias here SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.put("productSkuList", productSkuList); ProductCarousel productCarouselModel = context.request().adaptTo(ProductCarousel.class); Assert.assertEquals(4, productCarouselModel.getProducts().size()); Assert.assertEquals("24-MB02", productCarouselModel.getProducts().get(0).getSKU()); // We make sure that all assets in the sample JSON response point to the DAM for (ProductListItem product : productCarouselModel.getProducts()) { Assert.assertTrue(product.getImageURL().startsWith(CIF_DAM_ROOT)); } }
Example 2
Source File: ProductCollectionImplTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
@Before public void setUp() { context.currentResource(PRODUCT_COLLECTION); MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo(); requestPathInfo.setSelectorString("6"); // This sets the page attribute injected in the models with @Inject or @ScriptVariable Resource productCollectionResource = context.resourceResolver().getResource(PRODUCT_COLLECTION); SlingBindings slingBindings = getSlingBindings(PRODUCT_COLLECTION); XSSAPI xssApi = mock(XSSAPI.class); when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class)); slingBindings.put("xssApi", xssApi); Style style = mock(Style.class); when(style.get(Mockito.anyString(), Mockito.anyInt())).then(i -> i.getArgumentAt(1, Object.class)); slingBindings.put("currentStyle", style); SightlyWCMMode wcmMode = mock(SightlyWCMMode.class); when(wcmMode.isDisabled()).thenReturn(false); slingBindings.put("wcmmode", wcmMode); }
Example 3
Source File: ProductCarouselImplTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { Page page = context.currentPage(PAGE); context.currentResource(PRODUCTCAROUSEL); carouselResource = Mockito.spy(context.resourceResolver().getResource(PRODUCTCAROUSEL)); Query rootQuery = Utils.getQueryFromResource("graphql/magento-graphql-productcarousel-result.json"); products = rootQuery.getProducts().getItems(); GraphqlClient graphqlClient = Utils.setupGraphqlClientWithHttpResponseFrom("graphql/magento-graphql-productcarousel-result.json"); Mockito.when(carouselResource.adaptTo(ComponentsConfiguration.class)).thenReturn(MOCK_CONFIGURATION_OBJECT); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient") != null ? graphqlClient : null); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(carouselResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); productSkuArray = (String[]) carouselResource.getValueMap().get("product"); // The HTL script uses an alias here slingBindings.put("productSkuList", productSkuArray); productCarousel = context.request().adaptTo(ProductCarouselImpl.class); }
Example 4
Source File: ProductTeaserImplTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
public void setUp(String resourcePath, boolean deepLink) throws Exception { Page page = context.currentPage(PAGE); context.currentResource(resourcePath); teaserResource = Mockito.spy(context.resourceResolver().getResource(resourcePath)); Query rootQuery = Utils.getQueryFromResource("graphql/magento-graphql-productteaser-result.json"); product = rootQuery.getProducts().getItems().get(0); GraphqlClient graphqlClient = Utils.setupGraphqlClientWithHttpResponseFrom("graphql/magento-graphql-productteaser-result.json"); Mockito.when(teaserResource.adaptTo(ComponentsConfiguration.class)).thenReturn(MOCK_CONFIGURATION_OBJECT); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient", String.class) != null ? graphqlClient : null); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(teaserResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, teaserResource.getValueMap()); if (deepLink) { // Configure the component to create deep links to specific pages context.request().setAttribute(WCMMode.class.getName(), WCMMode.EDIT); } productTeaser = context.request().adaptTo(ProductTeaserImpl.class); }
Example 5
Source File: ProductTeaserImplTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
@Test public void verifyProductTeaserNoGraphqlCLient() { Page page = context.currentPage(PAGE); context.currentResource(PRODUCTTEASER_NOCLIENT); Resource teaserResource = Mockito.spy(context.resourceResolver().getResource(PRODUCTTEASER_NOCLIENT)); Mockito.when(teaserResource.adaptTo(GraphqlClient.class)).thenReturn(null); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(teaserResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, teaserResource.getValueMap()); ProductTeaserImpl productTeaserNoClient = context.request().adaptTo(ProductTeaserImpl.class); Assert.assertNull(productTeaserNoClient.getProductRetriever()); Assert.assertNull(productTeaserNoClient.getUrl()); }
Example 6
Source File: ProductTeaserImplTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
@Test public void testVirtualProduct() throws IOException { Page page = context.currentPage(PAGE); context.currentResource(PRODUCTTEASER_VIRTUAL); Resource teaserResource = Mockito.spy(context.resourceResolver().getResource(PRODUCTTEASER_VIRTUAL)); Mockito.when(teaserResource.adaptTo(ComponentsConfiguration.class)).thenReturn(MOCK_CONFIGURATION_OBJECT); GraphqlClient graphqlClient = Utils.setupGraphqlClientWithHttpResponseFrom("graphql/magento-graphql-virtualproduct-result.json"); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient", String.class) != null ? graphqlClient : null); SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(teaserResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, teaserResource.getValueMap()); productTeaser = context.request().adaptTo(ProductTeaserImpl.class); Assert.assertTrue(productTeaser.isVirtualProduct()); }
Example 7
Source File: CommerceTeaserImplTest.java From aem-core-cif-components with Apache License 2.0 | 6 votes |
@Before public void setup() { Page page = context.currentPage(PAGE); context.currentResource(TEASER); commerceTeaserResource = context.resourceResolver().getResource(TEASER); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(commerceTeaserResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); // Configure the component to create deep links to specific pages context.request().setAttribute(WCMMode.class.getName(), WCMMode.EDIT); commerceTeaser = context.request().adaptTo(CommerceTeaserImpl.class); }
Example 8
Source File: SlingObjectInjectorRequestTest.java From sling-org-apache-sling-models-impl with Apache License 2.0 | 5 votes |
@Before public void setUp() { SlingBindings bindings = new SlingBindings(); bindings.put(SlingBindings.SLING, this.scriptHelper); when(this.request.getResourceResolver()).thenReturn(this.resourceResolver); when(this.request.getResource()).thenReturn(this.resource); when(this.request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings); when(this.scriptHelper.getResponse()).thenReturn(this.response); }
Example 9
Source File: ConfigurationColumnPreviewTest.java From commerce-cif-connector with Apache License 2.0 | 5 votes |
@Test public void testGetProperties() { SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.put("resource", columnPreviewDef); context.currentResource(columnPreviewDef); ConfigurationColumnPreview preview = context.request().adaptTo(ConfigurationColumnPreview.class); Assert.assertEquals("Returns the correct title", "Mock configuration", preview.getTitle()); Assert.assertEquals("Returns whether it's folder or not", false, preview.isFolder()); Assert.assertEquals("Returns the correct path", CONFIGURATION_PATH, preview.getItemResourcePath()); }
Example 10
Source File: SearchResultsImplTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { Page page = Mockito.spy(context.currentPage(PAGE)); context.currentResource(SEARCHRESULTS); Resource searchResultsResource = context.resourceResolver().getResource(SEARCHRESULTS); GraphqlClient graphqlClient = new GraphqlClientImpl(); Whitebox.setInternalState(graphqlClient, "gson", QueryDeserializer.getGson()); Whitebox.setInternalState(graphqlClient, "client", httpClient); Whitebox.setInternalState(graphqlClient, "httpMethod", HttpMethod.POST); Utils.setupHttpResponse("graphql/magento-graphql-introspection-result.json", httpClient, HttpStatus.SC_OK, "{__type"); Utils.setupHttpResponse("graphql/magento-graphql-attributes-result.json", httpClient, HttpStatus.SC_OK, "{customAttributeMetadata"); Utils.setupHttpResponse("graphql/magento-graphql-search-result.json", httpClient, HttpStatus.SC_OK, "{products"); // This is needed by the SearchResultsService used by the productlist component pageResource = Mockito.spy(page.adaptTo(Resource.class)); when(page.adaptTo(Resource.class)).thenReturn(pageResource); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient") != null ? graphqlClient : null); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(searchResultsResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, searchResultsResource.getValueMap()); XSSAPI xssApi = mock(XSSAPI.class); when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class)); slingBindings.put("xssApi", xssApi); Style style = mock(Style.class); when(style.get(Mockito.anyString(), Mockito.anyInt())).then(i -> i.getArgumentAt(1, Object.class)); slingBindings.put("currentStyle", style); SightlyWCMMode wcmMode = mock(SightlyWCMMode.class); when(wcmMode.isDisabled()).thenReturn(false); slingBindings.put("wcmmode", wcmMode); }
Example 11
Source File: RelatedProductsImplTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
private void setUp(RelationType relationType, String jsonResponsePath, boolean addSlugInSelector) throws Exception { Page page = context.currentPage(PAGE); String resourcePath = RESOURCES_PATHS.get(relationType); context.currentResource(resourcePath); relatedProductsResource = Mockito.spy(context.resourceResolver().getResource(resourcePath)); if (addSlugInSelector) { MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo(); requestPathInfo.setSelectorString("endurance-watch"); } GraphqlClient graphqlClient = null; if (jsonResponsePath != null) { Query rootQuery = Utils.getQueryFromResource(jsonResponsePath); ProductInterface product = rootQuery.getProducts().getItems().get(0); products = PRODUCTS_GETTER.get(relationType).apply(product); graphqlClient = Utils.setupGraphqlClientWithHttpResponseFrom(jsonResponsePath); GraphqlClient finalGraphqlClient = graphqlClient; context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get("cq:graphqlClient", String.class) != null ? finalGraphqlClient : null); } // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(relatedProductsResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put("properties", relatedProductsResource.getValueMap()); relatedProducts = context.request().adaptTo(RelatedProductsImpl.class); }
Example 12
Source File: ButtonImplTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { Page currentPage = mock(Page.class); when(currentPage.getPath()).thenReturn("/content/sample-page"); SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage); context.addModelsForClasses(ButtonImpl.class); context.load().json("/context/jcr-content-button.json", "/content"); }
Example 13
Source File: ProductCarouselImplEmptyTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
@Before public void setUp() { carouselResource = Mockito.spy(context.resourceResolver().getResource(PRODUCTCAROUSEL)); // GraphQL client is not available Mockito.when(carouselResource.adaptTo(GraphqlClient.class)).thenReturn(null); // This sets the page attribute injected in the models with @Inject or @ScriptVariable slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(carouselResource); Page page = context.currentPage(PAGE); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); }
Example 14
Source File: ProductCollectionImplTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
private SlingBindings getSlingBindings(String resourcePath) { Page page = context.currentPage(PAGE); Resource productCollectionResource = context.resourceResolver().getResource(resourcePath); SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(productCollectionResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, productCollectionResource.getValueMap()); return slingBindings; }
Example 15
Source File: ProductListImplTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
@Test public void testProductListNoGraphqlClient() throws IOException { SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(context.resourceResolver().getResource("/content/pageB")); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, context.pageManager().getPage("/content/pageB")); productListModel = context.request().adaptTo(ProductListImpl.class); Assert.assertTrue(productListModel.getTitle().isEmpty()); Assert.assertTrue(productListModel.getImage().isEmpty()); Assert.assertTrue(productListModel.getProducts().isEmpty()); }
Example 16
Source File: GraphqlServletTest.java From aem-core-cif-components with Apache License 2.0 | 5 votes |
private Resource prepareModel(String resourcePath) throws ServletException { Page page = Mockito.spy(context.currentPage(PAGE)); context.currentPage(page); context.currentResource(resourcePath); Resource resource = Mockito.spy(context.currentResource()); GraphqlClient graphqlClient = new MockGraphqlClient(); Mockito.when(resource.adaptTo(GraphqlClient.class)).thenReturn(graphqlClient); Resource pageContent = Mockito.spy(page.getContentResource()); when(page.getContentResource()).thenReturn(pageContent); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient", String.class) != null ? graphqlClient : null); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(resource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, resource.getValueMap()); XSSAPI xssApi = mock(XSSAPI.class); when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class)); slingBindings.put("xssApi", xssApi); Style style = mock(Style.class); when(style.get(Mockito.anyString(), Mockito.isA(Boolean.class))).then(i -> i.getArgumentAt(1, Boolean.class)); when(style.get(Mockito.anyString(), Mockito.isA(Integer.class))).then(i -> i.getArgumentAt(1, Integer.class)); slingBindings.put("currentStyle", style); SightlyWCMMode wcmMode = mock(SightlyWCMMode.class); when(wcmMode.isDisabled()).thenReturn(false); slingBindings.put("wcmmode", wcmMode); return resource; }
Example 17
Source File: StoreConfigExporterTest.java From aem-core-cif-components with Apache License 2.0 | 4 votes |
private void setupWithPage(String pagetPath) { Page page = context.pageManager().getPage(pagetPath); SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); }
Example 18
Source File: ProductListImplTest.java From aem-core-cif-components with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Page page = Mockito.spy(context.currentPage(PAGE)); context.currentResource(PRODUCTLIST); productListResource = Mockito.spy(context.resourceResolver().getResource(PRODUCTLIST)); category = Utils.getQueryFromResource("graphql/magento-graphql-search-result-with-category.json").getCategory(); products = Utils.getQueryFromResource("graphql/magento-graphql-search-result-with-category.json").getProducts(); graphqlClient = Mockito.spy(new GraphqlClientImpl()); Whitebox.setInternalState(graphqlClient, "gson", QueryDeserializer.getGson()); Whitebox.setInternalState(graphqlClient, "client", httpClient); Whitebox.setInternalState(graphqlClient, "httpMethod", HttpMethod.POST); Utils.setupHttpResponse("graphql/magento-graphql-introspection-result.json", httpClient, HttpStatus.SC_OK, "{__type"); Utils.setupHttpResponse("graphql/magento-graphql-attributes-result.json", httpClient, HttpStatus.SC_OK, "{customAttributeMetadata"); Utils.setupHttpResponse("graphql/magento-graphql-search-result-with-category.json", httpClient, HttpStatus.SC_OK, "{products"); when(productListResource.adaptTo(ComponentsConfiguration.class)).thenReturn(MOCK_CONFIGURATION_OBJECT); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient", String.class) != null ? graphqlClient : null); // This is needed by the SearchResultsService used by the productlist component pageResource = Mockito.spy(page.adaptTo(Resource.class)); when(page.adaptTo(Resource.class)).thenReturn(pageResource); when(productListResource.adaptTo(ComponentsConfiguration.class)).thenReturn(MOCK_CONFIGURATION_OBJECT); Function<Resource, ComponentsConfiguration> adapter = r -> r.getPath().equals(PAGE) ? MOCK_CONFIGURATION_OBJECT : ComponentsConfiguration.EMPTY; context.registerAdapter(Resource.class, ComponentsConfiguration.class, adapter); MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo(); requestPathInfo.setSelectorString("6"); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(productListResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, productListResource.getValueMap()); XSSAPI xssApi = mock(XSSAPI.class); when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class)); slingBindings.put("xssApi", xssApi); Style style = mock(Style.class); when(style.get(Mockito.anyString(), Mockito.anyInt())).then(i -> i.getArgumentAt(1, Object.class)); slingBindings.put("currentStyle", style); SightlyWCMMode wcmMode = mock(SightlyWCMMode.class); when(wcmMode.isDisabled()).thenReturn(false); slingBindings.put("wcmmode", wcmMode); // context.request().adaptTo(ProductListImpl.class); is moved to each test because it uses an internal cache // and we want to override the "slug" in testEditModePlaceholderData() }
Example 19
Source File: ProductImplTest.java From aem-core-cif-components with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Page page = context.currentPage(PAGE); httpClient = mock(HttpClient.class); context.currentResource(PRODUCT); productResource = Mockito.spy(context.resourceResolver().getResource(PRODUCT)); Query rootQuery = Utils.getQueryFromResource("graphql/magento-graphql-product-result.json"); product = rootQuery.getProducts().getItems().get(0); storeConfig = rootQuery.getStoreConfig(); GraphqlClient graphqlClient = new GraphqlClientImpl(); Whitebox.setInternalState(graphqlClient, "gson", QueryDeserializer.getGson()); Whitebox.setInternalState(graphqlClient, "client", httpClient); Whitebox.setInternalState(graphqlClient, "httpMethod", HttpMethod.POST); Utils.setupHttpResponse("graphql/magento-graphql-product-result.json", httpClient, 200); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient", String.class) != null ? graphqlClient : null); MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo(); requestPathInfo.setSelectorString("beaumont-summit-kit"); // This sets the page attribute injected in the models with @Inject or @ScriptVariable SlingBindings slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName()); slingBindings.setResource(productResource); slingBindings.put(WCMBindingsConstants.NAME_CURRENT_PAGE, page); slingBindings.put(WCMBindingsConstants.NAME_PROPERTIES, productResource.getValueMap()); XSSAPI xssApi = mock(XSSAPI.class); when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class)); slingBindings.put("xssApi", xssApi); Style style = mock(Style.class); when(style.get(Mockito.anyString(), Mockito.anyBoolean())).then(i -> i.getArgumentAt(1, Boolean.class)); slingBindings.put("currentStyle", style); SightlyWCMMode wcmMode = mock(SightlyWCMMode.class); when(wcmMode.isDisabled()).thenReturn(false); slingBindings.put("wcmmode", wcmMode); // context.request().adaptTo(ProductImpl.class); is moved to each test because it uses an internal cache // and we want to override the "slug" in testEditModePlaceholderData() }