View Javadoc
1   package org.apache.maven.lifecycle.internal;
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 junit.framework.TestCase;
19  
20  import org.apache.maven.lifecycle.MavenExecutionPlan;
21  import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
22  import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
23  import org.apache.maven.plugin.MojoExecution;
24  
25  import java.util.List;
26  
27  /**
28   * @author Kristian Rosenvold
29   */
30  public class PhaseRecorderTest extends TestCase
31  {
32      public void testObserveExecution() throws Exception {
33          PhaseRecorder phaseRecorder = new PhaseRecorder( ProjectDependencyGraphStub.A);
34          MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
35          final List<MojoExecution> executions = plan.getMojoExecutions();
36  
37          final MojoExecution mojoExecution1 = executions.get( 0 );
38          final MojoExecution mojoExecution2 = executions.get( 1 );
39          phaseRecorder.observeExecution( mojoExecution1 );
40  
41          assertTrue( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution1.getLifecyclePhase() ));
42          assertFalse( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution2.getLifecyclePhase() ));
43  
44          assertFalse( phaseRecorder.isDifferentPhase( mojoExecution1));
45          assertTrue( phaseRecorder.isDifferentPhase( mojoExecution2));
46  
47      }
48  
49  }