1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package jp.liq.container;
17
18 import static org.junit.Assert.*;
19
20 import java.util.HashSet;
21 import java.util.Map;
22 import java.util.Set;
23
24 import org.junit.Before;
25 import org.junit.Test;
26
27 import jp.liq.container.reflect.MethodWrapper;
28 import jp.liq.container.vocabulary.Factory;
29
30 public class MethodFinderTest implements ContainerVocabulary {
31 private Set<String> methodNames;
32
33 @Before
34 public void setUp() {
35 methodNames = new HashSet<String>();
36 }
37 public class Foo {
38
39 public String createString() {
40 return null;
41 }
42
43 @Factory
44 public Map<String, String> createMap() {
45 return null;
46 }
47
48 public void hoge() {
49
50 }
51 }
52
53 @Test
54 public void findWithPrefix() {
55 methodNames.add("createString");
56 methodNames.add("createMap");
57 for(MethodWrapper m: methods.of(Foo.class).withPrefix("create")) {
58 assertTrue(methodNames.contains(m.name()));
59 methodNames.remove(m.name());
60 }
61 assertEquals(0, methodNames.size());
62 }
63
64
65 }