Search in sources :

Example 96 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormSubmitTest method allFormsEnabledSubmitMiddleForm.

/**
 */
@Test
public void allFormsEnabledSubmitMiddleForm() {
    assertEnabledState(true, true, true);
    FormTester formTester = tester.newFormTester("outerForm:middleForm");
    formTester.submit("submit");
    assertOnSubmitCalled(false, true, true);
    assertOnErrorCalled(false, false, false);
    assertSubmitOrder(innerForm, middleForm);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 97 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormSubmitTest method middleFormDisabledSubmitOuterForm.

/**
 */
@Test
public void middleFormDisabledSubmitOuterForm() {
    // disable middle form
    middleForm.setEnabled(false);
    assertEnabledState(true, false, true);
    // submit outer form
    FormTester formTester = tester.newFormTester("outerForm");
    formTester.submit("submit");
    assertOnSubmitCalled(true, false, false);
    assertOnErrorCalled(false, false, false);
    assertSubmitOrder(outerForm);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 98 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormSubmitTest method submitDisabledOuterForm.

/**
 */
@Test
public void submitDisabledOuterForm() {
    outerForm.setEnabled(false);
    assertEnabledState(false, true, true);
    FormTester formTester = tester.newFormTester("outerForm");
    try {
        formTester.submit("submit");
        fail("Executing the listener on disabled component is not allowed.");
    } catch (ListenerInvocationNotAllowedException expected) {
        ;
    }
    assertOnSubmitCalled(false, false, false);
    assertOnErrorCalled(false, false, false);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) ListenerInvocationNotAllowedException(org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException) Test(org.junit.Test)

Example 99 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormValidationDisabledFormComponentTest method formSubmitsEvenWithInvalidButDisabledFormComponent.

@Test
public void formSubmitsEvenWithInvalidButDisabledFormComponent() {
    TestPage page = tester.startPage(TestPage.class);
    assertFalse(page.onSubmitCalled.get());
    assertFalse(page.onErrorCalled.get());
    FormTester formTester = tester.newFormTester(page.form.getPageRelativePath());
    formTester.submit();
    assertTrue(page.field1.hasErrorMessage());
    assertFalse(page.onSubmitCalled.get());
    assertTrue(page.onErrorCalled.get());
    page.onErrorCalled.set(false);
    page.field1.setEnabled(false);
    formTester = tester.newFormTester(page.form.getPageRelativePath());
    formTester.submit();
    assertTrue(page.field1.hasErrorMessage());
    assertTrue(page.onSubmitCalled.get());
    assertFalse(page.onErrorCalled.get());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 100 with FormTester

use of org.apache.wicket.util.tester.FormTester in project wicket by apache.

the class FormValidationTest method renderedFeedbackMessages.

/**
 * Tests validation of form components when all errors are rendered using a feedback panel.
 *
 * Validation status depends on whether or not a form component has error messages, here we test
 * submission roundtrip in a usecase where all error messages are rendered and cleared at the
 * end of the request.
 */
@Test
public void renderedFeedbackMessages() {
    // start the page
    TestPage page = new TestPage();
    scope.getTester().startPage(page);
    // submit the form without filling out any values
    FormTester formTester = scope.getTester().newFormTester(page.form.getPageRelativePath());
    formTester.setClearFeedbackMessagesBeforeSubmit(true);
    formTester.submit();
    // the first required form component should fail and so should the form
    assertTrue(page.form.hasError());
    assertFalse(page.field1.isValid());
    // fill out a value and submit again
    formTester = scope.getTester().newFormTester(page.form.getPageRelativePath());
    formTester.setValue(page.field1, "hi");
    formTester.setClearFeedbackMessagesBeforeSubmit(true);
    formTester.submit();
    // now the form and the form component should be valid
    assertFalse(page.form.hasError());
    assertTrue(page.field1.isValid());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Aggregations

FormTester (org.apache.wicket.util.tester.FormTester)207 Test (org.junit.Test)122 Test (org.junit.jupiter.api.Test)54 Component (org.apache.wicket.Component)50 WicketTester (org.apache.wicket.util.tester.WicketTester)14 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Test (org.testng.annotations.Test)9 List (java.util.List)8 ListModel (org.apache.wicket.model.util.ListModel)7 ArrayList (java.util.ArrayList)6 File (org.apache.wicket.util.file.File)4 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)3 ButtonAjaxBehavior (com.googlecode.wicket.jquery.ui.widget.dialog.ButtonAjaxBehavior)3 LocalDate (java.time.LocalDate)3 Cookie (javax.servlet.http.Cookie)3 Page (org.apache.wicket.Page)3 LocalDateConverter (org.apache.wicket.util.convert.converter.LocalDateConverter)3 Ignore (org.junit.Ignore)3 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)2