View Javadoc
1   package org.apache.maven.shared.release.policy.oddeven;
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.junit.Assert.assertEquals;
23  
24  import org.apache.maven.shared.release.policy.version.VersionPolicy;
25  import org.apache.maven.shared.release.policy.version.VersionPolicyRequest;
26  import org.junit.After;
27  import org.junit.Before;
28  import org.junit.Test;
29  
30  public final class OddEvenVersionPolicyTestCase
31  {
32  
33      private VersionPolicy versionPolicy;
34  
35      @Before
36      public void setUp()
37      {
38          versionPolicy = new OddEvenVersionPolicy();
39      }
40  
41      @After
42      public void tearDown()
43      {
44          versionPolicy = null;
45      }
46  
47      @Test
48      public void testConvertToSnapshot()
49          throws Exception
50      {
51          String suggestedVersion = versionPolicy.getDevelopmentVersion( newVersionPolicyRequest( "1.0.0" ) )
52                                                 .getVersion();
53  
54          assertEquals( "1.0.1-SNAPSHOT", suggestedVersion );
55      }
56  
57      @Test
58      public void testConvertToRelease()
59          throws Exception
60      {
61          String suggestedVersion = versionPolicy.getReleaseVersion( newVersionPolicyRequest( "1.0.0-SNAPSHOT" ) )
62                                                 .getVersion();
63  
64          assertEquals( "1.0.0", suggestedVersion );
65      }
66  
67      @Test
68      public void testConvertOddToRelease()
69          throws Exception
70      {
71          String suggestedVersion = versionPolicy.getReleaseVersion( newVersionPolicyRequest( "1.0.1-SNAPSHOT" ) )
72                                                 .getVersion();
73  
74          assertEquals( "1.0.2", suggestedVersion );
75      }
76  
77      private static VersionPolicyRequest newVersionPolicyRequest( String version )
78      {
79          return new VersionPolicyRequest().setVersion( version );
80      }
81  
82  }