Search in sources :

Example 16 with FormTester

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

the class OnValidateModelObjectsTest method onValidateModelObjects.

/**
 * Asserts that submitting the outer form will call {@link Form#onValidateModelObjects()}
 * for both the outer form and the inner form(s)
 */
@Test
public void onValidateModelObjects() {
    tester.startPage(OnFormValidateModelObjectsPage.class);
    FormTester formTester = tester.newFormTester("parentForm");
    formTester.submit("parentSubmitBtn");
    Page page = tester.getLastRenderedPage();
    OnFormValidateModelObjectsPage.ParentModel parentModel = (OnFormValidateModelObjectsPage.ParentModel) page.getDefaultModelObject();
    assertThat(parentModel.isParentValidated(), is(true));
    AddressFormPanel.ChildModel childPanel = (AddressFormPanel.ChildModel) page.get("parentForm:addressInfo").getDefaultModelObject();
    assertThat(childPanel.isChildValidated(), is(true));
}
Also used : AddressFormPanel(org.apache.wicket.markup.html.form.onFormValidateModelObjects.AddressFormPanel) FormTester(org.apache.wicket.util.tester.FormTester) Page(org.apache.wicket.Page) OnFormValidateModelObjectsPage(org.apache.wicket.markup.html.form.onFormValidateModelObjects.OnFormValidateModelObjectsPage) OnFormValidateModelObjectsPage(org.apache.wicket.markup.html.form.onFormValidateModelObjects.OnFormValidateModelObjectsPage) Test(org.junit.Test)

Example 17 with FormTester

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

the class TextFieldTest method emptyInputConvertedToNull.

/**
 */
@Test
public void emptyInputConvertedToNull() {
    TestPage testPage = new TestPage();
    testPage.textField.setType(String.class);
    testPage.textField.setConvertEmptyInputStringToNull(true);
    tester.startPage(testPage);
    FormTester formTester = tester.newFormTester(testPage.form.getId());
    formTester.setValue(testPage.textField.getId(), "");
    formTester.submit();
    assertEquals(null, testPage.textField.getDefaultModelObject());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 18 with FormTester

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

the class TestHomePage method testWithBorder2.

@Test
public void testWithBorder2() {
    FormTester formTester = tester.newFormTester("border:form");
    // formTester.setValue("..:textfield1", "testxxx");
    @SuppressWarnings("unchecked") TextField<String> textfield = (TextField<String>) tester.getLastRenderedPage().get("border:form:border_body:textfield");
    tester.getRequest().getPostParameters().setParameterValue(textfield.getInputName(), "abcde");
    MyTextField datefield = (MyTextField) tester.getLastRenderedPage().get("border:form:border_body:datefield");
    tester.getRequest().getPostParameters().setParameterValue(datefield.getInputName(), "aaabbb");
    MyDateField datefield2 = (MyDateField) tester.getLastRenderedPage().get("border:form:border_body:datefield2");
    @SuppressWarnings("unchecked") TextField<String> date = (TextField<String>) datefield2.get("date");
    tester.getRequest().getPostParameters().setParameterValue(date.getInputName(), "abcdef");
    formTester.submit();
    tester.assertNoErrorMessage();
    HomePage page = (HomePage) tester.getLastRenderedPage();
    assertEquals("abcde", page.getTextfield());
    assertEquals("aaabbb-converted", page.getDatefield());
    assertEquals("abcdef-converted", page.getDatefield2());
    assertEquals("abcde", page.get("border:form:border_body:lbltextfield").getDefaultModelObjectAsString());
    assertEquals("aaabbb-converted", page.get("border:form:border_body:lbldatefield").getDefaultModelObjectAsString());
    assertEquals("abcdef-converted", page.get("border:form:border_body:lbldatefield2").getDefaultModelObjectAsString());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) TextField(org.apache.wicket.markup.html.form.TextField) Test(org.junit.Test)

Example 19 with FormTester

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

the class TestHomePage_2134 method testRenderMyPage.

/**
 * WICKET-2134: two forms inside a border throw a ConversionException error
 */
@Test
public void testRenderMyPage() {
    // start and render the test page
    tester.startPage(CommonModelPage.class);
    // assert rendered page class
    tester.assertRenderedPage(CommonModelPage.class);
    FormTester formTester = tester.newFormTester("border:border_body:form1");
    formTester.submit();
    CommonModelPage page = (CommonModelPage) tester.getLastRenderedPage();
    assertEquals(0, page.quantity1);
    assertEquals(0, page.quantity2);
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 20 with FormTester

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

the class TestHomePage_2134 method testRenderMyPage2.

/**
 * WICKET-2134: two forms inside a border throw a ConversionException error
 */
@Test
public void testRenderMyPage2() {
    // start and render the test page
    tester.startPage(CommonModelPage.class);
    // assert rendered page class
    tester.assertRenderedPage(CommonModelPage.class);
    FormTester formTester = tester.newFormTester("border:border_body:form1");
    formTester.setValue("quantity1", "123");
    // formTester.setValue("quantity2", "44");
    formTester.submit();
    CommonModelPage page = (CommonModelPage) tester.getLastRenderedPage();
    assertEquals(123, page.quantity1);
    assertEquals(0, page.quantity2);
}
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