diff --git a/javaxval/.gitignore b/javaxval/.gitignore index 55a6bcf596..8027134ae9 100644 --- a/javaxval/.gitignore +++ b/javaxval/.gitignore @@ -2,5 +2,5 @@ .project .settings/ target/ - +bin/ diff --git a/javaxval/bin/.gitignore b/javaxval/bin/.gitignore new file mode 100644 index 0000000000..55a6bcf596 --- /dev/null +++ b/javaxval/bin/.gitignore @@ -0,0 +1,6 @@ +.classpath +.project +.settings/ +target/ + + diff --git a/javaxval/bin/pom.xml b/javaxval/bin/pom.xml new file mode 100644 index 0000000000..592f3c3431 --- /dev/null +++ b/javaxval/bin/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + org.baeldung + javaxval + 0.1-SNAPSHOT + + + + + + + junit + junit + 4.12 + + + + javax.validation + validation-api + 1.1.0.Final + + + + org.hibernate + hibernate-validator + 5.2.1.Final + + + + org.hibernate + hibernate-validator-annotation-processor + 5.2.1.Final + + + + javax.el + javax.el-api + 2.2.4 + + + + org.glassfish.web + javax.el + 2.2.4 + + + + + + \ No newline at end of file diff --git a/javaxval/src/test/java/sample/ValidationTest.java b/javaxval/src/test/java/sample/ValidationTest.java deleted file mode 100644 index 73a14c1ce3..0000000000 --- a/javaxval/src/test/java/sample/ValidationTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package sample; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -import org.junit.Assert; -import org.junit.Test; - -import sample.model.User; - -public class ValidationTest { - - @Test - public void ifNameIsNull_nameValidationFails() { - User user = new User(); - user.setWorking(true); - user.setAboutMe("Its all about me!!"); - user.setAge(50); - - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> violations = validator.validate(user); - Assert.assertEquals(violations.isEmpty(), false); - } - - @Test - public void ifSizeNotInRange_aboutMeValidationFails() { - User user = new User(); - user.setName("MyName"); - user.setAboutMe("Its all about me!!"); - user.setAge(50); - - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> violations = validator.validate(user); - Assert.assertEquals(violations.isEmpty(), false); - } - - @Test - public void ifWorkingIsFalse_workingValidationFails() { - User user = new User(); - user.setName("MyName"); - user.setAboutMe("Its all about me!!"); - user.setAge(50); - - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> violations = validator.validate(user); - Assert.assertEquals(violations.isEmpty(), false); - } - - @Test - public void ifAgeNotRange_ageValidationFails() { - User user = new User(); - user.setName("MyName"); - user.setAboutMe("Its all about me!!"); - user.setAge(8); - - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> violations = validator.validate(user); - Assert.assertEquals(violations.isEmpty(), false); - } -}