View Javadoc
1   package org.apache.maven.lifecycle.mapping;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
5    * agreements. See the NOTICE file distributed with this work for additional information regarding
6    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance with the License. You may obtain a
8    * copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software distributed under the License
13   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   * or implied. See the License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  import static org.junit.Assert.assertNull;
21  import java.util.Arrays;
22  import java.util.List;
23  
24  import org.junit.Test;
25  
26  /**
27   * @author atanasenko
28   */
29  public class LifecyclePhaseTest
30  {
31      @Test
32      public void testToString()
33      {
34          LifecyclePhase phase = new LifecyclePhase();
35          assertEquals( "", phase.toString() );
36          
37          LifecycleMojo mojo1 = new LifecycleMojo();
38          mojo1.setGoal( "jar:jar" );
39          phase.setMojos( Arrays.asList( mojo1 ) );
40          assertEquals( "jar:jar", phase.toString()  );
41          
42          LifecycleMojo mojo2 = new LifecycleMojo();
43          mojo2.setGoal( "war:war" );
44          phase.setMojos( Arrays.asList( mojo1, mojo2 ) );
45          assertEquals( "jar:jar,war:war", phase.toString() );
46      }
47      
48      @Test
49      public void testSet()
50      {
51          LifecyclePhase phase = new LifecyclePhase();
52          assertNull( phase.getMojos() );
53          
54          phase.set( "" );
55          assertNotNull( phase.getMojos() );
56          assertEquals( 0, phase.getMojos().size() );
57          
58          phase.set( "jar:jar, war:war" );
59          
60          List<LifecycleMojo> mojos = phase.getMojos();
61          assertNotNull( mojos );
62          assertEquals( 2, mojos.size() );
63          
64          LifecycleMojo mojo1 = mojos.get(0);
65          assertNotNull( mojo1 );
66          assertEquals( "jar:jar", mojo1.getGoal() );
67          
68          LifecycleMojo mojo2 = mojos.get(1);
69          assertNotNull( mojo2 );
70          assertEquals( "war:war", mojo2.getGoal() );
71      }
72  }
73