1
2
3
4 package net.sourceforge.pmd.lang.java.symboltable;
5 import static org.junit.Assert.assertTrue;
6
7 import java.util.ArrayList;
8 import java.util.List;
9
10 import net.sourceforge.pmd.lang.java.symboltable.Applier;
11 import net.sourceforge.pmd.util.UnaryFunction;
12
13 import org.junit.Test;
14
15 public class ApplierTest {
16
17 private static class MyFunction implements UnaryFunction<Object> {
18 private boolean gotCallback;
19
20 public void applyTo(Object o) {
21 this.gotCallback = true;
22 }
23
24 public boolean gotCallback() {
25 return this.gotCallback;
26 }
27 }
28
29 @Test
30 public void testSimple() {
31 MyFunction f = new MyFunction();
32 List<Object> l = new ArrayList<Object>();
33 l.add(new Object());
34 Applier.apply(f, l.iterator());
35 assertTrue(f.gotCallback());
36 }
37
38 public static junit.framework.Test suite() {
39 return new junit.framework.JUnit4TestAdapter(ApplierTest.class);
40 }
41 }