use of org.apache.tapestry5.beanmodel.services.BeanModelSource in project tapestry-5 by apache.
the class CollectionGridDataSourceTest method setup.
@BeforeClass
public void setup() {
BeanModelSource source = getService(BeanModelSource.class);
Messages messages = mockMessages();
stub_contains(messages, false);
replay();
model = source.create(Datum.class, false, messages);
verify();
}
use of org.apache.tapestry5.beanmodel.services.BeanModelSource in project tapestry-5 by apache.
the class BeanEditorTest method refresh_bean_validation_context.
@Test
public void refresh_bean_validation_context() {
ComponentResources resources = mockComponentResources();
BeanModelSource source = mockBeanModelSource();
BeanModel model = mockBeanModel();
Environment env = mockEnvironment();
RegistrationData data = new RegistrationData();
Messages messages = mockMessages();
PropertyOverrides overrides = mockPropertyOverrides();
BeanValidationContext beanValidationContext = newMock(BeanValidationContext.class);
train_getBoundType(resources, "object", RegistrationData.class);
train_createEditModel(source, RegistrationData.class, messages, model);
train_getOverrideMessages(overrides, messages);
expect(model.newInstance()).andReturn(data);
expect(env.push(eq(BeanValidationContext.class), isA(BeanValidationContext.class))).andReturn(beanValidationContext);
expect(model.getBeanType()).andReturn(RegistrationData.class);
BeanEditContext ctxt = new BeanEditContext() {
public Class<?> getBeanClass() {
return RegistrationData.class;
}
public <T extends Annotation> T getAnnotation(Class<T> type) {
return null;
}
};
expect(env.push(eq(BeanEditContext.class), contextEq())).andReturn(ctxt);
replay();
BeanEditor component = new BeanEditor();
component.inject(resources, overrides, source, env);
component.doPrepare();
verify();
}
use of org.apache.tapestry5.beanmodel.services.BeanModelSource in project tapestry-5 by apache.
the class BeanEditorTest method beaneditcontext_popped_from_environment.
@Test
public void beaneditcontext_popped_from_environment() {
ComponentResources resources = mockComponentResources();
BeanModelSource source = mockBeanModelSource();
Environment env = mockEnvironment();
PropertyOverrides overrides = mockPropertyOverrides();
expect(env.pop(BeanEditContext.class)).andReturn(null);
expect(env.pop(BeanValidationContext.class)).andReturn(null);
replay();
BeanEditor component = new BeanEditor();
component.inject(resources, overrides, source, env);
component.cleanupEnvironment();
verify();
}
use of org.apache.tapestry5.beanmodel.services.BeanModelSource in project tapestry-5 by apache.
the class BeanEditorTest method beaneditcontext_pushed_to_environment.
@Test
public void beaneditcontext_pushed_to_environment() {
ComponentResources resources = mockComponentResources();
BeanModelSource source = mockBeanModelSource();
BeanModel model = mockBeanModel();
Environment env = mockEnvironment();
RegistrationData data = new RegistrationData();
Messages messages = mockMessages();
PropertyOverrides overrides = mockPropertyOverrides();
BeanValidationContext beanValidationContext = newMock(BeanValidationContext.class);
train_getBoundType(resources, "object", RegistrationData.class);
train_createEditModel(source, RegistrationData.class, messages, model);
train_getOverrideMessages(overrides, messages);
expect(model.newInstance()).andReturn(data);
expect(model.getBeanType()).andReturn(RegistrationData.class);
BeanEditContext ctxt = new BeanEditContext() {
public Class<?> getBeanClass() {
return RegistrationData.class;
}
public <T extends Annotation> T getAnnotation(Class<T> type) {
return null;
}
};
expect(env.push(eq(BeanEditContext.class), contextEq())).andReturn(ctxt);
expect(env.push(eq(BeanValidationContext.class), isA(BeanValidationContext.class))).andReturn(beanValidationContext);
replay();
BeanEditor component = new BeanEditor();
component.inject(resources, overrides, source, env);
component.doPrepare();
verify();
}
use of org.apache.tapestry5.beanmodel.services.BeanModelSource in project tapestry-5 by apache.
the class BeanEditorTest method object_created_as_needed.
@Test
public void object_created_as_needed() {
ComponentResources resources = mockComponentResources();
BeanModelSource source = mockBeanModelSource();
BeanModel model = mockBeanModel();
RegistrationData data = new RegistrationData();
Messages messages = mockMessages();
PropertyOverrides overrides = mockPropertyOverrides();
Environment env = EasyMock.createNiceMock(Environment.class);
train_getBoundType(resources, "object", RegistrationData.class);
train_createEditModel(source, RegistrationData.class, messages, model);
train_getOverrideMessages(overrides, messages);
expect(model.newInstance()).andReturn(data);
expect(model.getBeanType()).andReturn(RegistrationData.class);
replay();
EasyMock.replay(env);
BeanEditor component = new BeanEditor();
component.inject(resources, overrides, source, env);
component.doPrepare();
assertSame(component.getObject(), data);
verify();
}
Aggregations