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