1 package org.apache.maven.lifecycle.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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 }