diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3967d3f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -sudo: false - -language: java - -jdk: oraclejdk8 - -cache: - directories: - - "$HOME/.m2/repository" - -install: - - echo "bintray\${env.BINTRAY_USER}\${env.BINTRAY_KEY}" > ~/.m2/settings.xml - - if [[ $TRAVIS_PULL_REQUEST = false ]] && [[ $TRAVIS_BRANCH = master ]] || [[ $TRAVIS_TAG = v* ]]; then GOAL=deploy; else GOAL=install; fi - - if [[ $TRAVIS_TAG = v* ]]; then ADDITIONAL_PROFILES=release; mvn -q -U org.seedstack:seedstack-maven-plugin:release; else ADDITIONAL_PROFILES=snapshots; fi - -script: mvn -q -U -T 2 -Pbuild-number,compatibility,bintray,javadoc,$ADDITIONAL_PROFILES $GOAL jacoco:report - -after_success: mvn -q coveralls:report -DrepoToken=$COVERALLS_TOKEN diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index cefb0c3..0000000 --- a/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The SeedStack authors for copyright purposes. -# The master list of authors is in the SeedStack meta repository, -# visible at https://github.com/seedstack/seedstack/blob/master/AUTHORS. \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 28cc086..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,20 +0,0 @@ -# Version 2.3.0 (2016-04-26) - -* [chg] Validation plugin automatically disables itself if no validation API is present on the classpath. -* [new] Add a facet for providing the `ValidatorFactory` to other plugins. -* [chg] Update for SeedStack for 16.4 - -# Version 2.2.0 (2016-01-28) - -* [new] An `ExceptionMapper` for `ConstraintViolationException` is provided by default. -* [new] The `ValidatorFactory` is now injectable. -* [chg] The `ValidationService` is deprecated and replaced by `Validator` from the spec (injected or obtained through `ValidatorFactory`). -* [brk] The `org.seedstack.validation.ValidationException` is replaced by the standard `ConstraintViolationException`. - -# Version 2.1.0 (2015-11-15) - -* [chg] Refactored as an add-on and updated to work with Seed 2.1.0+ - -# Version 2.0.0 (2015-07-30) - -* [new] Initial Open-Source release. diff --git a/CONTRIBUTORS b/CONTRIBUTORS deleted file mode 100644 index c2dc923..0000000 --- a/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the SeedStack contributors. -# The master list of contributors is in the SeedStack meta repository, -# visible at https://github.com/seedstack/seedstack/blob/master/CONTRIBUTORS. \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f4bbcd2..0000000 --- a/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 3e6038d..0000000 --- a/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# SeedStack validation add-on - -[![Build status](https://travis-ci.org/seedstack/validation-addon.svg?branch=master)](https://travis-ci.org/seedstack/validation-addon) [![Coverage Status](https://coveralls.io/repos/seedstack/validation-addon/badge.svg?branch=master)](https://coveralls.io/r/seedstack/validation-addon?branch=master) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.seedstack.addons.validation/validation/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/org.seedstack.addons.validation/validation) - -Official validation integration for SeedStack. - -# Copyright and license - -This source code is copyrighted by [The SeedStack Authors](https://github.com/seedstack/seedstack/blob/master/AUTHORS) and -released under the terms of the [Mozilla Public License 2.0](https://www.mozilla.org/MPL/2.0/). diff --git a/index.md b/index.md new file mode 100644 index 0000000..09ba941 --- /dev/null +++ b/index.md @@ -0,0 +1,35 @@ +--- +title: "Basics" +name: "Validation" +repo: "https://github.com/seedstack/validation-addon" +date: 2016-01-21 +author: Adrien LAUER +description: "Provides bean validation 1.1 (JSR 303 & 349)." +backend: true +weight: -1 +tags: + - "bean" + - "validation" +zones: + - Addons +menu: + AddonValidation: + weight: 10 +--- + +SeedStack validation add-on allows developers to use Bean Validation 1.0 and 1.1: + +* Bean Validation 1.0 brings static validation (aka JSR 303). +* Bean Validation API 1.1 brings dynamic validation (aka JSR 349). + +Data validation is a very common concern at each and every layer of an application. As such, it has been standardized +through Bean Validation using JSR 303 and JSR 349. Implementation uses **Hibernate Validator** that you need to add +explicitly in your project: + +* Use Hibernate Validator version 4.x to support Bean Validation 1.0 only (like in strict JEE6 environments) +* Use Hibernate Validator version 5.x to support Bean Validation 1.1. + +To use this add-on add the following dependency: + +{{< dependency g="org.seedstack.addons.validation" a="validation" >}} + diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 7a68038..0000000 --- a/pom.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - 4.0.0 - - - org.seedstack.poms - parent-internal - 2.4.0 - - - org.seedstack.addons.validation - validation - 2.3.0-SNAPSHOT - - - 2.3.0 - 5.1.3.Final - - 2.1.0 - - validation-addon - 2.2.7 - - - - - - - org.codehaus.mojo - license-maven-plugin - - - Apache 2 - BSD - CDDL - LGPL 3.0 - MIT License - MPL 2.0 - Public Domain - WTFPL - - - IGNORED_LICENSE - - - Apache 2|Apache License, Version 2.0 - Apache 2|The Apache Software License, Version 2.0 - Apache 2|Apache License 2.0 - Apache 2|Apache License, version 2.0 - BSD|The New BSD License - CDDL|CDDL + GPLv2 with classpath exception - LGPL 3.0|GNU Lesser Public License - IGNORED_LICENSE|MPL 1.1 - IGNORED_LICENSE|LGPL 2.1 - - - - - com.github.siom79.japicmp - japicmp-maven-plugin - - - - *.internal.* - org.seedstack.validation.spi.ValidationConcern - - - - - - - - - - - org.seedstack.seed - seed-core - ${seed.version} - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - true - - - javax.validation - validation-api - 1.1.0.Final - provided - - - javax.ws.rs - javax.ws.rs-api - 2.0.1 - provided - - - - - org.seedstack.seed - seed-testing - ${seed.version} - test - - - javax.el - javax.el-api - ${javax-el.version} - test - - - de.odysseus.juel - juel-impl - ${juel.version} - - - de.odysseus.juel - juel-spi - ${juel.version} - - - org.glassfish.jersey.containers - jersey-container-servlet - 2.22.1 - test - - - ch.qos.logback - logback-classic - ${logback.version} - test - - - - - https://github.com/seedstack/validation-addon - scm:git:git://github.com/seedstack/validation-addon.git - scm:git:git@github.com:seedstack/validation-addon.git - HEAD - - - - - - false - - bintray-jfrog-jfrog-jars - bintray-plugins - http://dl.bintray.com/jfrog/jfrog-jars - - - - - - snapshots - - - - true - - - false - - ojo-libs-snapshot - ojo-snapshots - https://oss.jfrog.org/artifactory/libs-snapshot - - - - - bintray - - - - false - - - true - - bintray-seedstack-jars - bintray - http://dl.bintray.com/seedstack/jars - - - - - diff --git a/src/it/java/org/seedstack/validation/internal/FieldValidationKoIT.java b/src/it/java/org/seedstack/validation/internal/FieldValidationKoIT.java deleted file mode 100644 index 4b42d9f..0000000 --- a/src/it/java/org/seedstack/validation/internal/FieldValidationKoIT.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.seedstack.seed.it.Expect; -import org.seedstack.seed.it.SeedITRunner; -import org.seedstack.validation.api.VerboseConstraintViolationException; -import org.seedstack.validation.internal.pojo.FieldValidationKO; - -import javax.inject.Inject; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SeedITRunner.class) -@Expect(value = VerboseConstraintViolationException.class, step = Expect.TestingStep.INSTANTIATION) -public class FieldValidationKoIT { - - @Inject - FieldValidationKO serviceField; - - @Test - public void trigger() { - assertThat(serviceField).isNull(); - } -} diff --git a/src/it/java/org/seedstack/validation/internal/FieldValidationOkIT.java b/src/it/java/org/seedstack/validation/internal/FieldValidationOkIT.java deleted file mode 100644 index 8ca71b0..0000000 --- a/src/it/java/org/seedstack/validation/internal/FieldValidationOkIT.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.seedstack.validation.internal.pojo.FieldValidationOK; -import org.assertj.core.api.Assertions; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.seedstack.seed.it.SeedITRunner; - -import javax.inject.Inject; - -@RunWith(SeedITRunner.class) -public class FieldValidationOkIT { - - @Inject - FieldValidationOK serviceField; - - @Test - public void trigger() { - Assertions.assertThat(serviceField).isNotNull(); - } - -} diff --git a/src/it/java/org/seedstack/validation/internal/InjectionsIT.java b/src/it/java/org/seedstack/validation/internal/InjectionsIT.java deleted file mode 100644 index 34f326c..0000000 --- a/src/it/java/org/seedstack/validation/internal/InjectionsIT.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.assertj.core.api.Assertions; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.seedstack.seed.it.SeedITRunner; - -import javax.inject.Inject; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -@RunWith(SeedITRunner.class) -public class InjectionsIT { - - @Inject - private ValidatorFactory validatorFactory; - - @Inject - private Validator validator; - - @Test - public void isValidatorFactoryInjectable() { - Assertions.assertThat(validatorFactory).isNotNull(); - } - - @Test - public void isValidatorInjectable() { - Assertions.assertThat(validator).isNotNull(); - } -} diff --git a/src/it/java/org/seedstack/validation/internal/ValidationPluginIT.java b/src/it/java/org/seedstack/validation/internal/ValidationPluginIT.java deleted file mode 100644 index 91784d4..0000000 --- a/src/it/java/org/seedstack/validation/internal/ValidationPluginIT.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.seedstack.seed.it.SeedITRunner; -import org.seedstack.validation.internal.pojo.CustomPojo; -import org.seedstack.validation.internal.pojo.FieldValidationOK; -import org.seedstack.validation.internal.pojo.ParamReturnType; -import org.seedstack.validation.internal.pojo.ParamValidation; -import org.seedstack.validation.internal.pojo.Pojo; -import org.seedstack.validation.internal.pojo.WithoutValidation; - -import javax.inject.Inject; -import javax.validation.ConstraintViolationException; -import javax.validation.Validator; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SeedITRunner.class) -public class ValidationPluginIT { - - @Inject - ParamValidation serviceParam; - - @Inject - FieldValidationOK serviceField; - - @Inject - ParamReturnType serviceReturnType; - - @Inject - WithoutValidation serviceWithoutValidation; - - @Inject - Validator validator; - - @Test - public void services_are_well_injected() { - assertThat(serviceParam).isNotNull(); - assertThat(serviceField).isNotNull(); - assertThat(serviceReturnType).isNotNull(); - assertThat(serviceWithoutValidation).isNotNull(); - } - - @Test - public void param_not_null_validations_ok() { - serviceParam.validateNotNullParam(""); - } - - @Test(expected = ConstraintViolationException.class) - public void param_not_null_validations_are_well_intercepted() { - serviceParam.validateNotNullParam(null); - } - - @Test - public void param_valid_validations_ok() { - serviceParam.validateValidParam(new Pojo(Pojo.State.VALID)); - } - - - @Test(expected = ConstraintViolationException.class) - public void param_valid_validations_are_well_intercepted() { - serviceParam.validateValidParam(new Pojo(Pojo.State.INVALID)); - } - - @Test - public void not_null_return_validations_ok() { - serviceReturnType.validateNotNullReturn(""); - } - - @Test(expected = ConstraintViolationException.class) - public void not_null_return_validations_are_well_intercepted() { - serviceReturnType.validateNotNullReturn(null); - } - - @Test - public void valid_return_validations_ok() { - serviceReturnType.validateValidReturn(Pojo.State.VALID); - } - - @Test(expected = ConstraintViolationException.class) - public void valid_return_validations_are_well_intercepted() { - serviceReturnType.validateValidReturn(Pojo.State.INVALID); - } - - @Test - public void custom_validator() { - assertThat(validator.validate(new CustomPojo("abc")).size()).isEqualTo(1); - assertThat(validator.validate(new CustomPojo("ABC")).size()).isEqualTo(0); - } -} diff --git a/src/it/java/org/seedstack/validation/internal/ValidationServiceIT.java b/src/it/java/org/seedstack/validation/internal/ValidationServiceIT.java deleted file mode 100644 index 58740c8..0000000 --- a/src/it/java/org/seedstack/validation/internal/ValidationServiceIT.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.assertj.core.api.Assertions; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.seedstack.seed.it.SeedITRunner; -import org.seedstack.validation.internal.pojo.Bean; -import org.seedstack.validation.internal.pojo.MyImpl; -import org.seedstack.validation.internal.pojo.Pojo; -import org.seedstack.validation.internal.pojo.PojoWithDeepValidation; - -import javax.inject.Inject; -import javax.validation.ConstraintViolationException; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SeedITRunner.class) -public class ValidationServiceIT { - - @Inject - ValidationService validationService; - - @Test - public void validationServiceIsInjected() { - assertThat(validationService).isNotNull(); - } - - @Test - public void throwsExceptionOnInvalidPojo() { - try { - validationService.staticallyHandle(new Pojo(Pojo.State.INVALID)); - Assertions.failBecauseExceptionWasNotThrown(ConstraintViolationException.class); - } catch (ConstraintViolationException exception) { - assertThat(exception.getConstraintViolations()).hasSize(3); - } - } - - @Test - public void doNothingOnValidPojo() { - validationService.staticallyHandle(new Pojo(Pojo.State.VALID)); - } - - @Test - public void throwsExceptionOnDeepValidation() { - try { - validationService.staticallyHandle(new PojoWithDeepValidation()); - Assertions.failBecauseExceptionWasNotThrown(ConstraintViolationException.class); - } catch (ConstraintViolationException exception) { - assertThat(exception.getConstraintViolations()).hasSize(4); - } - } - - @Test - public void validationShouldWorkOnInterface() { - try { - validationService.staticallyHandle(new MyImpl()); - Assertions.failBecauseExceptionWasNotThrown(ConstraintViolationException.class); - } catch (ConstraintViolationException exception) { - assertThat(exception.getConstraintViolations()).hasSize(1); - } - } - - @Test - public void validationShouldWorkOnGetter() { - try { - Bean candidate = new Bean(); - candidate.setHour(25); - validationService.staticallyHandle(candidate); - Assertions.failBecauseExceptionWasNotThrown(ConstraintViolationException.class); - } catch (ConstraintViolationException exception) { - assertThat(exception.getConstraintViolations()).hasSize(1); - } - } -} diff --git a/src/it/java/org/seedstack/validation/internal/custom/CaseMode.java b/src/it/java/org/seedstack/validation/internal/custom/CaseMode.java deleted file mode 100644 index 30b7e1f..0000000 --- a/src/it/java/org/seedstack/validation/internal/custom/CaseMode.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.custom; - -public enum CaseMode { - UPPER, - LOWER; -} \ No newline at end of file diff --git a/src/it/java/org/seedstack/validation/internal/custom/CheckCase.java b/src/it/java/org/seedstack/validation/internal/custom/CheckCase.java deleted file mode 100644 index 3d70d58..0000000 --- a/src/it/java/org/seedstack/validation/internal/custom/CheckCase.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.custom; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE}) -@Retention(RUNTIME) -@Constraint(validatedBy = CheckCaseValidator.class) -@Documented -public @interface CheckCase { - - String message() default "{org.hibernate.validator.referenceguide.chapter06.CheckCase." + - "message}"; - - Class[] groups() default {}; - - Class[] payload() default {}; - - CaseMode value(); - - @Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE}) - @Retention(RUNTIME) - @Documented - @interface List { - CheckCase[] value(); - } -} \ No newline at end of file diff --git a/src/it/java/org/seedstack/validation/internal/custom/CheckCaseValidator.java b/src/it/java/org/seedstack/validation/internal/custom/CheckCaseValidator.java deleted file mode 100644 index 7a4c1cd..0000000 --- a/src/it/java/org/seedstack/validation/internal/custom/CheckCaseValidator.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.custom; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -public class CheckCaseValidator implements ConstraintValidator { - - private CaseMode caseMode; - - @Override - public void initialize(CheckCase constraintAnnotation) { - this.caseMode = constraintAnnotation.value(); - } - - @Override - public boolean isValid(String object, ConstraintValidatorContext constraintContext) { - if (object == null) { - return true; - } - - if (caseMode == CaseMode.UPPER) { - return object.equals(object.toUpperCase()); - } else { - return object.equals(object.toLowerCase()); - } - } -} \ No newline at end of file diff --git a/src/it/java/org/seedstack/validation/internal/pojo/Bean.java b/src/it/java/org/seedstack/validation/internal/pojo/Bean.java deleted file mode 100644 index 02a2e26..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/Bean.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import javax.validation.constraints.Max; - -public class Bean { - - private int hour; - - @Max(24) - public int getHour() { - return hour; - } - - public void setHour(int hour) { - this.hour = hour; - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/CustomPojo.java b/src/it/java/org/seedstack/validation/internal/pojo/CustomPojo.java deleted file mode 100644 index f9520a7..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/CustomPojo.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import org.seedstack.validation.internal.custom.CaseMode; -import org.seedstack.validation.internal.custom.CheckCase; - -public class CustomPojo { - @CheckCase(CaseMode.UPPER) - private final String item; - - public CustomPojo(String item) { - this.item = item; - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/FieldValidationKO.java b/src/it/java/org/seedstack/validation/internal/pojo/FieldValidationKO.java deleted file mode 100644 index cfcbf06..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/FieldValidationKO.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import org.seedstack.seed.it.ITBind; - -import javax.validation.constraints.NotNull; - - -@ITBind -public class FieldValidationKO { - - @NotNull - private Object param; - - public void doSomethingAwesome(Object param) { - this.param = param; - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/FieldValidationOK.java b/src/it/java/org/seedstack/validation/internal/pojo/FieldValidationOK.java deleted file mode 100644 index 5d26f00..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/FieldValidationOK.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import org.seedstack.seed.it.ITBind; - -import javax.validation.constraints.NotNull; - - -@ITBind -public class FieldValidationOK { - - @NotNull - private Object param = new Object(); - - public void doSomethingAwesome(Object param) { - this.param = param; - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/MyImpl.java b/src/it/java/org/seedstack/validation/internal/pojo/MyImpl.java deleted file mode 100644 index add17bd..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/MyImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -public class MyImpl implements MyInterface { - - private int color; - - @Override - public int getColor() { - return color; - } - - @Override - public void setColor(int color) { - this.color = color; - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/MyInterface.java b/src/it/java/org/seedstack/validation/internal/pojo/MyInterface.java deleted file mode 100644 index 2dc8425..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/MyInterface.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import javax.validation.constraints.Min; - -public interface MyInterface { - - @Min(1) - int getColor(); - - void setColor(int color); -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/ParamReturnType.java b/src/it/java/org/seedstack/validation/internal/pojo/ParamReturnType.java deleted file mode 100644 index c698be1..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/ParamReturnType.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import org.seedstack.seed.it.ITBind; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - - -@ITBind -public class ParamReturnType { - - @NotNull - public Object validateNotNullReturn(Object param) { - return param; - } - - @Valid - public Pojo validateValidReturn(Pojo.State state) { - return new Pojo(state); - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/ParamValidation.java b/src/it/java/org/seedstack/validation/internal/pojo/ParamValidation.java deleted file mode 100644 index 8493bc8..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/ParamValidation.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import org.seedstack.seed.it.ITBind; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - - -@ITBind -public class ParamValidation { - - public void validateNotNullParam(@NotNull Object param) { - } - - public void validateValidParam(@Valid Pojo param) { - } -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/Pojo.java b/src/it/java/org/seedstack/validation/internal/pojo/Pojo.java deleted file mode 100644 index 8a9603f..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/Pojo.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import javax.validation.constraints.AssertFalse; -import javax.validation.constraints.Max; -import javax.validation.constraints.Size; - -public class Pojo { - - @Size(min = 5) - private String name = "yoda"; - - @Max(100) - private int age = 10000; - - @AssertFalse - private boolean dead = true; - - public enum State { - VALID, - INVALID - } - - public Pojo(State state) { - if (State.INVALID.equals(state)) { - createInvalidPojo(); - } else { - createValidPojo(); - } - } - - private void createValidPojo() { - name = "yodaa"; - age = 99; - dead = false; - } - - private void createInvalidPojo() { - name = "yoda"; - age = 10000; - dead = true; - } - - public String getName() { - return this.name; - } - -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/PojoWithDeepValidation.java b/src/it/java/org/seedstack/validation/internal/pojo/PojoWithDeepValidation.java deleted file mode 100644 index 021b634..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/PojoWithDeepValidation.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - -import javax.validation.Valid; -import javax.validation.constraints.Null; - -public class PojoWithDeepValidation { - - @Null - String str = "should be null"; - - @Valid - private Pojo pojo = new Pojo(Pojo.State.INVALID); -} diff --git a/src/it/java/org/seedstack/validation/internal/pojo/WithoutValidation.java b/src/it/java/org/seedstack/validation/internal/pojo/WithoutValidation.java deleted file mode 100644 index 1311ffd..0000000 --- a/src/it/java/org/seedstack/validation/internal/pojo/WithoutValidation.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.pojo; - - -import org.seedstack.seed.it.ITBind; - -@ITBind -public class WithoutValidation { - - public void doSomethingAweswome(Object param) { - } -} diff --git a/src/it/resources/logback-test.xml b/src/it/resources/logback-test.xml deleted file mode 100644 index a92e301..0000000 --- a/src/it/resources/logback-test.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - \ No newline at end of file diff --git a/src/main/java/org/seedstack/validation/ValidationException.java b/src/main/java/org/seedstack/validation/ValidationException.java deleted file mode 100644 index 297a89a..0000000 --- a/src/main/java/org/seedstack/validation/ValidationException.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation; - - -import org.seedstack.seed.ErrorCode; -import org.seedstack.seed.SeedException; - -/** - * Exception class for validation errors. - * - * @author epo.jemba@ext.mpsa.com - * @deprecated This exception is no longer used and will be removed in the next version. - * Use the standard {@link javax.validation.ConstraintViolationException} instead. - */ -@Deprecated -public class ValidationException extends SeedException { - - public ValidationException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/org/seedstack/validation/ValidationService.java b/src/main/java/org/seedstack/validation/ValidationService.java deleted file mode 100644 index 42d5c23..0000000 --- a/src/main/java/org/seedstack/validation/ValidationService.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation; - -import org.aopalliance.intercept.MethodInvocation; - -import java.lang.reflect.Method; - -/** - * Interface for validation service. - * - * @author epo.jemba@ext.mpsa.com - * @deprecated ValidationService will be removed in the next version. Use {@link javax.validation.Validator} instead. - * It can be directly injected or retrieved through the {@link javax.validation.ValidatorFactory}. - */ -@Deprecated -public interface ValidationService { - - String JAVAX_VALIDATION_CONSTRAINT_VIOLATIONS = "Set"; - - /** - * Validate a class statically. - * - * @param the type of the class to validate. - * @param candidate the class to validate. - */ - void staticallyHandle(T candidate); - - /** - * Dynamically validate an intercepted method invocation. - * - * @param invocation the {@link org.aopalliance.intercept.MethodInvocation} to execute. - * @return the return value of the invocation. - * @throws Throwable if anything goes wrong during the invocation. - */ - Object dynamicallyHandleAndProceed(MethodInvocation invocation) throws Throwable; - - /** - * Checks if the class can be statically validated. - * - * @param candidate the class to assess. - * @return true if it can be statically validated, false otherwise. - */ - boolean candidateForStaticValidation(Class candidate); - - /** - * Checks if a method can be dynamically validated. - * - * @param candidate the method to assess. - * @return true if it can be dynamically validated, false otherwise. - */ - boolean candidateForDynamicValidation(Method candidate); - - /** - * Checks if a class can be dynamically validated. - * - * @param candidate the class to assess. - * @return true if it can be dynamically validated, false otherwise. - */ - boolean candidateForDynamicValidation(Class candidate); - -} \ No newline at end of file diff --git a/src/main/java/org/seedstack/validation/api/VerboseConstraintViolationException.java b/src/main/java/org/seedstack/validation/api/VerboseConstraintViolationException.java deleted file mode 100644 index 11b7beb..0000000 --- a/src/main/java/org/seedstack/validation/api/VerboseConstraintViolationException.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.api; - -import org.seedstack.seed.core.utils.SeedReflectionUtils; - -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import java.util.Set; - -/** - * This exception class formats a fully detailed message from a set of constraint violations or from an existing - * {@link ConstraintViolationException}. - */ -public class VerboseConstraintViolationException extends ConstraintViolationException { - /** - * Creates a verbose {@link ConstraintViolationException} from a set of constraint violations. - * - * @param constraintViolations the set of contraint violations. - */ - public VerboseConstraintViolationException(final Set> constraintViolations) { - super(createVerboseMessage(constraintViolations), constraintViolations); - } - - /** - * Creates a verbose {@link ConstraintViolationException} from an existing one. - * - * @param constraintViolationException the existing exception. - */ - public VerboseConstraintViolationException(final ConstraintViolationException constraintViolationException) { - this(constraintViolationException.getConstraintViolations()); - } - - private static String createVerboseMessage(final Set> constraintViolations) { - final StringBuilder sb = new StringBuilder(1024); - boolean first = true; - for (final ConstraintViolation constraintViolation : constraintViolations) { - if (first) { - sb.append(SeedReflectionUtils.cleanProxy(constraintViolation.getRootBeanClass()).getCanonicalName()).append("\n"); - first = false; - } - sb.append("\t"); - sb.append(constraintViolation.getPropertyPath()); - sb.append(": "); - sb.append(constraintViolation.getMessage()); - sb.append(" ('"); - sb.append(constraintViolation.getInvalidValue()); - sb.append("')\n"); - } - return sb.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/org/seedstack/validation/api/package-info.java b/src/main/java/org/seedstack/validation/api/package-info.java deleted file mode 100644 index fccbc85..0000000 --- a/src/main/java/org/seedstack/validation/api/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -/** - * Provides classes for using validation. - * - * @author Pierre Thirouin - */ -package org.seedstack.validation.api; \ No newline at end of file diff --git a/src/main/java/org/seedstack/validation/internal/MethodValidationInterceptor.java b/src/main/java/org/seedstack/validation/internal/MethodValidationInterceptor.java deleted file mode 100644 index 1a344d8..0000000 --- a/src/main/java/org/seedstack/validation/internal/MethodValidationInterceptor.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; - -class MethodValidationInterceptor implements MethodInterceptor { - private final ValidationService validationService; - - MethodValidationInterceptor(ValidationService validationService) { - this.validationService = validationService; - } - - @Override - public Object invoke(MethodInvocation invocation) throws Throwable { - return this.validationService.dynamicallyHandleAndProceed(invocation); - } - -} diff --git a/src/main/java/org/seedstack/validation/internal/StaticValidationProvisionListener.java b/src/main/java/org/seedstack/validation/internal/StaticValidationProvisionListener.java deleted file mode 100644 index 8dca89c..0000000 --- a/src/main/java/org/seedstack/validation/internal/StaticValidationProvisionListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import com.google.inject.spi.ProvisionListener; - -/** - * Validates provisioned instances eligible for static validation. - */ -class StaticValidationProvisionListener implements ProvisionListener { - - private ValidationService validationService; - - public StaticValidationProvisionListener(ValidationService validationService) { - this.validationService = validationService; - } - - @Override - public void onProvision(ProvisionInvocation provision) { - A injectee = provision.provision(); - validationService.staticallyHandle(injectee); - } -} diff --git a/src/main/java/org/seedstack/validation/internal/ValidationConcern.java b/src/main/java/org/seedstack/validation/internal/ValidationConcern.java deleted file mode 100644 index 27e3869..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationConcern.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import io.nuun.kernel.spi.Concern; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -@Concern(name = "validation", priority = Concern.Priority.HIGHER) -@interface ValidationConcern { - -} diff --git a/src/main/java/org/seedstack/validation/internal/ValidationErrorCode.java b/src/main/java/org/seedstack/validation/internal/ValidationErrorCode.java deleted file mode 100644 index 89dec55..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationErrorCode.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.seedstack.seed.ErrorCode; - -enum ValidationErrorCode implements ErrorCode { - DYNAMIC_VALIDATION_IS_NOT_SUPPORTED -} diff --git a/src/main/java/org/seedstack/validation/internal/ValidationExceptionMapper.java b/src/main/java/org/seedstack/validation/internal/ValidationExceptionMapper.java deleted file mode 100644 index 979edfb..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationExceptionMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import javax.validation.ConstraintViolationException; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -@Provider -public class ValidationExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(ConstraintViolationException exception) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } -} diff --git a/src/main/java/org/seedstack/validation/internal/ValidationModule.java b/src/main/java/org/seedstack/validation/internal/ValidationModule.java deleted file mode 100644 index 22f94bc..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationModule.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import com.google.inject.AbstractModule; -import com.google.inject.Binding; -import com.google.inject.Provides; -import com.google.inject.matcher.AbstractMatcher; -import com.google.inject.matcher.Matcher; -import com.google.inject.matcher.Matchers; -import org.seedstack.seed.core.utils.SeedLoggingUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import javax.validation.executable.ExecutableValidator; -import java.lang.reflect.Method; - -@ValidationConcern -class ValidationModule extends AbstractModule { - private static final Logger LOGGER = LoggerFactory.getLogger(ValidationModule.class); - - private final ValidatorFactory validatorFactory; - private final ValidationService validationService; - - ValidationModule(ValidatorFactory validatorFactory, ValidationService validationService) { - this.validatorFactory = validatorFactory; - this.validationService = validationService; - } - - @Override - protected void configure() { - bind(ValidatorFactory.class).toInstance(validatorFactory); - enableValidationOnInjectionPoints(); - if (isDynamicValidationSupported()) { - configureDynamicValidation(); - requestInjection(validationService); - bind(ValidationService.class).toInstance(validationService); - } - } - - private void enableValidationOnInjectionPoints() { - bindListener(staticValidationMatcher(validationService), new StaticValidationProvisionListener(validationService)); - } - - private void configureDynamicValidation() { - bindInterceptor(Matchers.any(), dynamicValidationMatcher(validationService), new MethodValidationInterceptor(validationService)); - } - - private boolean isDynamicValidationSupported() { - ExecutableValidator executableValidator = null; - try { - executableValidator = validatorFactory.getValidator().forExecutables(); - } catch (Throwable t) { - SeedLoggingUtils.logWarningWithDebugDetails(LOGGER, t, "Unable to create the dynamic validator, support for dynamic validation disabled"); - } - return executableValidator != null; - } - - @Provides - Validator provideValidator() { - return validatorFactory.getValidator(); - } - - private Matcher> staticValidationMatcher(final ValidationService validationService) { - return new AbstractMatcher>() { - @Override - public boolean matches(Binding t) { - return validationService.candidateForStaticValidation(t.getKey().getTypeLiteral().getRawType()); - } - }; - } - - private Matcher dynamicValidationMatcher(final ValidationService validationService) { - return new AbstractMatcher() { - @Override - public boolean matches(Method t) { - return validationService.candidateForDynamicValidation(t); - } - }; - } - -} diff --git a/src/main/java/org/seedstack/validation/internal/ValidationPlugin.java b/src/main/java/org/seedstack/validation/internal/ValidationPlugin.java deleted file mode 100644 index df3eb00..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationPlugin.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import io.nuun.kernel.api.plugin.InitState; -import io.nuun.kernel.api.plugin.context.InitContext; -import io.nuun.kernel.core.AbstractPlugin; -import org.seedstack.seed.core.utils.SeedReflectionUtils; -import org.seedstack.validation.spi.ValidationProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.validation.Validation; -import javax.validation.ValidatorFactory; - -/** - * This plugin handles validation through jsr303 and jsr349. - */ -public class ValidationPlugin extends AbstractPlugin implements ValidationProvider { - private static Logger logger = LoggerFactory.getLogger(ValidationPlugin.class); - private ValidatorFactory validatorFactory = null; - - @Override - public String name() { - return "validation"; - } - - @Override - public InitState init(InitContext initContext) { - if (SeedReflectionUtils.isClassPresent("javax.validation.Validation")) { - validatorFactory = Validation.buildDefaultValidatorFactory(); - } else { - logger.info("Validation API is not available, validation is disabled"); - } - - return InitState.INITIALIZED; - } - - @Override - public Object nativeUnitModule() { - if (validatorFactory != null) { - return new ValidationModule(validatorFactory, new ValidationServiceInternal()); - } else { - return null; - } - } - - @Override - public void stop() { - if (validatorFactory != null) { - validatorFactory.close(); - } - } - - @Override - public ValidatorFactory getValidatorFactory() { - return validatorFactory; - } -} diff --git a/src/main/java/org/seedstack/validation/internal/ValidationService.java b/src/main/java/org/seedstack/validation/internal/ValidationService.java deleted file mode 100644 index d160083..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationService.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -/** - * Interface for validation service. - */ -interface ValidationService extends org.seedstack.validation.ValidationService { - -} \ No newline at end of file diff --git a/src/main/java/org/seedstack/validation/internal/ValidationServiceInternal.java b/src/main/java/org/seedstack/validation/internal/ValidationServiceInternal.java deleted file mode 100644 index 6d9931e..0000000 --- a/src/main/java/org/seedstack/validation/internal/ValidationServiceInternal.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - - -import org.aopalliance.intercept.MethodInvocation; -import org.seedstack.seed.SeedException; -import org.seedstack.seed.core.utils.SeedReflectionUtils; -import org.seedstack.validation.api.VerboseConstraintViolationException; - -import javax.inject.Inject; -import javax.validation.*; -import javax.validation.executable.ExecutableValidator; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Set; - -import static org.seedstack.seed.core.utils.SeedReflectionUtils.cleanProxy; - -class ValidationServiceInternal implements ValidationService { - - @Inject - private ValidatorFactory validatorFactory; - - @Override - public void staticallyHandle(T candidate) { - Set> constraintViolations = validatorFactory.getValidator().validate(candidate); - throwsExceptionIfViolation(constraintViolations); - } - - private void throwsExceptionIfViolation(Set> constraintViolations) { - if (!constraintViolations.isEmpty()) { - throw new VerboseConstraintViolationException(constraintViolations); - } - } - - @Override - public Object dynamicallyHandleAndProceed(MethodInvocation invocation) throws Throwable { - ExecutableValidator executableValidator = validatorFactory.getValidator().forExecutables(); - if (executableValidator == null) { - throw SeedException.createNew(ValidationErrorCode.DYNAMIC_VALIDATION_IS_NOT_SUPPORTED); - } - // TODO : add support for constraint groups - - validateParameters(invocation, executableValidator); - Object returnValue = invocation.proceed(); - validateReturnValue(invocation, executableValidator, returnValue); - return returnValue; - } - - private void validateParameters(MethodInvocation invocation, ExecutableValidator executableValidator) { - Set> parametersConstraintViolations = executableValidator - .validateParameters(invocation.getThis(), invocation.getMethod(), invocation.getArguments() /*, groups */); - throwsExceptionIfViolation(parametersConstraintViolations); - } - - private void validateReturnValue(MethodInvocation invocation, ExecutableValidator executableValidator, Object returnValue) { - Set> returnValueConstraintViolations = executableValidator - .validateReturnValue(invocation.getThis(), invocation.getMethod(), returnValue /*, groups*/); - throwsExceptionIfViolation(returnValueConstraintViolations); - } - - @Override - public boolean candidateForStaticValidation(Class candidate) { - for (Field field : candidate.getDeclaredFields()) { - for (Annotation annotation : field.getAnnotations()) { - if (hasConstraintOrValidAnnotation(annotation)) { - return true; - } - } - } - return false; - } - - private boolean hasConstraintOrValidAnnotation(Annotation annotation) { - return SeedReflectionUtils.hasAnnotationDeep(annotation.annotationType(), Constraint.class) || Valid.class.equals(annotation.annotationType()); - } - - @Override - public boolean candidateForDynamicValidation(Class candidate) { - for (Method method : candidate.getDeclaredMethods()) { - if (candidateForDynamicValidation(method)) { - return true; - } - } - return false; - } - - @Override - public boolean candidateForDynamicValidation(Method candidate) { - return shouldValidateParameters(candidate) || shouldValidateReturnType(candidate); - } - - private boolean shouldValidateParameters(Method candidate) { - for (Annotation[] annotationsForOneParameter : candidate.getParameterAnnotations()) { - for (Annotation annotation : annotationsForOneParameter) { - if (hasConstraintOrValidAnnotation(annotation)) { - return true; - } - } - } - return false; - } - - private boolean shouldValidateReturnType(Method candidate) { - for (Annotation annotation : candidate.getAnnotations()) { - if (hasConstraintOrValidAnnotation(annotation)) { - return true; - } - } - return false; - } -} diff --git a/src/main/java/org/seedstack/validation/package-info.java b/src/main/java/org/seedstack/validation/package-info.java deleted file mode 100644 index 4612345..0000000 --- a/src/main/java/org/seedstack/validation/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -/** - * Provides classes for using Java Bean Validation. - * - * @author Pierre Thirouin - */ -package org.seedstack.validation; \ No newline at end of file diff --git a/src/main/java/org/seedstack/validation/spi/ValidationProvider.java b/src/main/java/org/seedstack/validation/spi/ValidationProvider.java deleted file mode 100644 index 340ef00..0000000 --- a/src/main/java/org/seedstack/validation/spi/ValidationProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.spi; - -import io.nuun.kernel.api.annotations.Facet; - -import javax.validation.ValidatorFactory; - -/** - * Provides access to bean validation. - */ -@Facet -public interface ValidationProvider { - /** - * Retrieves the initialized {@link ValidatorFactory}. - * - * @return An instance of {@link ValidatorFactory} if validation is enabled, null otherwise. - */ - ValidatorFactory getValidatorFactory(); -} diff --git a/src/main/java/org/seedstack/validation/spi/package-info.java b/src/main/java/org/seedstack/validation/spi/package-info.java deleted file mode 100644 index 6014d91..0000000 --- a/src/main/java/org/seedstack/validation/spi/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -/** - * Provides classes for extending validation. - * - * @author Pierre Thirouin - */ -package org.seedstack.validation.spi; \ No newline at end of file diff --git a/src/main/resources/META-INF/services/io.nuun.kernel.api.Plugin b/src/main/resources/META-INF/services/io.nuun.kernel.api.Plugin deleted file mode 100644 index 0822288..0000000 --- a/src/main/resources/META-INF/services/io.nuun.kernel.api.Plugin +++ /dev/null @@ -1 +0,0 @@ -org.seedstack.validation.internal.ValidationPlugin \ No newline at end of file diff --git a/src/test/java/org/seedstack/validation/internal/ValidationExceptionMapperTest.java b/src/test/java/org/seedstack/validation/internal/ValidationExceptionMapperTest.java deleted file mode 100644 index 91831ba..0000000 --- a/src/test/java/org/seedstack/validation/internal/ValidationExceptionMapperTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - -import org.assertj.core.api.Assertions; -import org.junit.Test; - -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; -import java.util.HashSet; - -public class ValidationExceptionMapperTest { - - @Test - public void testIsProvider() { - ValidationExceptionMapper.class.isAnnotationPresent(Provider.class); - } - - @Test - public void testReturnError400() { - Response response = new ValidationExceptionMapper() - .toResponse(new ConstraintViolationException("error message", new HashSet>())); - Assertions.assertThat(response.getStatus()).isEqualTo(400); - } -} diff --git a/src/test/java/org/seedstack/validation/internal/ValidationServiceTest.java b/src/test/java/org/seedstack/validation/internal/ValidationServiceTest.java deleted file mode 100644 index 10582d3..0000000 --- a/src/test/java/org/seedstack/validation/internal/ValidationServiceTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal; - - -import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; -import org.seedstack.validation.internal.fixtures.*; - -public class ValidationServiceTest { - - private ValidationService underTest; - - @Before - public void init() { - underTest = new ValidationServiceInternal(); - } - - @Test - public void isCandidateForStaticValidation() { - Assertions.assertThat(underTest.candidateForStaticValidation(BeanField.class)).isTrue(); - Assertions.assertThat(underTest.candidateForStaticValidation(BeanAll.class)).isTrue(); - } - - @Test - public void isNotCandidateForStaticValidation() { - Assertions.assertThat(underTest.candidateForStaticValidation(BeanNominal.class)).isFalse(); - } - - @Test - public void isCandidateForDynamicValidation() { - Assertions.assertThat(underTest.candidateForDynamicValidation(BeanMethodParam.class)).isTrue(); - Assertions.assertThat(underTest.candidateForDynamicValidation(BeanMethodReturnType.class)).isTrue(); - Assertions.assertThat(underTest.candidateForDynamicValidation(BeanAll.class)).isTrue(); - } - - @Test - public void isNotCandidateForDynamicValidation() { - Assertions.assertThat(underTest.candidateForDynamicValidation(BeanNominal.class)).isFalse(); - } - -} diff --git a/src/test/java/org/seedstack/validation/internal/fixtures/BeanAll.java b/src/test/java/org/seedstack/validation/internal/fixtures/BeanAll.java deleted file mode 100644 index c596e98..0000000 --- a/src/test/java/org/seedstack/validation/internal/fixtures/BeanAll.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.fixtures; - -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -public class BeanAll { - private int age; - - private Long longNumber; - - private String name; - - private String firstName; - - @NotNull(message = "Description obligatoire") - @Size(min = 1, max = 10) - private String description; - - public int getAge() { - return age; - } - - public void setAge(@Range(min = 0, max = 200) int age) { - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(@NotNull(message = "Nom obligatoire") @Size(min = 1, max = 10) String name) { - this.name = name; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(@NotNull(groups = {Group1Checks.class}) String firstName) { - this.firstName = firstName; - } - - public Long getLongNumber() { - return longNumber; - } - - public void setLongNumber(@NotNull @Min(value = 10L) @Max(value = 999999999999999999L) Long longNumber) { - this.longNumber = longNumber; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - -} diff --git a/src/test/java/org/seedstack/validation/internal/fixtures/BeanField.java b/src/test/java/org/seedstack/validation/internal/fixtures/BeanField.java deleted file mode 100644 index e0050cb..0000000 --- a/src/test/java/org/seedstack/validation/internal/fixtures/BeanField.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.fixtures; - -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -public class BeanField { - @Range(min = 0, max = 200) - private int age; - - @NotNull - @Range(min = 10L, max = 999999999999999999L) - private Long longNumber; - - @NotNull(message = "Nom obligatoire") - @Size(min = 1, max = 10) - private String name; - - @NotNull(groups = {Group1Checks.class}) - private String firstName; - - public BeanField() { - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public Long getLongNumber() { - return longNumber; - } - - public void setLongNumber(Long longNumber) { - this.longNumber = longNumber; - } - -} diff --git a/src/test/java/org/seedstack/validation/internal/fixtures/BeanMethodParam.java b/src/test/java/org/seedstack/validation/internal/fixtures/BeanMethodParam.java deleted file mode 100644 index 72417d1..0000000 --- a/src/test/java/org/seedstack/validation/internal/fixtures/BeanMethodParam.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.fixtures; - -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -public class BeanMethodParam { - private int age; - - private Long longNumber; - - private String name; - - private String firstName; - - - public int getAge() { - return age; - } - - public void setAge(@Range(min = 0, max = 200) int age) { - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(@NotNull(message = "Nom obligatoire") @Size(min = 1, max = 10) String name) { - this.name = name; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(@NotNull(groups = {Group1Checks.class}) String firstName) { - this.firstName = firstName; - } - - public Long getLongNumber() { - return longNumber; - } - - public void setLongNumber( - @NotNull @Min(value = 10L) @Max(value = 999999999999999999L) - Long longNumber) { - this.longNumber = longNumber; - } - - -} diff --git a/src/test/java/org/seedstack/validation/internal/fixtures/BeanMethodReturnType.java b/src/test/java/org/seedstack/validation/internal/fixtures/BeanMethodReturnType.java deleted file mode 100644 index f8f5d65..0000000 --- a/src/test/java/org/seedstack/validation/internal/fixtures/BeanMethodReturnType.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.fixtures; - -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -public class BeanMethodReturnType { - - private int age; - - private Long longNumber; - - private String name; - - private String firstName; - - @Range(min = 0, max = 200) - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - @NotNull(message = "Nom obligatoire") - @Size(min = 1, max = 10) - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @NotNull(groups = {Group1Checks.class}) - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - @NotNull - @Min(value = 10L) - @Max(value = 999999999999999999L) - public Long getLongNumber() { - return longNumber; - } - - public void setLongNumber(Long longNumber) { - this.longNumber = longNumber; - } - -} diff --git a/src/test/java/org/seedstack/validation/internal/fixtures/BeanNominal.java b/src/test/java/org/seedstack/validation/internal/fixtures/BeanNominal.java deleted file mode 100644 index fb5ef15..0000000 --- a/src/test/java/org/seedstack/validation/internal/fixtures/BeanNominal.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.fixtures; - - -public class BeanNominal { - private int age; - - private Long longNumber; - - private String name; - - private String firstName; - - public BeanNominal() { - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public Long getLongNumber() { - return longNumber; - } - - public void setLongNumber(Long longNumber) { - this.longNumber = longNumber; - } - -} diff --git a/src/test/java/org/seedstack/validation/internal/fixtures/Group1Checks.java b/src/test/java/org/seedstack/validation/internal/fixtures/Group1Checks.java deleted file mode 100644 index 7d08a49..0000000 --- a/src/test/java/org/seedstack/validation/internal/fixtures/Group1Checks.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) 2013-2016, The SeedStack authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.seedstack.validation.internal.fixtures; - -public interface Group1Checks { -}