1   package org.apache.maven.lifecycle.internal;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
4    * agreements. See the NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
6    * "License"); you may not use this file except in compliance with the License. You may obtain a
7    * copy of the License at
8    *
9    * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software distributed under the License
12   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13   * or implied. See the License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  import junit.framework.TestCase;
17  import org.apache.maven.lifecycle.MavenExecutionPlan;
18  import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
19  import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
20  import org.apache.maven.plugin.MojoExecution;
21  
22  import java.util.List;
23  
24  /**
25   * @author Kristian Rosenvold
26   */
27  public class PhaseRecorderTest extends TestCase
28  {
29      public void testObserveExecution() throws Exception {
30          PhaseRecorder phaseRecorder = new PhaseRecorder( ProjectDependencyGraphStub.A);
31          MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
32          final List<MojoExecution> executions = plan.getMojoExecutions();
33  
34          final MojoExecution mojoExecution1 = executions.get( 0 );
35          final MojoExecution mojoExecution2 = executions.get( 1 );
36          phaseRecorder.observeExecution( mojoExecution1 );
37  
38          assertTrue( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution1.getLifecyclePhase() ));
39          assertFalse( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution2.getLifecyclePhase() ));
40  
41          assertFalse( phaseRecorder.isDifferentPhase( mojoExecution1));
42          assertTrue( phaseRecorder.isDifferentPhase( mojoExecution2));
43  
44      }
45  
46  }