-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GenericTypeReflector.mapTypeParameters() now resolves type variables
The method GenericTypeReflector.mapTypeParameters() now also tries to resolve TypeVariable, if these have bounds like the method: `<T extends Annotation> T getAnnotation()` Which now returns `Annotation` as return type instead of `Object`. This fixes #1163 "NodeInfo#getAnnotation returns instance of Cglib-generated that does not actually implement Annotation".
- Loading branch information
Showing
3 changed files
with
93 additions
and
11 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
34 changes: 34 additions & 0 deletions
34
spock-specs/src/test/groovy/org/spockframework/mock/MockSpecInfoAnnotationSpec.groovy
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,34 @@ | ||
package org.spockframework.mock | ||
|
||
import org.spockframework.runtime.model.SpecInfo | ||
import org.spockframework.util.Nullable | ||
import spock.lang.Specification | ||
|
||
import java.lang.annotation.Annotation | ||
|
||
class MockSpecInfoAnnotationSpec extends Specification { | ||
|
||
def "NodeInfo.getAnnotation() shall return valid Stub for Stub Issue #1163"() { | ||
given: | ||
def mockUtil = new MockUtil() | ||
def spec = Stub(SpecInfo) | ||
|
||
when: | ||
def t = spec.getAnnotation(Nullable) | ||
|
||
then: | ||
t instanceof Annotation | ||
mockUtil.isMock(t) | ||
} | ||
|
||
def "NodeInfo.getAnnotation() shall return null for Mock Issue #1163"() { | ||
given: | ||
def spec = Mock(SpecInfo) | ||
|
||
when: | ||
def t = spec.getAnnotation(Nullable) | ||
|
||
then: | ||
t == null | ||
} | ||
} |