View Javadoc
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.api.plugin.testing.stubs;
20  
21  import java.util.Optional;
22  
23  import org.apache.maven.api.MojoExecution;
24  import org.apache.maven.api.Plugin;
25  import org.apache.maven.api.model.PluginExecution;
26  import org.apache.maven.api.plugin.descriptor.MojoDescriptor;
27  import org.apache.maven.api.xml.XmlNode;
28  
29  /**
30   * Stub for {@link MojoExecution}.
31   */
32  public class MojoExecutionStub implements MojoExecution {
33      private String executionId;
34      private String goal;
35      private XmlNode dom;
36      private Plugin plugin = new PluginStub();
37      private PluginExecution model;
38      private MojoDescriptor descriptor;
39      private String lifecyclePhase;
40  
41      public MojoExecutionStub(String executionId, String goal) {
42          this(executionId, goal, null);
43      }
44  
45      public MojoExecutionStub(String executionId, String goal, XmlNode dom) {
46          this.executionId = executionId;
47          this.goal = goal;
48          this.dom = dom;
49      }
50  
51      @Override
52      public Plugin getPlugin() {
53          return plugin;
54      }
55  
56      @Override
57      public PluginExecution getModel() {
58          return model;
59      }
60  
61      @Override
62      public MojoDescriptor getDescriptor() {
63          return descriptor;
64      }
65  
66      @Override
67      public String getLifecyclePhase() {
68          return lifecyclePhase;
69      }
70  
71      @Override
72      public String getExecutionId() {
73          return executionId;
74      }
75  
76      @Override
77      public String getGoal() {
78          return goal;
79      }
80  
81      @Override
82      public Optional<XmlNode> getConfiguration() {
83          return Optional.ofNullable(dom);
84      }
85  
86      public void setExecutionId(String executionId) {
87          this.executionId = executionId;
88      }
89  
90      public void setGoal(String goal) {
91          this.goal = goal;
92      }
93  
94      public void setDom(XmlNode dom) {
95          this.dom = dom;
96      }
97  
98      public void setPlugin(Plugin plugin) {
99          this.plugin = plugin;
100     }
101 
102     public void setModel(PluginExecution model) {
103         this.model = model;
104     }
105 
106     public void setDescriptor(MojoDescriptor descriptor) {
107         this.descriptor = descriptor;
108     }
109 
110     public void setLifecyclePhase(String lifecyclePhase) {
111         this.lifecyclePhase = lifecyclePhase;
112     }
113 }