1   /***
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package test.net.sourceforge.pmd.util;
5   
6   import junit.framework.TestCase;
7   import net.sourceforge.pmd.util.Applier;
8   import net.sourceforge.pmd.util.UnaryFunction;
9   
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  public class ApplierTest extends TestCase {
14  
15      private static class MyFunction implements UnaryFunction {
16          private boolean gotCallback;
17  
18          public void applyTo(Object o) {
19              this.gotCallback = true;
20          }
21  
22          public boolean gotCallback() {
23              return this.gotCallback;
24          }
25      }
26  
27      public void testSimple() {
28          MyFunction f = new MyFunction();
29          List l = new ArrayList();
30          l.add(new Object());
31          Applier.apply(f, l.iterator());
32          assertTrue(f.gotCallback());
33      }
34  }