-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/jooby hibernate validator #3508
Merged
jknack
merged 15 commits into
jooby-project:3.x
from
kliushnichenko:feat/jooby-hibernate-validator
Sep 5, 2024
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
daca727
jooby-hbv module draft
kliushnichenko 1bf0e00
jooby-hbv module draft
kliushnichenko 887dc9d
rollback core changes
kliushnichenko 8d71495
cleanup hbv module
kliushnichenko 06eb67e
basic implementation for MVC
kliushnichenko 7adc2a2
rebase
kliushnichenko 951a459
Merge remote-tracking branch 'origin/feat/jooby-hbv' into feat/jooby-hbv
kliushnichenko 646f355
rollback core changes
kliushnichenko 229b584
error handler, tests, refactoring
kliushnichenko a470d9b
resolve discussions
kliushnichenko baf422e
mvc validation revisited
kliushnichenko c23d4b0
javadoc, support configuration over hocon config
kliushnichenko 8b79308
hibernate-validator module ascii doc
kliushnichenko 84c8f93
Merge branch '3.x' into feat/jooby-hibernate-validator
kliushnichenko 4d73e31
update version to 3.3.1-SNAPSHOT
kliushnichenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
19 changes: 19 additions & 0 deletions
19
modules/jooby-apt/src/test/java/tests/validation/Bean.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 tests.validation; | ||
|
||
import io.jooby.Context; | ||
|
||
class Bean { | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public static Bean map(Context ctx) { | ||
return ctx.body(Bean.class); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
modules/jooby-apt/src/test/java/tests/validation/BeanValidationGeneratorTest.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,36 @@ | ||
package tests.validation; | ||
|
||
import io.jooby.apt.ProcessorRunner; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class BeanValidationGeneratorTest { | ||
|
||
@Test | ||
public void generate_validation_forBean() throws Exception { | ||
new ProcessorRunner(new BeanValidationsController()).withSource( | ||
false, | ||
source -> { | ||
assertTrue(source.contains( | ||
"c.validateQueryBean(io.jooby.validation.BeanValidator.validate(ctx, ctx.query(\"bean\").isMissing() ? ctx.query().toNullable(tests.validation.Bean.class) : ctx.query(\"bean\").toNullable(tests.validation.Bean.class)))") | ||
); | ||
|
||
assertTrue(source.contains( | ||
"c.validateFormBean(io.jooby.validation.BeanValidator.validate(ctx, ctx.form(\"bean\").isMissing() ? ctx.form().toNullable(tests.validation.Bean.class) : ctx.form(\"bean\").toNullable(tests.validation.Bean.class)))") | ||
); | ||
|
||
assertTrue(source.contains( | ||
"c.validateBindParamBean(io.jooby.validation.BeanValidator.validate(ctx, tests.validation.Bean.map(ctx)))") | ||
); | ||
|
||
assertTrue(source.contains( | ||
"c.validateBodyBean(io.jooby.validation.BeanValidator.validate(ctx, ctx.body(tests.validation.Bean.class)))") | ||
); | ||
|
||
assertTrue(source.contains( | ||
"c.validateListOfBodyBeans(io.jooby.validation.BeanValidator.validate(ctx, ctx.body(io.jooby.Reified.list(tests.validation.Bean.class).getType())))") | ||
); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
modules/jooby-apt/src/test/java/tests/validation/BeanValidationsController.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,40 @@ | ||
package tests.validation; | ||
|
||
import io.jooby.annotation.*; | ||
import jakarta.validation.Valid; | ||
|
||
import java.util.List; | ||
|
||
public class BeanValidationsController { | ||
|
||
@POST("/validate/query-bean") | ||
public Bean validateQueryBean(@Valid @QueryParam Bean bean) { | ||
return bean; | ||
} | ||
|
||
@POST("/validate/form-bean") | ||
public Bean validateFormBean(@Valid @FormParam Bean bean) { | ||
return bean; | ||
} | ||
|
||
//todo: revive when flash `toNullable` will be fixed | ||
// @POST("/validate/flash-bean") | ||
// public Bean validateFlashBean(@Valid @FlashParam Bean bean) { | ||
// return bean; | ||
// } | ||
|
||
@POST("/validate/bind-param-bean") | ||
public Bean validateBindParamBean(@Valid @BindParam Bean bean) { | ||
return bean; | ||
} | ||
|
||
@POST("/validate/body-bean") | ||
public Bean validateBodyBean(@Valid Bean bean) { | ||
return bean; | ||
} | ||
|
||
@POST("/validate/list-of-body-beans") | ||
public List<Bean> validateListOfBodyBeans(@Valid List<Bean> bean) { | ||
return bean; | ||
} | ||
} |
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,119 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>modules</artifactId> | ||
<version>3.2.10-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>jooby-hibernate-validator</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>jooby</artifactId> | ||
<version>${jooby.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>jooby-validation</artifactId> | ||
<version>${jooby.version}</version> | ||
</dependency> | ||
|
||
<!-- Hibernate Validator --> | ||
<dependency> | ||
<groupId>org.hibernate.validator</groupId> | ||
<artifactId>hibernate-validator</artifactId> | ||
<version>8.0.1.Final</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.el</groupId> | ||
<artifactId>jakarta.el-api</artifactId> | ||
<version>5.0.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.glassfish.expressly</groupId> | ||
<artifactId>expressly</artifactId> | ||
<version>5.0.0</version> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>jooby-netty</artifactId> | ||
<version>${jooby.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>jooby-jackson</artifactId> | ||
<version>${jooby.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>jooby-test</artifactId> | ||
<version>${jooby.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.26.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>test</id> | ||
<phase>test-compile</phase> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-parameters</arg> | ||
</compilerArgs> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.jooby</groupId> | ||
<artifactId>jooby-apt</artifactId> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
jooby-hibernate-validator