use of org.apache.tapestry5.services.ComponentDefaultProvider in project tapestry-5 by apache.
the class ComponentDefaultProviderImplTest method default_translator.
@Test
public void default_translator() {
ComponentResources resources = mockComponentResources();
FieldTranslator translator = mockFieldTranslator();
FieldTranslatorSource source = newMock(FieldTranslatorSource.class);
train_createDefaultTranslator(source, resources, "object", translator);
replay();
ComponentDefaultProvider provider = new ComponentDefaultProviderImpl(null, null, null, source, null);
assertSame(provider.defaultTranslator("object", resources), translator);
verify();
}
use of org.apache.tapestry5.services.ComponentDefaultProvider in project tapestry-5 by apache.
the class ComponentDefaultProviderImplTest method default_label_key_missing.
@Test
public void default_label_key_missing() {
ComponentResources resources = mockComponentResources();
ComponentResources container = mockComponentResources();
Messages messages = mockMessages();
String componentId = "myField";
String key = componentId + "-label";
train_getId(resources, componentId);
train_getContainerResources(resources, container);
train_getMessages(container, messages);
train_contains(messages, key, false);
replay();
ComponentDefaultProvider provider = new ComponentDefaultProviderImpl(null, null, null, null, null);
assertEquals(provider.defaultLabel(resources), "My Field");
verify();
}
use of org.apache.tapestry5.services.ComponentDefaultProvider in project tapestry-5 by apache.
the class ComponentDefaultProviderImplTest method no_matching_property_for_default.
@Test
public void no_matching_property_for_default() {
String parameterName = "myparam";
String id = "mycomponentid";
ComponentResources resources = mockComponentResources();
Component container = mockComponent();
PropertyAccess access = mockPropertyAccess();
ClassPropertyAdapter classPropertyAdapter = mockClassPropertyAdapter();
BindingSource bindingSource = mockBindingSource();
train_getId(resources, id);
train_getContainer(resources, container);
train_getAdapter(access, container, classPropertyAdapter);
train_getPropertyAdapter(classPropertyAdapter, id, null);
replay();
ComponentDefaultProvider source = new ComponentDefaultProviderImpl(access, bindingSource, null, null, null);
assertNull(source.defaultBinding(parameterName, resources));
verify();
}
use of org.apache.tapestry5.services.ComponentDefaultProvider in project tapestry-5 by apache.
the class ComponentDefaultProviderImplTest method default_translator_property_type_is_null.
@Test
public void default_translator_property_type_is_null() {
ComponentResources resources = mockComponentResources();
FieldTranslatorSource source = newMock(FieldTranslatorSource.class);
train_createDefaultTranslator(source, resources, "object", null);
replay();
ComponentDefaultProvider provider = new ComponentDefaultProviderImpl(null, null, null, source, null);
assertNull(provider.defaultTranslator("object", resources));
verify();
}
use of org.apache.tapestry5.services.ComponentDefaultProvider in project tapestry-5 by apache.
the class ComponentDefaultProviderImplTest method default_property_exists.
@Test
public void default_property_exists() {
String parameterName = "myparam";
String id = "mycomponentid";
ComponentResources resources = mockComponentResources();
Component container = mockComponent();
PropertyAccess access = mockPropertyAccess();
ClassPropertyAdapter classPropertyAdapter = mockClassPropertyAdapter();
PropertyAdapter propertyAdapter = mockPropertyAdapter();
BindingSource bindingSource = mockBindingSource();
Binding binding = mockBinding();
ComponentResources containerResources = mockComponentResources();
train_getId(resources, id);
train_getContainer(resources, container);
train_getAdapter(access, container, classPropertyAdapter);
train_getPropertyAdapter(classPropertyAdapter, id, propertyAdapter);
train_getContainerResources(resources, containerResources);
train_newBinding(bindingSource, "default myparam", containerResources, BindingConstants.PROP, id, binding);
replay();
ComponentDefaultProvider source = new ComponentDefaultProviderImpl(access, bindingSource, null, null, null);
assertSame(source.defaultBinding(parameterName, resources), binding);
verify();
}
Aggregations