Search in sources :

Example 1 with RegistrationData

use of org.apache.tapestry5.integration.app1.data.RegistrationData 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();
}
Also used : RegistrationData(org.apache.tapestry5.integration.app1.data.RegistrationData) BeanModelSource(org.apache.tapestry5.beanmodel.services.BeanModelSource) Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) BeanValidationContext(org.apache.tapestry5.internal.BeanValidationContext) Environment(org.apache.tapestry5.services.Environment) PropertyOverrides(org.apache.tapestry5.PropertyOverrides) Annotation(java.lang.annotation.Annotation) ComponentResources(org.apache.tapestry5.ComponentResources) BeanEditContext(org.apache.tapestry5.services.BeanEditContext) Test(org.testng.annotations.Test)

Example 2 with RegistrationData

use of org.apache.tapestry5.integration.app1.data.RegistrationData 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();
}
Also used : RegistrationData(org.apache.tapestry5.integration.app1.data.RegistrationData) BeanModelSource(org.apache.tapestry5.beanmodel.services.BeanModelSource) Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) BeanValidationContext(org.apache.tapestry5.internal.BeanValidationContext) Environment(org.apache.tapestry5.services.Environment) PropertyOverrides(org.apache.tapestry5.PropertyOverrides) Annotation(java.lang.annotation.Annotation) ComponentResources(org.apache.tapestry5.ComponentResources) BeanEditContext(org.apache.tapestry5.services.BeanEditContext) Test(org.testng.annotations.Test)

Example 3 with RegistrationData

use of org.apache.tapestry5.integration.app1.data.RegistrationData 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();
}
Also used : RegistrationData(org.apache.tapestry5.integration.app1.data.RegistrationData) BeanModelSource(org.apache.tapestry5.beanmodel.services.BeanModelSource) Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Environment(org.apache.tapestry5.services.Environment) PropertyOverrides(org.apache.tapestry5.PropertyOverrides) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Aggregations

ComponentResources (org.apache.tapestry5.ComponentResources)3 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)3 BeanModel (org.apache.tapestry5.beanmodel.BeanModel)3 BeanModelSource (org.apache.tapestry5.beanmodel.services.BeanModelSource)3 Messages (org.apache.tapestry5.commons.Messages)3 RegistrationData (org.apache.tapestry5.integration.app1.data.RegistrationData)3 Environment (org.apache.tapestry5.services.Environment)3 Test (org.testng.annotations.Test)3 Annotation (java.lang.annotation.Annotation)2 BeanValidationContext (org.apache.tapestry5.internal.BeanValidationContext)2 BeanEditContext (org.apache.tapestry5.services.BeanEditContext)2