summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-05-01 19:44:40 +0300
committerVaadin Code Review <review@vaadin.com>2015-05-19 06:45:45 +0000
commitd63bf2c215831dcfea060331339199cc086d78f7 (patch)
treeb077f4c2f3702680c56fcff5a64a57169b3d776e /server/tests
parent851306745e0974669403ea0e9d07b08e9fbf979a (diff)
downloadvaadin-framework-d63bf2c215831dcfea060331339199cc086d78f7.tar.gz
vaadin-framework-d63bf2c215831dcfea060331339199cc086d78f7.zip
Make fields with validators immediate (#13709)7.5.0.beta1
Change-Id: I113aa38869cf4dceec24315e70d3b44eae526f65
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java61
1 files changed, 57 insertions, 4 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
index 61aafe317d..59831d92e1 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
@@ -1,16 +1,19 @@
package com.vaadin.tests.server.component.abstractfield;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.easymock.EasyMock;
+import org.junit.Test;
import com.vaadin.data.Validator;
import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Field;
-public class AbsFieldValidatorsTest extends TestCase {
+public class AbsFieldValidatorsTest {
- Field<Object> field = new AbstractField<Object>() {
+ AbstractField<Object> field = new AbstractField<Object>() {
@Override
public Class getType() {
return Object.class;
@@ -20,6 +23,7 @@ public class AbsFieldValidatorsTest extends TestCase {
Validator validator = EasyMock.createMock(Validator.class);
Validator validator2 = EasyMock.createMock(Validator.class);
+ @Test
public void testAddValidator() {
assertNotNull(field.getValidators());
assertEquals(0, field.getValidators().size());
@@ -34,6 +38,7 @@ public class AbsFieldValidatorsTest extends TestCase {
assertTrue(field.getValidators().contains(validator2));
}
+ @Test
public void testRemoveValidator() {
field.addValidator(validator);
field.addValidator(validator2);
@@ -51,6 +56,7 @@ public class AbsFieldValidatorsTest extends TestCase {
assertFalse(field.getValidators().contains(validator2));
}
+ @Test
public void testRemoveAllValidators() {
field.addValidator(validator);
field.addValidator(validator2);
@@ -61,4 +67,51 @@ public class AbsFieldValidatorsTest extends TestCase {
assertFalse(field.getValidators().contains(validator));
assertFalse(field.getValidators().contains(validator2));
}
+
+ @Test
+ public void validatorShouldMakeImmediate() {
+ assertFalse("field should not be immediate by default",
+ field.isImmediate());
+ field.addValidator(validator);
+ assertTrue("field should be immediate when it has a validator",
+ field.isImmediate());
+ }
+
+ @Test
+ public void nonImmediateFieldWithValidator() {
+ field.setImmediate(false);
+ field.addValidator(validator);
+ assertFalse("field should be non-immediate because explicitly set",
+ field.isImmediate());
+ }
+
+ @Test
+ public void removeValidatorMakesNonImmediate() {
+ field.addValidator(validator);
+ field.removeValidator(validator);
+ assertFalse(
+ "field should be non-immediate after validator was removed",
+ field.isImmediate());
+ }
+
+ @Test
+ public void requiredMakesImmediate() {
+ assertFalse("field should not be immediate by default",
+ field.isImmediate());
+ field.setRequired(true);
+ assertTrue("field should be immediate when it is required",
+ field.isImmediate());
+ }
+
+ @Test
+ public void removeRequiredMakesNonImmediate() {
+ assertFalse("field should not be immediate by default",
+ field.isImmediate());
+ field.setRequired(true);
+ field.setRequired(false);
+ assertFalse(
+ "field should not be immediate even though it was required",
+ field.isImmediate());
+ }
+
}