use of org.craftercms.core.store.ContentStoreAdapter in project engine by craftercms.
the class TargetedContentDescriptorMergeStrategyTest method testGetDescriptors.
@Test
public void testGetDescriptors() throws Exception {
Item item = mock(Item.class);
when(item.getDescriptorDom()).thenReturn(mock(Document.class));
ContentStoreAdapter storeAdapter = mock(ContentStoreAdapter.class);
when(storeAdapter.findItem(any(Context.class), any(CachingOptions.class), anyString(), anyBoolean())).thenReturn(item);
Context context = mock(Context.class);
when(context.getStoreAdapter()).thenReturn(storeAdapter);
List<MergeableDescriptor> descriptors = mergeStrategy.getDescriptors(context, CachingOptions.DEFAULT_CACHING_OPTIONS, "/site/website/es_CR/products/index.xml", mock(Document.class), false);
assertNotNull(descriptors);
assertEquals(12, descriptors.size());
assertEquals("/crafter-level-descriptor.level.xml", descriptors.get(0).getUrl());
assertEquals("/site/crafter-level-descriptor.level.xml", descriptors.get(1).getUrl());
assertEquals("/site/website/crafter-level-descriptor.level.xml", descriptors.get(2).getUrl());
assertEquals("/site/website/en/crafter-level-descriptor.level.xml", descriptors.get(3).getUrl());
assertEquals("/site/website/en/products/crafter-level-descriptor.level.xml", descriptors.get(4).getUrl());
assertEquals("/site/website/en/products/index.xml", descriptors.get(5).getUrl());
assertEquals("/site/website/es/crafter-level-descriptor.level.xml", descriptors.get(6).getUrl());
assertEquals("/site/website/es/products/crafter-level-descriptor.level.xml", descriptors.get(7).getUrl());
assertEquals("/site/website/es/products/index.xml", descriptors.get(8).getUrl());
assertEquals("/site/website/es_CR/crafter-level-descriptor.level.xml", descriptors.get(9).getUrl());
assertEquals("/site/website/es_CR/products/crafter-level-descriptor.level.xml", descriptors.get(10).getUrl());
assertEquals("/site/website/es_CR/products/index.xml", descriptors.get(11).getUrl());
}
use of org.craftercms.core.store.ContentStoreAdapter in project engine by craftercms.
the class TargetedContentStoreAdapterTest method createActualAdapter.
private ContentStoreAdapter createActualAdapter() {
ContentStoreAdapter adapter = mock(ContentStoreAdapter.class);
Item idx = new Item();
idx.setName("index.xml");
idx.setUrl("/site/website/index.xml");
Item en = new Item();
en.setName("en");
en.setUrl("/site/website/en");
Item enIdx = new Item();
enIdx.setName("index.xml");
enIdx.setUrl("/site/website/en/index.xml");
Item enAboutUs = new Item();
enAboutUs.setName("about-us");
enAboutUs.setUrl("/site/website/en/about-us");
Item mainCss = new Item();
mainCss.setName("main.css");
mainCss.setUrl("/static-assets/css/main.css");
Item frIdx = new Item();
frIdx.setName("index.xml");
frIdx.setUrl("/site/website/ja/index.xml");
when(adapter.exists(any(Context.class), eq("/site/website/index.xml"))).thenReturn(true);
when(adapter.exists(any(Context.class), eq("/site/website/en"))).thenReturn(true);
when(adapter.exists(any(Context.class), eq("/site/website/en/index.xml"))).thenReturn(true);
when(adapter.exists(any(Context.class), eq("/static-assets/css/main.css"))).thenReturn(true);
when(adapter.findContent(any(Context.class), any(CachingOptions.class), eq("/site/website/index.xml"))).thenReturn(mock(Content.class));
when(adapter.findContent(any(Context.class), any(CachingOptions.class), eq("/site/website/en/index.xml"))).thenReturn(mock(Content.class));
when(adapter.findContent(any(Context.class), any(CachingOptions.class), eq("/static-assets/css/main.css"))).thenReturn(mock(Content.class));
when(adapter.findItem(any(Context.class), any(CachingOptions.class), eq("/site/website/index.xml"), anyBoolean())).thenReturn(idx);
when(adapter.findItem(any(Context.class), any(CachingOptions.class), eq("/site/website/en"), anyBoolean())).thenReturn(en);
when(adapter.findItem(any(Context.class), any(CachingOptions.class), eq("/site/website/en/index.xml"), anyBoolean())).thenReturn(enIdx);
when(adapter.findItem(any(Context.class), any(CachingOptions.class), eq("/static-assets/css/main.css"), anyBoolean())).thenReturn(mainCss);
when(adapter.findItems(any(Context.class), any(CachingOptions.class), eq("/site/website/en"), anyBoolean())).thenReturn(Arrays.asList(enIdx, enAboutUs));
when(adapter.findItems(any(Context.class), any(CachingOptions.class), eq("/site/website/ja"), anyBoolean())).thenReturn(Collections.singletonList(frIdx));
return adapter;
}
Aggregations