View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
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  }