Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapted changed Java 9 APIs for class file transformer and changed re…
…ndering of parameterized types.
- Loading branch information
Showing
11 changed files
with
159 additions
and
19 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
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
71 changes: 71 additions & 0 deletions
71
...uddy/description/type/TypeDescriptionGenericOfParameterizedTypeRenderingDelegateTest.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,71 @@ | ||
package net.bytebuddy.description.type; | ||
|
||
import net.bytebuddy.ClassFileVersion; | ||
import net.bytebuddy.test.utility.MockitoRule; | ||
import net.bytebuddy.test.utility.ObjectPropertyAssertion; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestRule; | ||
import org.mockito.Mock; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class TypeDescriptionGenericOfParameterizedTypeRenderingDelegateTest { | ||
|
||
private static final String FOO = "foo", BAR = "bar"; | ||
|
||
@Rule | ||
public TestRule mockitoRule = new MockitoRule(this); | ||
|
||
@Mock | ||
private TypeDescription typeDescription, erasure; | ||
|
||
@Mock | ||
private TypeDescription.Generic ownerType; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
when(typeDescription.getName()).thenReturn(FOO + "." + BAR); | ||
when(typeDescription.getSimpleName()).thenReturn(BAR); | ||
when(ownerType.asErasure()).thenReturn(erasure); | ||
when(erasure.getName()).thenReturn(FOO); | ||
} | ||
|
||
@Test | ||
public void testJava9Capable() throws Exception { | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
TypeDescription.Generic.OfParameterizedType.RenderingDelegate.JAVA_9_CAPABLE_VM.apply(stringBuilder, typeDescription, ownerType); | ||
assertThat(stringBuilder.toString(), is("$" + BAR)); | ||
} | ||
|
||
@Test | ||
public void testLegacyParameterized() throws Exception { | ||
when(ownerType.getSort()).thenReturn(TypeDefinition.Sort.PARAMETERIZED); | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
TypeDescription.Generic.OfParameterizedType.RenderingDelegate.LEGACY_VM.apply(stringBuilder, typeDescription, ownerType); | ||
assertThat(stringBuilder.toString(), is("." + BAR)); | ||
} | ||
|
||
@Test | ||
public void testLegacyNonParameterized() throws Exception { | ||
when(ownerType.getSort()).thenReturn(TypeDefinition.Sort.NON_GENERIC); | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
TypeDescription.Generic.OfParameterizedType.RenderingDelegate.LEGACY_VM.apply(stringBuilder, typeDescription, ownerType); | ||
assertThat(stringBuilder.toString(), is("." + FOO + "." + BAR)); | ||
} | ||
|
||
@Test | ||
public void testCurrent() throws Exception { | ||
assertThat(TypeDescription.Generic.OfParameterizedType.RenderingDelegate.CURRENT, is(ClassFileVersion.ofThisVm().isAtLeast(ClassFileVersion.JAVA_V9) | ||
? TypeDescription.Generic.OfParameterizedType.RenderingDelegate.JAVA_9_CAPABLE_VM | ||
: TypeDescription.Generic.OfParameterizedType.RenderingDelegate.LEGACY_VM)); | ||
} | ||
|
||
@Test | ||
public void testObjectProperties() throws Exception { | ||
ObjectPropertyAssertion.of(TypeDescription.Generic.OfParameterizedType.RenderingDelegate.class).apply(); | ||
} | ||
} |
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