use of org.apache.tapestry5.services.BeanBlockContribution in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method display_block_not_found.
@Test
public void display_block_not_found() {
RequestPageCache cache = mockRequestPageCache();
Collection<BeanBlockContribution> configuration = newList();
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
try {
assertFalse(source.hasDisplayBlock("MyData"));
source.getDisplayBlock("MyData");
unreachable();
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "There is no defined way to display data of type \'MyData\'. Make a contribution to the BeanBlockSource service for this type.");
}
verify();
}
use of org.apache.tapestry5.services.BeanBlockContribution in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method found_edit_block.
@Test
public void found_edit_block() {
Block block = mockBlock();
RequestPageCache cache = mockRequestPageCache();
Page page = mockPage();
BeanBlockContribution contribution = new EditBlockContribution("mydata", "MyPage", "mydisplay");
Collection<BeanBlockContribution> configuration = newList(contribution);
train_get(cache, "MyPage", page);
train_getBlock(page, "mydisplay", block);
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
// Check case insensitivity while we are at it.
Block actual = source.getEditBlock("MyData");
assertSame(actual, block);
verify();
}
use of org.apache.tapestry5.services.BeanBlockContribution in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method found_display_block.
@Test
public void found_display_block() {
Block block = mockBlock();
RequestPageCache cache = mockRequestPageCache();
Page page = mockPage();
BeanBlockContribution contribution = new DisplayBlockContribution("mydata", "MyPage", "mydisplay");
Collection<BeanBlockContribution> configuration = newList(contribution);
train_get(cache, "MyPage", page);
train_getBlock(page, "mydisplay", block);
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
// Check case insensitivity while we are at it.
assertTrue(source.hasDisplayBlock("MyData"));
Block actual = source.getDisplayBlock("MyData");
assertSame(actual, block);
verify();
}
use of org.apache.tapestry5.services.BeanBlockContribution in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method edit_block_not_found.
@Test
public void edit_block_not_found() {
RequestPageCache cache = mockRequestPageCache();
Collection<BeanBlockContribution> configuration = newList();
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
try {
source.getEditBlock("MyData");
unreachable();
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "There is no defined way to edit data of type \'MyData\'. Make a contribution to the BeanBlockSource service for this type.");
}
verify();
}
use of org.apache.tapestry5.services.BeanBlockContribution in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method conflicting_bean_block_overrides.
@Test
public // TAP5-2506
void conflicting_bean_block_overrides() {
RequestPageCache cache = mockRequestPageCache();
Collection<BeanBlockContribution> configuration = CollectionFactory.newList();
configuration.add(new DisplayBlockContribution("foo", "page1", "bar"));
configuration.add(new DisplayBlockContribution("foo", "page2", "baz"));
try {
new BeanBlockOverrideSourceImpl(cache, configuration);
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "The BeanBlockOverrideSource configuration contains multiple display block overrides for data type 'foo'.");
}
}
Aggregations