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());
}
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.");
}
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());
}
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>");
}
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());
}
Aggregations