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.mule.model;
8   
9   import org.mule.api.model.InvocationResult;
10  import org.mule.model.resolvers.AbstractArgumentEntryPointResolver;
11  import org.mule.model.resolvers.ArrayEntryPointResolver;
12  import org.mule.tck.junit4.AbstractMuleContextTestCase;
13  import org.mule.tck.testmodels.fruit.Apple;
14  import org.mule.tck.testmodels.fruit.Fruit;
15  import org.mule.tck.testmodels.fruit.FruitBowl;
16  import org.mule.tck.testmodels.fruit.Orange;
17  
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  
22  public class ArrayEntryPointResolverTestCase extends AbstractMuleContextTestCase
23  {
24  
25      @Test
26      public void testArrayMatch() throws Exception
27      {
28          AbstractArgumentEntryPointResolver resolver = new ArrayEntryPointResolver();
29          InvocationResult ctx = resolver.invoke(new FruitBowl(), getTestEventContext(new Fruit[]{new Apple(), new Orange()}));
30          assertEquals(ctx.getState(), InvocationResult.State.SUCCESSFUL);
31  
32      }
33  
34      @Test
35      public void testArrayMatchGenericFail() throws Exception
36      {
37          AbstractArgumentEntryPointResolver resolver = new ArrayEntryPointResolver();
38          InvocationResult ctx = resolver.invoke(new FruitBowl(), getTestEventContext(new Object[]{new Apple(), new Orange()}));
39          assertEquals(ctx.getState(), InvocationResult.State.FAILED);
40      }
41  
42  
43      @Test
44      public void testArrayMatchFail() throws Exception
45      {
46          AbstractArgumentEntryPointResolver resolver = new ArrayEntryPointResolver();
47          InvocationResult ctx = resolver.invoke(new Apple(), getTestEventContext(new Object[]{"blah"}));
48          assertEquals(ctx.getState(), InvocationResult.State.FAILED);
49      }
50  }