Search in sources :

Example 91 with FormTester

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

the class FormMethodMismatchTest method formSubmittedAbortsByWithMismatchingMethodWhenDesired.

@Test
public void formSubmittedAbortsByWithMismatchingMethodWhenDesired() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }

        @Override
        protected MethodMismatchResponse onMethodMismatch() {
            return MethodMismatchResponse.ABORT;
        }
    };
    tester.startPage(new PlainFormPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    tester.getRequest().setMethod("GET");
    formTester.submit();
    assertFalse(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 92 with FormTester

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

the class FormMethodMismatchTest method withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired.

@Test
public void withButtonFormSubmittedAbortsByWithMismatchingMethodWhenDesired() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }

        @Override
        protected MethodMismatchResponse onMethodMismatch() {
            return MethodMismatchResponse.ABORT;
        }
    };
    tester.startPage(new FormWithButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    tester.getRequest().setMethod("GET");
    formTester.submit("button");
    assertFalse(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 93 with FormTester

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

the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesWithCorrectMethod.

@Test
public void withAjaxButtonFormSubmittedContinuesWithCorrectMethod() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }
    };
    tester.startPage(new FormWithAjaxButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    formTester.submit("button");
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 94 with FormTester

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

the class FormMethodMismatchTest method withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod.

@Test
public void withAjaxButtonFormSubmittedContinuesByDefaultWithMismatchingMethod() {
    final WicketTester tester = new WicketTester();
    final boolean[] onSubmitCalled = new boolean[1];
    final Form<Void> underTest = new Form<Void>("underTest") {

        @Override
        protected void onSubmit() {
            onSubmitCalled[0] = true;
        }
    };
    tester.startPage(new FormWithAjaxButtonPage(underTest));
    final FormTester formTester = tester.newFormTester("underTest");
    tester.getRequest().setMethod("GET");
    formTester.submit("button");
    assertTrue(onSubmitCalled[0]);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) WicketTester(org.apache.wicket.util.tester.WicketTester) Test(org.junit.Test)

Example 95 with FormTester

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

the class FormSubmitTest method allFormsEnabledSubmitOuterForm.

/**
 */
@Test
public void allFormsEnabledSubmitOuterForm() {
    assertEnabledState(true, true, true);
    FormTester formTester = tester.newFormTester("outerForm");
    formTester.submit("submit");
    assertOnSubmitCalled(true, true, true);
    assertOnErrorCalled(false, false, false);
    assertSubmitOrder(innerForm, middleForm, outerForm);
}
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