/** * <code>FormTester</code> must only be used once. Create a new instance of * <code>FormTester</code> for each test. */ private void checkClosed() { if (closed) { fail("'" + path + "' already submitted. Note that FormTester " + "is allowed to submit only once"); } }
/** * <code>FormTester</code> must only be used once. Create a new instance of * <code>FormTester</code> for each test. */ private void checkClosed() { if (closed) { fail("'" + path + "' already submitted. Note that FormTester " + "is allowed to submit only once"); } }
/** * Constructor. * * @param formComponent * a <code>FormComponent</code> */ protected MultipleChoiceSelector(FormComponent<?> formComponent) { super(formComponent); if (!allowMultipleChoice(formComponent)) { fail("Component:'" + formComponent.getPath() + "' Does not support multiple selection."); } }
/** * Creates a <code>ChoiceSelector</code>. * * @param formComponent * a <code>FormComponent</code> * @return ChoiceSelector a <code>ChoiceSelector</code> */ protected ChoiceSelector create(FormComponent<?> formComponent) { if (formComponent == null) { fail("Trying to select on null component."); return null; } else if (formComponent instanceof RadioGroup || formComponent instanceof AbstractSingleSelectChoice) { return new SingleChoiceSelector(formComponent); } else if (allowMultipleChoice(formComponent)) { return new MultipleChoiceSelector(formComponent); } else { fail("Selecting on the component:'" + formComponent.getPath() + "' is not supported."); return null; } }
/** * A convenience method for submitting the <code>Form</code> with an alternate button. * <p> * Note that if the button is associated with a model, it's better to use the * <code>setValue</code> method instead: * * <pre> * formTester.setValue("to:my:button", "value on the button"); * formTester.submit(); * </pre> * * @param buttonComponentId * relative path (from <code>Form</code>) to the button * @return This */ public FormTester submit(final String buttonComponentId) { Component submitter = getForm().get(buttonComponentId); if (submitter == null) { fail("Cannot submit the form because there is no submitting component with id: " + buttonComponentId); } return submit(submitter); }
/** * A convenience method for submitting the <code>Form</code> with an alternate button. * <p> * Note that if the button is associated with a model, it's better to use the * <code>setValue</code> method instead: * * <pre> * formTester.setValue("to:my:button", "value on the button"); * formTester.submit(); * </pre> * * @param buttonComponentId * relative path (from <code>Form</code>) to the button * @return This */ public FormTester submit(final String buttonComponentId) { Component submitter = getForm().get(buttonComponentId); if (submitter == null) { fail("Cannot submit the form because there is no submitting component with id: " + buttonComponentId); } return submit(submitter); }
if (foundRadio == null) fail("RadioGroup " + formComponent.getPath() + " does not have index:" + index); return null; if (foundCheck == null) fail("CheckGroup " + formComponent.getPath() + " does not have index:" + index); return null; if (idValue == null) fail(formComponent.getPath() + " is not a selectable Component."); return null;
/** * Simulates filling in a field on a <code>Form</code>. * * @param formComponent * relative path (from <code>Form</code>) to the selectable * <code>FormComponent</code> or <code>IFormSubmittingComponent</code> * @param value * the field value * @return This */ public FormTester setValue(final Component formComponent, final String value) { Args.notNull(formComponent, "formComponent"); checkClosed(); if (formComponent instanceof IFormSubmittingComponent) { setFormSubmittingComponentValue((IFormSubmittingComponent)formComponent, value); } else if (formComponent instanceof FormComponent) { setFormComponentValue((FormComponent<?>)formComponent, value); } else { fail("Component with id: " + formComponent.getId() + " is not a FormComponent"); } return this; }
/** * Simulates filling in a field on a <code>Form</code>. * * @param formComponent * relative path (from <code>Form</code>) to the selectable * <code>FormComponent</code> or <code>IFormSubmittingComponent</code> * @param value * the field value * @return This */ public FormTester setValue(final Component formComponent, final String value) { Args.notNull(formComponent, "formComponent"); checkClosed(); if (formComponent instanceof IFormSubmittingComponent) { setFormSubmittingComponentValue((IFormSubmittingComponent)formComponent, value); } else if (formComponent instanceof FormComponent) { setFormComponentValue((FormComponent<?>)formComponent, value); } else { fail("Component with id: " + formComponent.getId() + " is not a FormComponent"); } return this; }
fail("'" + formComponentId + "' is not " + "a FileUploadField. You can only attach a file to form " + "component of this type.");
fail("'" + formComponentId + "' is not " + "a FileUploadField. You can only attach a file to form " + "component of this type.");