use of org.apache.tapestry5.commons.services.TypeCoercer in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method render_informal_parameters_no_bindings.
@Test
public void render_informal_parameters_no_bindings() {
ComponentPageElement element = mockComponentPageElement();
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
MarkupWriter writer = mockMarkupWriter();
TypeCoercer coercer = mockTypeCoercer();
ComponentModel model = mockComponentModel();
train_getModel(ins, model);
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(null, element, null, elementResources, null, null, ins, false);
resources.renderInformalParameters(writer);
verify();
}
use of org.apache.tapestry5.commons.services.TypeCoercer in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method setup.
@BeforeClass
public void setup() {
perThreadManager = getService(PerthreadManager.class);
TypeCoercer typeCoercer = getService(TypeCoercer.class);
elementResources = new ComponentPageElementResourcesImpl(null, null, typeCoercer, null, null, null, null, null, null, null, perThreadManager, false, false, null);
}
use of org.apache.tapestry5.commons.services.TypeCoercer in project tapestry-5 by apache.
the class EnumValueEncoderTest method valid_values_can_be_retrieved_from_exception.
@Test
public // TAP5-1331
void valid_values_can_be_retrieved_from_exception() {
TypeCoercer typeCoercer = getService(TypeCoercer.class);
EnumValueEncoder<Stooge> encoder = new EnumValueEncoder<Stooge>(typeCoercer, Stooge.class);
try {
encoder.toValue("Foo");
fail();
} catch (RuntimeException e) {
assertTrue(e.getCause() instanceof UnknownValueException);
UnknownValueException cause = (UnknownValueException) e.getCause();
List<String> availableValues = cause.getAvailableValues().getValues();
assertTrue(availableValues.contains("MOE"));
assertTrue(availableValues.contains("LARRY"));
assertTrue(availableValues.contains("CURLY_JOE"));
}
}
use of org.apache.tapestry5.commons.services.TypeCoercer in project tapestry-5 by apache.
the class PageCallbackTest method callback_with_context.
@Test
public void callback_with_context() {
EventContext context = new ArrayEventContext(typeCoercer, 1, 2);
PageRenderLinkSource source = mockPageRenderLinkSource();
Link link = mockLink();
expect(source.createPageRenderLinkWithContext("bar", "1", "2")).andReturn(link);
PageCallback pc = new PageCallback("bar", context);
assertEquals(pc.toString(), "PageCallback[bar 1/2]");
replay();
assertSame(pc.toLink(source), link);
verify();
}
Aggregations