1 package com.lexicalscope.fluentreflection;
2
3 import static org.hamcrest.Matchers.equalTo;
4
5 import org.hamcrest.Matcher;
6 import org.jmock.Expectations;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 public class TestMatcherConstructorReflectingOn extends AbstractTestReflectionMatcher<FluentConstructor<?>> {
25 static class ClassWithAConstructor {
26 ClassWithAConstructor() {}
27 }
28
29 static class AnotherClassWithAConstructor {
30 AnotherClassWithAConstructor() {}
31 }
32
33 @Override protected FluentConstructor<?> target() {
34 return constructor;
35 }
36
37 @Override protected void setupMatchingCase() throws Throwable {
38 context.checking(new Expectations() {
39 {
40 oneOf(constructor).member();
41 will(returnValue(ClassWithAConstructor.class.getDeclaredConstructor()));
42 }
43 });
44 }
45
46 @Override protected void setupFailingCase() throws Throwable {
47 context.checking(new Expectations() {
48 {
49 oneOf(constructor).member();
50 will(returnValue(AnotherClassWithAConstructor.class.getDeclaredConstructor()));
51 }
52 });
53 }
54
55 @Override protected Matcher<String> hasDescription() {
56 return equalTo("reflecting on constructor <com.lexicalscope.fluentreflection.TestMatcherConstructorReflectingOn$ClassWithAConstructor()>");
57 }
58
59 @Override protected ReflectionMatcher<FluentConstructor<?>> matcher() throws Throwable {
60 return new MatcherConstructorReflectingOn(ClassWithAConstructor.class.getDeclaredConstructor());
61 }
62 }