1 package com.lexicalscope.fluentreflection;
2
3 import static com.lexicalscope.fluentreflection.Visibility.PUBLIC;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.equalTo;
6
7 import java.lang.reflect.Member;
8
9 import org.jmock.Expectations;
10 import org.jmock.auto.Mock;
11 import org.jmock.integration.junit4.JUnitRuleMockery;
12 import org.junit.Before;
13 import org.junit.Rule;
14 import org.junit.Test;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 public class TestBoundReflectedMemberImpl {
33 @Rule public final JUnitRuleMockery context = new JUnitRuleMockery();
34
35 @Mock private FluentMember member;
36 private final Object instance = new Object();
37
38 private BoundFluentMemberImpl boundReflectedMemberImpl;
39
40 @Before public void setUp() {
41 context.checking(new Expectations() {
42 {
43 oneOf(member).isStatic(); will(returnValue(false));
44 }
45 });
46
47 boundReflectedMemberImpl = new BoundFluentMemberImpl(null, member, instance) {
48 @Override public Member member() {
49 return null;
50 }
51 };
52 }
53
54 @Test public void isStaticIsDelegated() {
55 assertThat(boundReflectedMemberImpl.isStatic(), equalTo(false));
56 }
57
58 @Test public void isFinalIsDelegated() {
59 context.checking(new Expectations() {
60 {
61 oneOf(member).isFinal(); will(returnValue(true));
62 }
63 });
64 assertThat(boundReflectedMemberImpl.isFinal(), equalTo(true));
65 }
66
67 @Test public void visibilityIsDelegated() {
68 context.checking(new Expectations() {
69 {
70 oneOf(member).visibility(); will(returnValue(PUBLIC));
71 }
72 });
73 assertThat(boundReflectedMemberImpl.visibility(), equalTo(PUBLIC));
74 }
75 }