1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.lifecycle.internal;
20
21 import java.util.List;
22
23 import org.apache.maven.lifecycle.MavenExecutionPlan;
24 import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
25 import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
26 import org.apache.maven.plugin.MojoExecution;
27 import org.junit.jupiter.api.Test;
28
29 import static org.junit.jupiter.api.Assertions.assertFalse;
30 import static org.junit.jupiter.api.Assertions.assertTrue;
31
32
33
34 class PhaseRecorderTest {
35 @Test
36 void testObserveExecution() throws Exception {
37 PhaseRecorder phaseRecorder = new PhaseRecorder(ProjectDependencyGraphStub.A);
38 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExecutionPlan();
39 final List<MojoExecution> executions = plan.getMojoExecutions();
40
41 final MojoExecution mojoExecution1 = executions.get(0);
42 final MojoExecution mojoExecution2 = executions.get(1);
43 phaseRecorder.observeExecution(mojoExecution1);
44
45 assertTrue(ProjectDependencyGraphStub.A.hasLifecyclePhase(mojoExecution1.getLifecyclePhase()));
46 assertFalse(ProjectDependencyGraphStub.A.hasLifecyclePhase(mojoExecution2.getLifecyclePhase()));
47
48 assertFalse(phaseRecorder.isDifferentPhase(mojoExecution1));
49 assertTrue(phaseRecorder.isDifferentPhase(mojoExecution2));
50 }
51 }