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.module.ibeans.annotations;
8   
9   import org.ibeans.impl.support.util.UriParamFilter;
10  import org.junit.Test;
11  
12  import static org.junit.Assert.assertEquals;
13  
14  public class UriParamFilterTestCase extends AbstractIBeansTestCase
15  {
16      private UriParamFilter filter = new UriParamFilter();
17  
18      @Test
19      public void testOptionalRemoveOneParam() throws Exception
20      {
21          String test = "http://foo.com?param=null.param";
22          test = filter.filterParamsByValue(test, "null.param");
23          assertEquals("http://foo.com", test);
24      }
25  
26      @Test
27      public void testOptionalRemoveTwoParam() throws Exception
28      {
29          String test = "http://foo.com?param=null.param&param2=foo";
30          test = filter.filterParamsByValue(test, "null.param");
31          assertEquals("http://foo.com?param2=foo", test);
32      }
33  
34      @Test
35      public void testOptionalRemoveThrteeParamsMiddle() throws Exception
36      {
37          String test = "http://foo.com?param0=foo&param1=null.param&param2=bar";
38          test = filter.filterParamsByValue(test, "null.param");
39          assertEquals("http://foo.com?param0=foo&param2=bar", test);
40      }
41  
42      @Test
43      public void testOptionalRemoveThreeParamsEnd() throws Exception
44      {
45          String test = "http://foo.com?param0=foo&param1=bar&param2=null.param";
46          test = filter.filterParamsByValue(test, "null.param");
47          assertEquals("http://foo.com?param0=foo&param1=bar", test);
48      }
49  
50      @Test
51      public void testOptionalRemoveAllButOne() throws Exception
52      {
53          String test = "http://foo.com?param0=foo&param1=null.param&param2=null.param&param3=null.param";
54          test = filter.filterParamsByValue(test, "null.param");
55          assertEquals("http://foo.com?param0=foo", test);
56      }
57  }