-
-
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
cleanup validation tests #3534
Merged
jknack
merged 2 commits into
jooby-project:3.x
from
kliushnichenko:validation-tests-cleanup
Sep 18, 2024
Merged
cleanup validation tests #3534
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
52 changes: 52 additions & 0 deletions
52
modules/jooby-apt/src/main/java/io/jooby/internal/apt/Types.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,52 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package io.jooby.internal.apt; | ||
|
||
import java.net.URI; | ||
import java.net.URL; | ||
import java.time.Duration; | ||
import java.time.Period; | ||
import java.time.ZoneId; | ||
import java.util.Set; | ||
import java.util.TimeZone; | ||
|
||
class Types { | ||
static final Set<String> BUILT_IN = | ||
Set.of( | ||
String.class.getName(), | ||
Boolean.class.getName(), | ||
Boolean.TYPE.getName(), | ||
Byte.class.getName(), | ||
Byte.TYPE.getName(), | ||
Character.class.getName(), | ||
Character.TYPE.getName(), | ||
Short.class.getName(), | ||
Short.TYPE.getName(), | ||
Integer.class.getName(), | ||
Integer.TYPE.getName(), | ||
Long.class.getName(), | ||
Long.TYPE.getName(), | ||
Float.class.getName(), | ||
Float.TYPE.getName(), | ||
Double.class.getName(), | ||
Double.TYPE.getName(), | ||
Enum.class.getName(), | ||
java.util.UUID.class.getName(), | ||
java.time.Instant.class.getName(), | ||
java.util.Date.class.getName(), | ||
java.time.LocalDate.class.getName(), | ||
java.time.LocalDateTime.class.getName(), | ||
java.math.BigDecimal.class.getName(), | ||
java.math.BigInteger.class.getName(), | ||
Duration.class.getName(), | ||
Period.class.getName(), | ||
java.nio.charset.Charset.class.getName(), | ||
"io.jooby.StatusCode", | ||
TimeZone.class.getName(), | ||
ZoneId.class.getName(), | ||
URI.class.getName(), | ||
URL.class.getName()); | ||
} |
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 |
---|---|---|
|
@@ -22,12 +22,6 @@ public Bean validateFormBean(@Valid @FormParam Bean bean) { | |
return bean; | ||
} | ||
|
||
// todo: revive when flash `toNullable` will be fixed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add the type check |
||
// @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; | ||
|
15 changes: 15 additions & 0 deletions
15
modules/jooby-apt/src/test/java/tests/verifyarg/ControllerCookie.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,15 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package tests.verifyarg; | ||
|
||
import io.jooby.annotation.CookieParam; | ||
import io.jooby.annotation.GET; | ||
|
||
class ControllerCookie { | ||
@GET | ||
public void param(@CookieParam Object param) { | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/jooby-apt/src/test/java/tests/verifyarg/ControllerFlash.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,15 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package tests.verifyarg; | ||
|
||
import io.jooby.annotation.FlashParam; | ||
import io.jooby.annotation.GET; | ||
|
||
class ControllerFlash { | ||
@GET | ||
public void param(@FlashParam Object param) { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
modules/jooby-apt/src/test/java/tests/verifyarg/ControllerFlashOpt.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,17 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package tests.verifyarg; | ||
|
||
import io.jooby.annotation.FlashParam; | ||
import io.jooby.annotation.GET; | ||
|
||
import java.util.Optional; | ||
|
||
class ControllerFlashOpt { | ||
@GET | ||
public void param(@FlashParam Optional<Object> param) { | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/jooby-apt/src/test/java/tests/verifyarg/ControllerHeader.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,15 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package tests.verifyarg; | ||
|
||
import io.jooby.annotation.GET; | ||
import jakarta.ws.rs.HeaderParam; | ||
|
||
class ControllerHeader { | ||
@GET | ||
public void param(@HeaderParam("test") Object param) { | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/jooby-apt/src/test/java/tests/verifyarg/ControllerSession.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,15 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package tests.verifyarg; | ||
|
||
import io.jooby.annotation.GET; | ||
import io.jooby.annotation.SessionParam; | ||
|
||
class ControllerSession { | ||
@GET | ||
public void param(@SessionParam Object param) { | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
modules/jooby-apt/src/test/java/tests/verifyarg/VerifyArgTypeTest.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,38 @@ | ||
/* | ||
* Jooby https://jooby.io | ||
* Apache License Version 2.0 https://jooby.io/LICENSE.txt | ||
* Copyright 2014 Edgar Espina | ||
*/ | ||
package tests.verifyarg; | ||
|
||
import io.jooby.apt.ProcessorRunner; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class VerifyArgTypeTest { | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideControllers") | ||
public void compileController_illegalArgumentType_shouldThrowException(Object controller) { | ||
RuntimeException ex = assertThrows(RuntimeException.class, | ||
() -> new ProcessorRunner(controller)); | ||
|
||
assertTrue(ex.getMessage().contains("Illegal argument type at")); | ||
} | ||
|
||
private static List<Arguments> provideControllers() { | ||
return List.of( | ||
Arguments.of(new ControllerFlash()), | ||
Arguments.of(new ControllerFlashOpt()), | ||
Arguments.of(new ControllerCookie()), | ||
Arguments.of(new ControllerSession()), | ||
Arguments.of(new ControllerHeader()) | ||
); | ||
} | ||
} |
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
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.
just aligning the doc with what we have at the moment. There is no
ctx.flash(str,str)
method