diff --git a/src/test/java/com/github/joschi/jadconfig/JadConfigTest.java b/src/test/java/com/github/joschi/jadconfig/JadConfigTest.java index 355c17d..b32da87 100644 --- a/src/test/java/com/github/joschi/jadconfig/JadConfigTest.java +++ b/src/test/java/com/github/joschi/jadconfig/JadConfigTest.java @@ -2,22 +2,7 @@ import com.github.joschi.jadconfig.repositories.InMemoryRepository; import com.github.joschi.jadconfig.repositories.PropertiesRepository; -import com.github.joschi.jadconfig.testbeans.ConverterFailureBean; -import com.github.joschi.jadconfig.testbeans.DefaultValueConfigurationBean; -import com.github.joschi.jadconfig.testbeans.EmptyBean; -import com.github.joschi.jadconfig.testbeans.FoobarConfigurationBean; -import com.github.joschi.jadconfig.testbeans.InheritedBeanSubClass; -import com.github.joschi.jadconfig.testbeans.InheritedBeanSubSubClass; -import com.github.joschi.jadconfig.testbeans.Multi1ConfigurationBean; -import com.github.joschi.jadconfig.testbeans.Multi2ConfigurationBean; -import com.github.joschi.jadconfig.testbeans.NonExistingParameterBean; -import com.github.joschi.jadconfig.testbeans.RequiredParameterBean; -import com.github.joschi.jadconfig.testbeans.SaveMeBean; -import com.github.joschi.jadconfig.testbeans.SimpleConfigurationBean; -import com.github.joschi.jadconfig.testbeans.TrimBean; -import com.github.joschi.jadconfig.testbeans.ValidatedConfigurationBean; -import com.github.joschi.jadconfig.testbeans.ValidatorMethodConfigurationBean; -import com.github.joschi.jadconfig.testbeans.VoidConfigurationBean; +import com.github.joschi.jadconfig.testbeans.*; import com.github.joschi.jadconfig.testconverters.FoobarConverterFactory; import com.github.joschi.jadconfig.validators.StringNotBlankValidator; import org.junit.Assert; @@ -503,6 +488,18 @@ public void testProcessValidatedBean() throws RepositoryException, ValidationExc Assert.assertEquals(1234567890123L, configurationBean.getMyLong()); } + @Test + public void testProcessValidatedBeanInvalidDefaultValue() throws RepositoryException, ValidationException { + InvalidDefaultValueValidatorBean configurationBean = new InvalidDefaultValueValidatorBean(); + jadConfig = new JadConfig(repository, configurationBean); + + jadConfig.process(); + + // TODO: this should throw an exception, is a mismatch of default value and configured validator + Assert.assertEquals(-1L, configurationBean.getMyPositiveLong()); + } + + @Test public void testProcessNullPropertiesDoNotOverwriteDefaultValues() throws RepositoryException, ValidationException { final SingleFieldBean bean = new SingleFieldBean(); diff --git a/src/test/java/com/github/joschi/jadconfig/testbeans/InvalidDefaultValueValidatorBean.java b/src/test/java/com/github/joschi/jadconfig/testbeans/InvalidDefaultValueValidatorBean.java new file mode 100644 index 0000000..90f0985 --- /dev/null +++ b/src/test/java/com/github/joschi/jadconfig/testbeans/InvalidDefaultValueValidatorBean.java @@ -0,0 +1,14 @@ +package com.github.joschi.jadconfig.testbeans; + +import com.github.joschi.jadconfig.Parameter; +import com.github.joschi.jadconfig.validators.PositiveLongValidator; + +public class InvalidDefaultValueValidatorBean { + + @Parameter(value = "test.positive.long", validator = PositiveLongValidator.class) + private long myPositiveLong = -1; + + public long getMyPositiveLong() { + return myPositiveLong; + } +}