Search in sources :

Example 36 with FormTester

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

the class TimeFieldTest method timeNotNull.

@Test
public void timeNotNull() {
    TestPage page = new TestPage(LocalTime.of(6, 15));
    tester.startPage(page);
    FormTester formTester = tester.newFormTester("form", false);
    formTester.setValue("field:hours", "8");
    formTester.submit();
    LocalTime t = page.field.getModelObject();
    assertNotNull(t);
    assertEquals(8, t.getHour());
    assertEquals(15, t.getMinute());
}
Also used : LocalTime(java.time.LocalTime) FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 37 with FormTester

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

the class TimeFieldTest method timeEmptyMinutes.

@Test
public void timeEmptyMinutes() {
    TestPage page = new TestPage(null);
    tester.startPage(page);
    FormTester formTester = tester.newFormTester("form", false);
    formTester.setValue("field:hours", "8");
    formTester.submit();
    tester.assertErrorMessages("The value of 'field' is not a valid LocalTime.");
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) Test(org.junit.Test)

Example 38 with FormTester

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

the class PaletteTest method required.

/**
 * WICKET-5352
 */
@Test
public void required() {
    IModel<List<String>> selected = new ListModel<>(new ArrayList<String>());
    IModel<List<String>> all = new ListModel<>(new ArrayList<>(Arrays.asList("A")));
    PaletteTestPage testPage = new PaletteTestPage(selected, all);
    testPage.palette.setRequired(true);
    tester.startPage(testPage);
    FormTester formTester = tester.newFormTester(testPage.form.getId());
    formTester.submit();
    assertTrue(testPage.form.hasError());
}
Also used : ListModel(org.apache.wicket.model.util.ListModel) FormTester(org.apache.wicket.util.tester.FormTester) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 39 with FormTester

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

the class PaletteTest method validationErrorRawInput.

/**
 * WICKET-5352
 */
@Test
public void validationErrorRawInput() {
    IModel<List<String>> selected = new ListModel<>(new ArrayList<String>());
    IModel<List<String>> all = new ListModel<>(new ArrayList<>(Arrays.asList("A", "B")));
    PaletteTestPage testPage = new PaletteTestPage(selected, all);
    testPage.palette.add(new IValidator<Collection<String>>() {

        @Override
        public void validate(IValidatable<Collection<String>> validatable) {
            if (validatable.getValue().contains("A")) {
                validatable.error(new ValidationError("A not allowed"));
            }
        }
    });
    tester.startPage(testPage);
    FormTester formTester = tester.newFormTester(testPage.form.getId());
    formTester.setValue("palette:recorder", "A");
    formTester.submit();
    assertTrue(testPage.form.hasError());
    // with RAW_INPUT
    tester.assertContains("<option value=\"B\">B</option>\\s*</select>");
    tester.assertContains("<option value=\"A\">A</option>\\s*</select>");
    testPage.form.clearInput();
    tester.startPage(testPage);
    // without RAW_INPUT
    tester.assertContains("<option value=\"A\">A</option>\\s*<option value=\"B\">B</option>\\s*</select>");
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) ListModel(org.apache.wicket.model.util.ListModel) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) ValidationError(org.apache.wicket.validation.ValidationError) Test(org.junit.Test)

Example 40 with FormTester

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

the class PaletteTest method standard.

/**
 */
@Test
public void standard() {
    IModel<List<String>> selected = new ListModel<>(new ArrayList<>(Arrays.asList("A", "D")));
    IModel<List<String>> all = new ListModel<>(new ArrayList<>(Arrays.asList("A", "B", "C", "D")));
    PaletteTestPage testPage = new PaletteTestPage(selected, all);
    tester.startPage(testPage);
    FormTester formTester = tester.newFormTester(testPage.form.getId());
    formTester.submit();
    Collection<String> collection = testPage.palette.getModelCollection();
    assertEquals(2, collection.size());
    Iterator<String> iterator = collection.iterator();
    assertEquals("A", iterator.next());
    assertEquals("D", iterator.next());
}
Also used : ListModel(org.apache.wicket.model.util.ListModel) FormTester(org.apache.wicket.util.tester.FormTester) ArrayList(java.util.ArrayList) List(java.util.List) 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