use of org.craftercms.core.service.Item in project core by craftercms.
the class FieldRenamingProcessorTest method testProcess.
@Test
public void testProcess() throws Exception {
Item item = new Item();
item.setDescriptorDom(readInputXml());
item = processor.process(mock(Context.class), CachingOptions.DEFAULT_CACHING_OPTIONS, item);
assertNotNull(item.getDescriptorDom());
assertEquals(EXPECTED_XML, item.getDescriptorDom().asXML().replace("\n", ""));
}
use of org.craftercms.core.service.Item in project core by craftercms.
the class TextMetaDataExtractingProcessorTest method setUpTestItem.
private void setUpTestItem() {
Node cssNode = mock(Node.class);
when(cssNode.getText()).thenReturn(CSS);
Node jsNode = mock(Node.class);
when(jsNode.getText()).thenReturn(JS);
Document descriptorDom = mock(Document.class);
when(descriptorDom.selectSingleNode(testMetaDataNodesXPathQueries[0])).thenReturn(cssNode);
when(descriptorDom.selectSingleNode(testMetaDataNodesXPathQueries[1])).thenReturn(jsNode);
item = new Item();
item.setDescriptorDom(descriptorDom);
}
use of org.craftercms.core.service.Item in project core by craftercms.
the class UrlPatternProcessorResolverTest method testGetProcessor.
@Test
public void testGetProcessor() throws Exception {
Item item = new Item();
item.setUrl(DESCRIPTOR_URL);
ItemProcessor processor = resolver.getProcessor(item);
assertSame(processor, pagesProcessor);
item = new Item();
item.setUrl(IMAGE_URL);
processor = resolver.getProcessor(item);
assertSame(processor, staticAssetsProcessor);
}
use of org.craftercms.core.service.Item in project core by craftercms.
the class ContentStoreServiceImplTest method testGetDescriptorItem.
@Test
public void testGetDescriptorItem() throws Exception {
Item item = contentStoreService.findItem(context, CONTENT_FR_ES_DESCRIPTOR_PATH);
assertContentFrEsDescriptorItem(item, false);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
Item cachedItem = contentStoreService.getItem(context, CONTENT_FR_ES_DESCRIPTOR_PATH);
assertEquals(item, cachedItem);
assertCaching(item, cachedItem);
item = contentStoreService.findItem(context, INVALID_PATH);
assertNull(item);
try {
contentStoreService.getItem(context, INVALID_PATH);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
TextMetaDataExtractingProcessor extractor = new TextMetaDataExtractingProcessor("//first-quote", "//second-quote", "//third-quote");
item = contentStoreService.findItem(context, DEFAULT_CACHING_OPTIONS, CONTENT_FR_ES_DESCRIPTOR_PATH, extractor);
assertContentFrEsDescriptorItem(item, true);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
cachedItem = contentStoreService.getItem(context, DEFAULT_CACHING_OPTIONS, CONTENT_FR_ES_DESCRIPTOR_PATH, extractor);
assertEquals(item, cachedItem);
assertCaching(item, cachedItem);
item = contentStoreService.findItem(context, DEFAULT_CACHING_OPTIONS, INVALID_PATH, extractor);
assertNull(item);
try {
contentStoreService.getItem(context, DEFAULT_CACHING_OPTIONS, INVALID_PATH, extractor);
fail("Expected " + PathNotFoundException.class.getName());
} catch (PathNotFoundException e) {
}
}
use of org.craftercms.core.service.Item in project core by craftercms.
the class ContentStoreServiceImplTest method testGetFolderItem.
@Test
public void testGetFolderItem() throws Exception {
Item item = contentStoreService.findItem(context, BUNDLE_FOLDER_PATH);
assertBundleFolderItem(item, false);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
Item cachedItem = contentStoreService.getItem(context, BUNDLE_FOLDER_PATH);
assertEquals(item, cachedItem);
assertCaching(item, cachedItem);
TextMetaDataCollectionExtractingProcessor extractor = new TextMetaDataCollectionExtractingProcessor("//extension");
item = contentStoreService.findItem(context, DEFAULT_CACHING_OPTIONS, BUNDLE_FOLDER_PATH, extractor);
assertBundleFolderItem(item, true);
// Sleep so that we get a different caching time in the next call if the caching is being done wrong.
Thread.sleep(100);
cachedItem = contentStoreService.getItem(context, DEFAULT_CACHING_OPTIONS, BUNDLE_FOLDER_PATH, extractor);
assertEquals(item, cachedItem);
assertCaching(item, cachedItem);
}
Aggregations