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.execution.MavenSession;
24 import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub;
25 import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
26 import org.junit.jupiter.api.Test;
27
28 import static org.junit.jupiter.api.Assertions.assertEquals;
29 import static org.junit.jupiter.api.Assertions.assertNotNull;
30
31
32
33
34 class LifecycleTaskSegmentCalculatorImplTest {
35 @Test
36 void testCalculateProjectBuilds() throws Exception {
37 LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator();
38 BuildListCalculator buildListCalculator = new BuildListCalculator();
39 final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
40 List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments(session);
41
42 final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds(session, taskSegments);
43 final ProjectBuildList segments = buildList.getByTaskSegment(taskSegments.get(0));
44 assertEquals(3, taskSegments.size(), "Stub data contains 3 segments");
45 assertEquals(6, segments.size(), "Stub data contains 6 items");
46 final ProjectSegment build = segments.get(0);
47 assertNotNull(build);
48 }
49
50 private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator() {
51 return new LifecycleTaskSegmentCalculatorStub();
52 }
53 }