-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3534 from kliushnichenko/validation-tests-cleanup
cleanup validation tests
- Loading branch information
Showing
13 changed files
with
210 additions
and
57 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
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
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