generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error message when introspection is missing and method has generi…
- Loading branch information
Showing
3 changed files
with
56 additions
and
5 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
48 changes: 48 additions & 0 deletions
48
test-suite/src/test/java/io/micronaut/docs/validation/WrongValidationTest.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,48 @@ | ||
package io.micronaut.docs.validation; | ||
|
||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.core.annotation.Introspected; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import io.micronaut.validation.Validated; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import jakarta.validation.ConstraintViolationException; | ||
import jakarta.validation.Valid; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@Property(name = "spec.name", value = "WrongValidationTest") | ||
@MicronautTest | ||
class WrongValidationTest { | ||
|
||
@Inject | ||
ValidatedService validatedService; | ||
|
||
@Test | ||
void validateEvent() { | ||
assertDoesNotThrow(() -> validatedService.send(new IntrospectedEvent())); | ||
|
||
var ex = assertThrows(ConstraintViolationException.class, () -> validatedService.send(new NonIntrospectedEvent())); | ||
|
||
assertTrue(ex.getMessage().contains("NonIntrospectedEvent")); | ||
} | ||
|
||
@Requires(property = "spec.name", value = "WrongValidationTest") | ||
@Singleton | ||
@Validated | ||
static class ValidatedService { | ||
|
||
<E> void send(@Valid E event) { | ||
|
||
} | ||
} | ||
|
||
@Introspected | ||
static class IntrospectedEvent {} | ||
|
||
static class NonIntrospectedEvent {} | ||
} |
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