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.
Added recursion at ArcProxyBeanMetaDataClassNormalizer.normalize to fix
quarkusio#18388 (cherry picked from commit 0c66ba5)
- Loading branch information
Showing
2 changed files
with
65 additions
and
4 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
56 changes: 56 additions & 0 deletions
56
.../java/io/quarkus/hibernate/validator/runtime/ArcProxyBeanMetaDataClassNormalizerTest.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,56 @@ | ||
package io.quarkus.hibernate.validator.runtime; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.arc.Subclass; | ||
|
||
/** | ||
* Tests class normalization, which translates into getting the "original" class, without all the specializations instances of | ||
* {@link io.quarkus.arc.Subclass}. <br /> | ||
* There's no need to be a @{@link io.quarkus.test.junit.QuarkusTest} because no Quarkus related feature is required. | ||
*/ | ||
class ArcProxyBeanMetaDataClassNormalizerTest { | ||
|
||
@Test | ||
@DisplayName("Normalize should return same class if beanClass isn't a Subclass.") | ||
void normalize_simpleClass() { | ||
Class<Original> expected = Original.class; | ||
|
||
assertEquals(expected, new ArcProxyBeanMetaDataClassNormalizer().normalize(Original.class)); | ||
} | ||
|
||
@Test | ||
@DisplayName("Normalize should return 'superclass' if beanClass is the only Subclass in it's class hierarchy.") | ||
void normalize_oneSubClass() { | ||
Class<Original> expected = Original.class; | ||
|
||
assertEquals(expected, new ArcProxyBeanMetaDataClassNormalizer().normalize(FirstSubclass.class)); | ||
} | ||
|
||
@Test | ||
@DisplayName("Normalize should return upmost superclass if beanClass has more than one Subclass in it's class hierarchy.") | ||
void normalize_multipleSubClasses() { | ||
Class<Original> expected = Original.class; | ||
|
||
assertEquals(expected, new ArcProxyBeanMetaDataClassNormalizer().normalize(SecondSubclass.class)); | ||
} | ||
|
||
private static class Original { | ||
} | ||
|
||
/** | ||
* Simulates an object injected through @{@link javax.inject.Inject}. | ||
*/ | ||
private static class FirstSubclass extends Original implements Subclass { | ||
} | ||
|
||
/** | ||
* Simulates an object injected through @{@link io.quarkus.test.junit.mockito.InjectMock} | ||
* or @{@link io.quarkus.test.junit.mockito.InjectSpy}. | ||
*/ | ||
private static class SecondSubclass extends FirstSubclass { | ||
} | ||
} |