Search in sources :

Example 1 with ByteCodeElement

use of net.bytebuddy.description.ByteCodeElement in project byte-buddy by raphw.

the class ElementMatchersTest method testNamedIgnoreCase.

@Test
public void testNamedIgnoreCase() throws Exception {
    ByteCodeElement byteCodeElement = mock(ByteCodeElement.class);
    when(byteCodeElement.getActualName()).thenReturn(FOO);
    assertThat(ElementMatchers.namedIgnoreCase(FOO).matches(byteCodeElement), is(true));
    assertThat(ElementMatchers.namedIgnoreCase(FOO.toUpperCase()).matches(byteCodeElement), is(true));
    assertThat(ElementMatchers.namedIgnoreCase(BAR).matches(byteCodeElement), is(false));
}
Also used : ByteCodeElement(net.bytebuddy.description.ByteCodeElement) Test(org.junit.Test)

Example 2 with ByteCodeElement

use of net.bytebuddy.description.ByteCodeElement in project byte-buddy by raphw.

the class ElementMatchersTest method testHasDescriptor.

@Test
public void testHasDescriptor() throws Exception {
    ByteCodeElement byteCodeElement = mock(ByteCodeElement.class);
    when(byteCodeElement.getDescriptor()).thenReturn(FOO);
    assertThat(ElementMatchers.hasDescriptor(FOO).matches(byteCodeElement), is(true));
    assertThat(ElementMatchers.hasDescriptor(FOO.toUpperCase()).matches(byteCodeElement), is(false));
    assertThat(ElementMatchers.hasDescriptor(BAR).matches(byteCodeElement), is(false));
}
Also used : ByteCodeElement(net.bytebuddy.description.ByteCodeElement) Test(org.junit.Test)

Example 3 with ByteCodeElement

use of net.bytebuddy.description.ByteCodeElement in project byte-buddy by raphw.

the class ElementMatchersTest method testNameMatches.

@Test
public void testNameMatches() throws Exception {
    ByteCodeElement byteCodeElement = mock(ByteCodeElement.class);
    when(byteCodeElement.getActualName()).thenReturn(FOO);
    assertThat(ElementMatchers.nameMatches("^" + FOO + "$").matches(byteCodeElement), is(true));
    assertThat(ElementMatchers.nameMatches(FOO.toUpperCase()).matches(byteCodeElement), is(false));
    assertThat(ElementMatchers.nameMatches(BAR).matches(byteCodeElement), is(false));
}
Also used : ByteCodeElement(net.bytebuddy.description.ByteCodeElement) Test(org.junit.Test)

Example 4 with ByteCodeElement

use of net.bytebuddy.description.ByteCodeElement in project byte-buddy by raphw.

the class ElementMatchersTest method testNameStartsWithIgnoreCase.

@Test
public void testNameStartsWithIgnoreCase() throws Exception {
    ByteCodeElement byteCodeElement = mock(ByteCodeElement.class);
    when(byteCodeElement.getActualName()).thenReturn(FOO);
    assertThat(ElementMatchers.nameStartsWithIgnoreCase(FOO.substring(0, 2)).matches(byteCodeElement), is(true));
    assertThat(ElementMatchers.nameStartsWithIgnoreCase(FOO.substring(0, 2).toUpperCase()).matches(byteCodeElement), is(true));
    assertThat(ElementMatchers.nameStartsWithIgnoreCase(BAR).matches(byteCodeElement), is(false));
}
Also used : ByteCodeElement(net.bytebuddy.description.ByteCodeElement) Test(org.junit.Test)

Example 5 with ByteCodeElement

use of net.bytebuddy.description.ByteCodeElement in project byte-buddy by raphw.

the class ElementMatchersTest method testNamed.

@Test
public void testNamed() throws Exception {
    ByteCodeElement byteCodeElement = mock(ByteCodeElement.class);
    when(byteCodeElement.getActualName()).thenReturn(FOO);
    assertThat(named(FOO).matches(byteCodeElement), is(true));
    assertThat(named(FOO.toUpperCase()).matches(byteCodeElement), is(false));
    assertThat(named(BAR).matches(byteCodeElement), is(false));
}
Also used : ByteCodeElement(net.bytebuddy.description.ByteCodeElement) Test(org.junit.Test)

Aggregations

ByteCodeElement (net.bytebuddy.description.ByteCodeElement)11 Test (org.junit.Test)10 PropertyModel (dev.morphia.mapping.codec.pojo.PropertyModel)1 ByteBuddy (net.bytebuddy.ByteBuddy)1