@Test(dependsOnMethods = "mapByGetter") public void mapByPropertyName() { final FormBuilder<Person> formBuilder = FormBuilder.map(Person.class).useForProperty("description", new StringToTextAreaMapper()); final Form<Person> form = env.buildFormInEDT(formBuilder); env.addToWindow(form.asComponent()); env.setValueInEDT(form, env.createPerson()); final JPanelFixture wrapperPanel = env.getWrapperPanelFixture(); final JTextComponentFixture nameComponent = wrapperPanel.textBox("name"); assert nameComponent.target instanceof JTextField; final JTextComponentFixture descComponent = wrapperPanel.textBox("description"); assert descComponent.target instanceof JTextArea; }
@Test public void mapByGetter() { final FormBuilder<Person> formBuilder = FormBuilder.map(Person.class) .useForGetters( new GetterMapper<Person>() { public void mapGetters(final Person beanSample, final GetterConfig config) { config.use(beanSample.getDescription(), new StringToTextAreaMapper()); } }); final Form<Person> form = env.buildFormInEDT(formBuilder); env.addToWindow(form.asComponent()); env.setValueInEDT(form, env.createPerson()); final JPanelFixture wrapperPanel = env.getWrapperPanelFixture(); final JTextComponentFixture nameComponent = wrapperPanel.textBox("name"); assert nameComponent.target instanceof JTextField; final JTextComponentFixture descComponent = wrapperPanel.textBox("description"); assert descComponent.target instanceof JTextArea; }