Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing documentation for element matchers. Fixed test cases.
- Loading branch information
Rafael Winterhalter
committed
Sep 15, 2015
1 parent
22bddce
commit 16ea4d1
Showing
4 changed files
with
110 additions
and
27 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
52 changes: 52 additions & 0 deletions
52
byte-buddy-dep/src/test/java/net/bytebuddy/matcher/MethodParameterTypesMatcherTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
package net.bytebuddy.matcher; | |||
|
|||
import net.bytebuddy.description.method.ParameterList; | |||
import net.bytebuddy.description.type.generic.GenericTypeDescription; | |||
import net.bytebuddy.description.type.generic.GenericTypeList; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.mockito.Mock; | |||
|
|||
import java.util.List; | |||
|
|||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.mockito.Mockito.*; | |||
|
|||
public class MethodParameterTypesMatcherTest extends AbstractElementMatcherTest<MethodParameterTypesMatcher<?>> { | |||
|
|||
@Mock | |||
private ElementMatcher<? super List<? extends GenericTypeDescription>> parameterMatcher; | |||
|
|||
@Mock | |||
private GenericTypeList typeList; | |||
|
|||
@Mock | |||
private ParameterList parameterList; | |||
|
|||
@SuppressWarnings("unchecked") | |||
public MethodParameterTypesMatcherTest() { | |||
super((Class<MethodParameterTypesMatcher<?>>) (Object) MethodParameterTypesMatcher.class, "hasTypes"); | |||
} | |||
|
|||
@Before | |||
public void setUp() throws Exception { | |||
when(parameterList.asTypeList()).thenReturn(typeList); | |||
} | |||
|
|||
@Test | |||
public void testMatch() throws Exception { | |||
when(parameterMatcher.matches(typeList)).thenReturn(true); | |||
assertThat(new MethodParameterTypesMatcher<ParameterList<?>>(parameterMatcher).matches(parameterList), is(true)); | |||
verify(parameterMatcher).matches(typeList); | |||
verifyNoMoreInteractions(parameterMatcher); | |||
} | |||
|
|||
@Test | |||
public void testNoMatch() throws Exception { | |||
when(parameterMatcher.matches(typeList)).thenReturn(false); | |||
assertThat(new MethodParameterTypesMatcher<ParameterList<?>>(parameterMatcher).matches(parameterList), is(false)); | |||
verify(parameterMatcher).matches(typeList); | |||
verifyNoMoreInteractions(parameterMatcher); | |||
} | |||
} |