Skip to content

Commit bc8eae3

Browse files
committed
Cover BuildStep.hasExecutions() with unit tests
1 parent c07675a commit bc8eae3

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

  • impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.lifecycle.internal.concurrent;
20+
21+
import org.apache.maven.plugin.MojoExecution;
22+
import org.apache.maven.plugin.descriptor.MojoDescriptor;
23+
import org.apache.maven.project.MavenProject;
24+
import org.junit.jupiter.api.Test;
25+
26+
import static org.junit.jupiter.api.Assertions.assertFalse;
27+
import static org.junit.jupiter.api.Assertions.assertTrue;
28+
29+
class BuildStepTest {
30+
31+
@Test
32+
void stepWithoutMojosDoesNoWork() {
33+
BuildStep step = new BuildStep("compile", new MavenProject(), null);
34+
35+
assertFalse(step.hasExecutions());
36+
}
37+
38+
@Test
39+
void stepCarryingAMojoDoesWork() {
40+
BuildStep step = new BuildStep("compile", new MavenProject(), null);
41+
step.addMojo(mojoExecution("compile"), 0);
42+
43+
assertTrue(step.hasExecutions());
44+
}
45+
46+
@Test
47+
void skippedStepDoesNoWork() {
48+
BuildStep step = new BuildStep("compile", new MavenProject(), null);
49+
step.addMojo(mojoExecution("compile"), 0);
50+
step.skip();
51+
52+
assertFalse(step.hasExecutions());
53+
}
54+
55+
private static MojoExecution mojoExecution(String goal) {
56+
MojoDescriptor descriptor = new MojoDescriptor();
57+
descriptor.setGoal(goal);
58+
return new MojoExecution(descriptor, "default-" + goal);
59+
}
60+
}

0 commit comments

Comments
 (0)