forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for a bean where constraints are defined only in an XML
- Loading branch information
1 parent
0242fd5
commit 19d8764
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ts/hibernate-validator/src/main/java/io/quarkus/it/hibernate/validator/xml/MyXmlBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.quarkus.it.hibernate.validator.xml; | ||
|
||
public class MyXmlBean { | ||
int id = 0; | ||
String name; | ||
} |
19 changes: 19 additions & 0 deletions
19
...in/java/io/quarkus/it/hibernate/validator/xml/ValidationServiceBasedOnXmlConstraints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.quarkus.it.hibernate.validator.xml; | ||
|
||
import java.util.Set; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.validation.ConstraintViolation; | ||
import jakarta.validation.Validator; | ||
|
||
@ApplicationScoped | ||
public class ValidationServiceBasedOnXmlConstraints { | ||
|
||
@Inject | ||
Validator validator; | ||
|
||
public Set<ConstraintViolation<MyXmlBean>> validateSomeMyXmlBean() { | ||
return validator.validate(new MyXmlBean()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
integration-tests/hibernate-validator/src/main/resources/META-INF/validation.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<validation-config | ||
xmlns="https://jakarta.ee/xml/ns/validation/configuration" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/validation/configuration https://jakarta.ee/xml/ns/validation/validation-configuration-3.0.xsd" | ||
version="3.0"> | ||
<constraint-mapping>META-INF/validation/constraints-my-xml-bean.xml</constraint-mapping> | ||
</validation-config> |
15 changes: 15 additions & 0 deletions
15
...ts/hibernate-validator/src/main/resources/META-INF/validation/constraints-my-xml-bean.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<constraint-mappings | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/validation/mapping https://jakarta.ee/xml/ns/validation/validation-mapping-3.0.xsd" | ||
xmlns="https://jakarta.ee/xml/ns/validation/mapping" version="3.0"> | ||
|
||
<bean class="io.quarkus.it.hibernate.validator.xml.MyXmlBean"> | ||
<field name="id"> | ||
<constraint annotation="jakarta.validation.constraints.Positive"/> | ||
</field> | ||
<field name="name"> | ||
<constraint annotation="jakarta.validation.constraints.NotNull"/> | ||
</field> | ||
</bean> | ||
</constraint-mappings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters