View Javadoc
1   package org.apache.maven.plugin.issues;
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 junit.framework.TestCase;
23  import org.apache.maven.plugin.MojoExecutionException;
24  
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  /**
29   * Tests for the IssueUtils class.
30   *
31   * @author Dennis Lundberg
32   * @version $Id: IssueUtilsTestCase.java 1685894 2015-06-16 19:29:09Z khmarbaise $
33   * @since 2.4
34   */
35  public class IssueUtilsTestCase
36      extends TestCase
37  {
38      public void testFilterIssuesWithVersionPrefix()
39      {
40          Issue issue_1;
41          issue_1 = new Issue();
42          issue_1.setId( "1" );
43          issue_1.addFixVersion( "myPrefix-1.0" );
44  
45          Issue issue_2;
46          issue_2 = new Issue();
47          issue_2.setId( "2" );
48          issue_2.addFixVersion( "1.0" );
49  
50          List<Issue> issueList = new ArrayList<Issue>();
51          issueList.add( issue_1 );
52          issueList.add( issue_2 );
53  
54          List filteredIssues;
55          try
56          {
57              filteredIssues = IssueUtils.filterIssuesWithVersionPrefix( issueList, null );
58              assertEquals( 2, filteredIssues.size() );
59  
60              filteredIssues = IssueUtils.filterIssuesWithVersionPrefix( issueList, "" );
61              assertEquals( 2, filteredIssues.size() );
62  
63              filteredIssues = IssueUtils.filterIssuesWithVersionPrefix( issueList, "myPrefix-" );
64              assertEquals( 1, filteredIssues.size() );
65          }
66          catch ( MojoExecutionException e )
67          {
68              fail( e.getMessage() );
69          }
70  
71          try
72          {
73              IssueUtils.filterIssuesWithVersionPrefix( issueList, "yourPrefix-" );
74              fail( "No issues should be found." );
75          }
76          catch ( MojoExecutionException e )
77          {
78              // Expected
79          }
80  
81      }
82  
83  }