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