From 16b5411f4e99b7112920d8ed641f0add58519966 Mon Sep 17 00:00:00 2001 From: Rafael Winterhalter Date: Sat, 19 Dec 2020 23:41:13 +0100 Subject: [PATCH] Add tests for method list properties. --- .../method/AbstractMethodListTest.java | 15 ++++++++++++++- .../description/method/MethodListEmptyTest.java | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/AbstractMethodListTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/AbstractMethodListTest.java index 1220fd756dd..723306fd525 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/AbstractMethodListTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/AbstractMethodListTest.java @@ -1,7 +1,9 @@ package net.bytebuddy.description.method; import net.bytebuddy.description.ByteCodeElement; +import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.AbstractFilterableListTest; +import net.bytebuddy.matcher.ElementMatchers; import org.junit.Test; import java.util.Collections; @@ -13,12 +15,23 @@ public abstract class AbstractMethodListTest extends AbstractFilterableListTest, U> { @Test - @SuppressWarnings("unchecked") public void testTokenWithMatcher() throws Exception { assertThat(asList(getFirst()).asTokenList(none()), is(new ByteCodeElement.Token.TokenList(asElement(getFirst()).asToken(none())))); } + @Test + public void testSignatureToken() throws Exception { + assertThat(asList(getFirst()).asSignatureTokenList(), + is(Collections.singletonList(asElement(getFirst()).asSignatureToken()))); + } + + @Test + public void testSignatureTokenWithMatcher() throws Exception { + assertThat(asList(getFirst()).asSignatureTokenList(none(), TypeDescription.ForLoadedType.of(Foo.class)), + is(Collections.singletonList(asElement(getFirst()).asToken(none()).asSignatureToken(TypeDescription.ForLoadedType.of(Foo.class))))); + } + @Test public void testAsDefined() throws Exception { assertThat(asList(getFirst()).asDefined(), is(Collections.singletonList(asElement(getFirst()).asDefined()))); diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/MethodListEmptyTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/MethodListEmptyTest.java index bba063b912d..9a883454480 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/MethodListEmptyTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/description/method/MethodListEmptyTest.java @@ -1,10 +1,12 @@ package net.bytebuddy.description.method; +import net.bytebuddy.description.type.TypeDescription; import org.junit.Test; import static net.bytebuddy.matcher.ElementMatchers.none; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.mock; public class MethodListEmptyTest { @@ -13,6 +15,16 @@ public void testTokenListWithFilter() throws Exception { assertThat(new MethodList.Empty().asTokenList(none()).size(), is(0)); } + @Test + public void testSignatureTokenList() throws Exception { + assertThat(new MethodList.Empty().asSignatureTokenList().size(), is(0)); + } + + @Test + public void testSignatureTokenListWithFilter() throws Exception { + assertThat(new MethodList.Empty().asSignatureTokenList(none(), mock(TypeDescription.class)).size(), is(0)); + } + @Test public void testDeclaredList() throws Exception { assertThat(new MethodList.Empty().asDefined().size(), is(0));