1
2
3
4
5
6
7 package org.mule.transaction;
8
9 import org.mule.api.MuleEvent;
10 import org.mule.tck.junit4.AbstractMuleTestCase;
11 import org.mule.transaction.constraints.BatchConstraint;
12 import org.mule.transaction.constraints.ConstraintFilter;
13
14 import org.junit.Test;
15 import org.mockito.Mockito;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertNotSame;
20 import static org.junit.Assert.assertTrue;
21
22 public class BatchConstraintTestCase extends AbstractMuleTestCase
23 {
24 @Test
25 public void testConstraintFilter() throws Exception
26 {
27 MuleEvent testEvent = Mockito.mock(MuleEvent.class);
28 BatchConstraint filter = new BatchConstraint();
29 filter.setBatchSize(3);
30 assertEquals(3, filter.getBatchSize());
31 assertTrue(!filter.accept(testEvent));
32
33 ConstraintFilter clone = (ConstraintFilter)filter.clone();
34 assertNotNull(clone);
35 assertNotSame(filter, clone);
36
37 assertTrue(!filter.accept(testEvent));
38 assertTrue(filter.accept(testEvent));
39 }
40 }