WicketTester tester = new WicketTester();
tester.startPage(BeanMetaDataTestPage.class);
Page page = tester.getLastRenderedPage();
BeanMetaDataTestBean bean = new BeanMetaDataTestBean();
BeanMetaData beanMetaData = new BeanMetaData(BeanMetaDataTestBean.class, null, page, null, false);
// Check parameters, elements, element parameters, tabs, tab elements.
assertFalse( beanMetaData.isViewOnly() );
assertTrue( beanMetaData.isDisplayed() );
// Test that ${} substitution works and that the properties file is referenced.
assertEquals("My Experiment Title", beanMetaData.getLabel() );
ElementInfo[] expectedProps = {
new ElementInfo("action.addRow", false, null, null, "Add Row", null, "listOfBeans"),
new ElementInfo("action.save", false, null, null, "Save", null, "nameInfo"),
new ElementInfo("gender", false, null, null, "Gender", null, "miscInfo"),
new ElementInfo("beans", true, null, null, "Beans", null, "listOfBeans"),
new ElementInfo("firstName", false, null, null, "First Name", null, "nameInfo"),
new ElementInfo("EMPTY:28", true, EmptyField.class.getName(), null, "", null, "miscInfo"),
new ElementInfo("age", false, null, null, "Age", null, "miscInfo"),
new ElementInfo("lastName", false, null, null, "Last Name", null, "nameInfo"),
new ElementInfo("operand1", false, null, null, "Operand 1", null, "miscInfo"),
new ElementInfo("EMPTY:28", true, EmptyField.class.getName(), null, "", null, "nameInfo"),
new ElementInfo("activePrimitive", false, null, null, "Active Primitive", null, "nameInfo"),
new ElementInfo("operand2", false, null, null, "Operand 2", null, "miscInfo"),
new ElementInfo("color", false, null, null, "Color", null, "nameInfo"),
new ElementInfo("result", true, null, null, "Result", null, "miscInfo"),
new ElementInfo("inlineBean", false, BeanInlineField.class.getName(), null, "Inline Bean", null, "nameInfo"),
new ElementInfo("palette", false, null, BeanMetaDataTestBean.ColorEnum.class.getName(), "Palette", null, "miscInfo"),
new ElementInfo("dateTimestamp", false, null, null, "Date Timestamp", null, "nameInfo"),
new ElementInfo("palette2", true, null, BeanMetaDataTestBean.ColorEnum.class.getName(), "Palette 2", null, "miscInfo"),
new ElementInfo("blockBean", false, BeanGridField.class.getName(), null, "Block Bean", null, "nameInfo"),
new ElementInfo("description", false, TextAreaField.class.getName(), null, "Description", null, "miscInfo"),
new ElementInfo("testBean2", false, null, null, "Test Bean 2", null, "nameInfo"),
new ElementInfo("popupBean", false, null, null, "Popup Bean", null, "nameInfo"),
new ElementInfo("action.cancel", false, null, null, "Cancel", null, null),
new ElementInfo("action.doIt", false, null, null, "Do It", null, null),
new ElementInfo("dateOnly", false, null, null, "Date Only", null, "nameInfo"),
new ElementInfo("isActive", false, null, null, "Is Active", null, "nameInfo"),
new ElementInfo("savingsAmount", false, null, null, "Savings Amount", null, "nameInfo"),
new ElementInfo("startDate", false, null, null, "Start Date", null, "nameInfo"),
new ElementInfo("timeOnly", false, null, null, "Time Only", null, "nameInfo"),
};
assertEquals(expectedProps.length, beanMetaData.getDisplayedElements().size());
int elementIdx = 0;
for (ElementMetaData element : beanMetaData.getDisplayedElements()) {
//System.out.println("new ElementInfo(\"" + element.getPropertyName() + "\", " + element.isViewOnly() + ", \"" + element.getFieldType() + "\", \"" + element.getElementTypeName() + "\", \"" + element.getLabel() + "\", \"" + element.getLabelImage() + "\", \"" + element.getTabId() + "\"),");
assertElement(beanMetaData, element, expectedProps[elementIdx]);
++elementIdx;
}
// action.save (second element) should have a parameter of colspan: 3
assertEquals(Integer.valueOf(3), beanMetaData.getDisplayedElements().get(1).getIntegerParameter("colspan"));
List<TabMetaData> tabs = beanMetaData.getTabs();
assertEquals(3, tabs.size());
assertEquals("nameInfo", tabs.get(0).getId());
assertEquals("Name Info", tabs.get(0).getLabel());
assertEquals(16, beanMetaData.getTabElements(tabs.get(0)).size());
assertEquals("miscInfo", tabs.get(1).getId());
assertEquals("Miscellaneous", tabs.get(1).getLabel());
assertEquals(9, beanMetaData.getTabElements(tabs.get(1)).size());
assertEquals("listOfBeans", tabs.get(2).getId());
assertEquals("List Of Beans", tabs.get(2).getLabel());
assertEquals(2, beanMetaData.getTabElements(tabs.get(2)).size());
}