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