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.builder;
20
21 import java.util.HashSet;
22
23 import org.apache.maven.execution.MavenSession;
24 import org.apache.maven.lifecycle.MavenExecutionPlan;
25 import org.apache.maven.lifecycle.internal.ExecutionEventCatapult;
26 import org.apache.maven.lifecycle.internal.LifecycleDebugLogger;
27 import org.apache.maven.lifecycle.internal.TaskSegment;
28 import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
29 import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
30 import org.junit.jupiter.api.Test;
31 import org.slf4j.Logger;
32
33 import static org.junit.jupiter.api.Assertions.assertEquals;
34 import static org.mockito.Mockito.mock;
35 import static org.mockito.Mockito.verify;
36
37
38
39 class BuilderCommonTest {
40 private Logger logger = mock(Logger.class);
41
42 @Test
43 void testResolveBuildPlan() throws Exception {
44 MavenSession original = ProjectDependencyGraphStub.getMavenSession();
45
46 final TaskSegment taskSegment1 = new TaskSegment(false);
47 final MavenSession session1 = original.clone();
48 session1.setCurrentProject(ProjectDependencyGraphStub.A);
49
50 final BuilderCommon builderCommon = getBuilderCommon(logger);
51 final MavenExecutionPlan plan =
52 builderCommon.resolveBuildPlan(session1, ProjectDependencyGraphStub.A, taskSegment1, new HashSet<>());
53 assertEquals(
54 LifecycleExecutionPlanCalculatorStub.getProjectAExecutionPlan().size(), plan.size());
55 }
56
57 @Test
58 void testDefaultBindingPluginsWarning() throws Exception {
59 MavenSession original = ProjectDependencyGraphStub.getMavenSession();
60
61 final TaskSegment taskSegment1 = new TaskSegment(false);
62 final MavenSession session1 = original.clone();
63 session1.setCurrentProject(ProjectDependencyGraphStub.A);
64
65 getBuilderCommon(logger)
66 .resolveBuildPlan(session1, ProjectDependencyGraphStub.A, taskSegment1, new HashSet<>());
67
68 verify(logger)
69 .warn("Version not locked for default bindings plugins ["
70 + "stub-plugin-initialize, "
71 + "stub-plugin-process-resources, "
72 + "stub-plugin-compile, "
73 + "stub-plugin-process-test-resources, "
74 + "stub-plugin-test-compile, "
75 + "stub-plugin-test, "
76 + "stub-plugin-package, "
77 + "stub-plugin-install], "
78 + "you should define versions in pluginManagement section of your pom.xml or parent");
79 }
80
81 @Test
82 void testHandleBuildError() throws Exception {}
83
84 @Test
85 void testAttachToThread() throws Exception {}
86
87 @Test
88 void testGetKey() throws Exception {}
89
90 public BuilderCommon getBuilderCommon(Logger logger) {
91 final LifecycleDebugLogger debugLogger = new LifecycleDebugLogger();
92 return new BuilderCommon(
93 debugLogger, new LifecycleExecutionPlanCalculatorStub(), mock(ExecutionEventCatapult.class), logger);
94 }
95 }