-
-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't resolve parameterized types for RAW_TYPES mode (#1604)
* Don't resolve parameterized types for RAW_TYPES mode * Use Collections.emptyList() * Specify matcher generic type for Java <8 * Actually specify it --------- Co-authored-by: Joshua Selbo <jselbo@meta.com>
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 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
30 changes: 30 additions & 0 deletions
30
.../type/TypeDescriptionGenericVisitorSubstitutorForTypeVariableBindingWithRawTypesTest.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,30 @@ | ||
package net.bytebuddy.description.type; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class TypeDescriptionGenericVisitorSubstitutorForTypeVariableBindingWithRawTypesTest { | ||
|
||
@Mock | ||
private TypeDescription.Generic visitedType, parameterizedType, rawType; | ||
|
||
@Test | ||
@SuppressWarnings("unchecked") | ||
public void testParameterizedTypeWithRawTypes() throws Exception { | ||
System.setProperty(TypeDefinition.RAW_TYPES_PROPERTY, "true"); | ||
MockitoAnnotations.initMocks(this); | ||
|
||
when(parameterizedType.asRawType()).thenReturn(rawType); | ||
when(rawType.accept(any(TypeDescription.Generic.Visitor.class))).thenReturn(rawType); | ||
when(parameterizedType.getTypeArguments()).thenReturn(new TypeList.Generic.Explicit(TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(Object.class))); | ||
TypeDescription.Generic result = new TypeDescription.Generic.Visitor.Substitutor.ForTypeVariableBinding(visitedType).onParameterizedType(parameterizedType); | ||
|
||
assertThat(result.getTypeArguments(), CoreMatchers.<TypeList.Generic>is(new TypeList.Generic.Explicit())); | ||
} | ||
} |