FormStyleItem extends Composite { public void setup(final String labelText, final IsWidget field, final int index) { final FormLabel formLabel = GWT.create(FormLabel.class); formLabel.setText(labelText); labelContainer.add(formLabel); group.add(field); this.index = index; } FormStyleItem(); void setup(final String labelText,
                      final IsWidget field,
                      final int index); void setup(final String labelText,
                      final String helpTitle,
                      final String helpContent,
                      final IsWidget widget,
                      final int index); FormGroup getFormGroup(); FlowPanel getGroup(); int getIndex();  }
@Test public void testSetup() throws Exception { final String attribute = "attribute"; final IsWidget widget = mock(IsWidget.class); final int index = 123; testedItem.setup(attribute, widget, index); verify(formLabel).setText(attribute); verify(labelContainer).add(formLabel); verify(group).add(widget); assertEquals(index, testedItem.index); }
@Test public void testSetupWithHelp() throws Exception { final String attribute = "attribute"; final String helpTitle = "help key"; final String helpContent = "help content"; final IsWidget widget = mock(IsWidget.class); final int index = 123; testedItem.setup(attribute, helpTitle, helpContent, widget, index); verify(formLabelHelp).setText(attribute); verify(formLabelHelp).setHelpTitle(helpTitle); verify(formLabelHelp).setHelpContent(helpContent); verify(labelContainer).add(formLabelHelp); verify(group).add(widget); assertEquals(index, testedItem.index); }