View Javadoc
1   package org.apache.maven.plugins.ejb;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import static org.assertj.core.api.Assertions.assertThat;
23  
24  import java.util.Collections;
25  
26  import org.junit.Test;
27  
28  import com.google.inject.internal.util.Lists;
29  
30  public class IncludesExcludesTest
31  {
32  
33      @Test
34      public void emptyListsShouldResultInZeroSizeResults()
35      {
36          IncludesExcludes ie = new IncludesExcludes( Collections.<String>emptyList(), Collections.<String>emptyList(),
37                                                      Collections.<String>emptyList(), Collections.<String>emptyList() );
38  
39          assertThat( ie.resultingIncludes() ).isEqualTo( new String[0] );
40          assertThat( ie.resultingExcludes() ).isEqualTo( new String[0] );
41      }
42  
43      @Test
44      public void nullForInclucesShouldResultInZeroSizeResults()
45      {
46          IncludesExcludes ie = new IncludesExcludes( null, Collections.<String>emptyList(),
47                                                      Collections.<String>emptyList(), Collections.<String>emptyList() );
48  
49          assertThat( ie.resultingIncludes() ).isEqualTo( new String[0] );
50          assertThat( ie.resultingExcludes() ).isEqualTo( new String[0] );
51      }
52  
53      @Test
54      public void nullForExclucesShouldResultInZeroSizeResults()
55      {
56          IncludesExcludes ie = new IncludesExcludes( Collections.<String>emptyList(), null,
57                                                      Collections.<String>emptyList(), Collections.<String>emptyList() );
58  
59          assertThat( ie.resultingIncludes() ).isEqualTo( new String[0] );
60          assertThat( ie.resultingExcludes() ).isEqualTo( new String[0] );
61      }
62  
63      @Test
64      public void nonNullForDefaultExcludesShouldResultInExcludesWithDefaultExcludes()
65      {
66          IncludesExcludes ie = new IncludesExcludes( null, null, Collections.<String>emptyList(),
67                                                      Lists.newArrayList( "**/package.html" ) );
68  
69          assertThat( ie.resultingIncludes() ).isEqualTo( new String[0] );
70          assertThat( ie.resultingExcludes() ).isEqualTo( new String[] { "**/package.html" } );
71      }
72  
73      @Test
74      public void nonNullForDefaultIncludesShouldResultInExcludesWithDefaultIncludes()
75      {
76          IncludesExcludes ie = new IncludesExcludes( null, null, Lists.newArrayList( "**/package.html" ),
77                                                      Collections.<String>emptyList() );
78  
79          assertThat( ie.resultingIncludes() ).isEqualTo( new String[] { "**/package.html" } );
80          assertThat( ie.resultingExcludes() ).isEqualTo( new String[0] );
81      }
82  
83  }