### Question:
Sequence implements Procedure<A> { public void run(A obj) { for (Iterator<Procedure<? super A>> iter = list.iterator(); iter.hasNext();) { iter.next().run(obj); } } Sequence();  Sequence(Procedure<? super A>... procedures);  Sequence(Iterable<Procedure<? super A>> procedures); Sequence<A> then(Procedure<? super A> p); void run(A obj); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testRunZero() throws Exception { Sequence<String> seq = new Sequence<String>(); seq.run(null); seq.run("xyzzy"); }
@Test public void testRunOne() throws Exception { RunCounter counter = new RunCounter(); Sequence<String> seq = new Sequence<String>(counter); assertEquals(0,counter.count); seq.run(null); assertEquals(1,counter.count); seq.run("xyzzy"); assertEquals(2,counter.count); }
@Test public void testRunTwo() throws Exception { RunCounter[] counter = { new RunCounter(), new RunCounter() }; Sequence<String> seq = new Sequence<String>(counter[0],counter[1]); assertEquals(0,counter[0].count); assertEquals(0,counter[1].count); seq.run(null); assertEquals(1,counter[0].count); assertEquals(1,counter[1].count); seq.run("xyzzy"); assertEquals(2,counter[0].count); assertEquals(2,counter[1].count); }