fix compilation
[teamcity/git-plugin.git] / git-tests / src / jetbrains / buildServer / buildTriggers / vcs / git / tests / builders / AgentRunningBuildBuilder.java
1 /*
2  * Copyright 2000-2015 JetBrains s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package jetbrains.buildServer.buildTriggers.vcs.git.tests.builders;
18
19 import jetbrains.buildServer.agent.*;
20 import jetbrains.buildServer.agent.impl.BuildParametersMapImpl;
21 import jetbrains.buildServer.agentServer.AgentBuild;
22 import jetbrains.buildServer.artifacts.ArtifactDependencyInfo;
23 import jetbrains.buildServer.buildTriggers.vcs.git.agent.PluginConfigImpl;
24 import jetbrains.buildServer.parameters.ValueResolver;
25 import jetbrains.buildServer.util.FileUtil;
26 import jetbrains.buildServer.util.Option;
27 import jetbrains.buildServer.util.PasswordReplacer;
28 import jetbrains.buildServer.vcs.CheckoutRules;
29 import jetbrains.buildServer.vcs.VcsChangeInfo;
30 import jetbrains.buildServer.vcs.VcsRoot;
31 import jetbrains.buildServer.vcs.VcsRootEntry;
32 import org.jetbrains.annotations.NotNull;
33 import org.jetbrains.annotations.Nullable;
34
35 import java.io.File;
36 import java.util.*;
37
38 import static jetbrains.buildServer.util.Util.map;
39
40 public class AgentRunningBuildBuilder {
41
42   private Map<String, String> mySharedConfigParameters = new HashMap<String, String>();
43   private Map<String, String> mySharedBuildParameters = new HashMap<String, String>();
44   private List<VcsRootEntry> myRootEntries = null;
45
46   public static AgentRunningBuildBuilder runningBuild() {
47     return new AgentRunningBuildBuilder();
48   }
49
50
51   public AgentRunningBuildBuilder sharedConfigParams(String... params) {
52     mySharedConfigParameters.putAll(map(params));
53     return this;
54   }
55
56
57   public AgentRunningBuildBuilder sharedConfigParams(Map<String, String> params) {
58     mySharedConfigParameters.putAll(params);
59     return this;
60   }
61
62
63   public AgentRunningBuildBuilder sharedEnvVariable(String key, String value) {
64     mySharedBuildParameters.put("env." + key, value);
65     return this;
66   }
67
68
69   public AgentRunningBuildBuilder useLocalMirrors(boolean doUse) {
70     mySharedConfigParameters.put(PluginConfigImpl.USE_MIRRORS, String.valueOf(doUse));
71     return this;
72   }
73
74
75   public AgentRunningBuildBuilder addRootEntry(@NotNull VcsRoot root, @NotNull String rules) {
76     if (myRootEntries == null) {
77       myRootEntries = new ArrayList<>();
78     }
79     myRootEntries.add(new VcsRootEntry(root, new CheckoutRules(rules)));
80     return this;
81   }
82
83   public AgentRunningBuildBuilder addRoot(@NotNull VcsRoot root) {
84     if (myRootEntries == null) {
85       myRootEntries = new ArrayList<>();
86     }
87     myRootEntries.add(new VcsRootEntry(root, CheckoutRules.DEFAULT));
88     return this;
89   }
90
91
92   public AgentRunningBuild build() {
93     return new AgentRunningBuild() {
94       @NotNull
95       public File getBuildTempDirectory() {
96         return new File(FileUtil.getTempDirectory());
97       }
98
99       @NotNull
100       public BuildProgressLogger getBuildLogger() {
101         return new NullBuildProgressLogger();
102       }
103
104       @NotNull
105       public Map<String, String> getSharedConfigParameters() {
106         return mySharedConfigParameters;
107       }
108
109       @NotNull
110       public BuildParametersMap getMandatoryBuildParameters() {
111         throw new UnsupportedOperationException();
112       }
113
114       @NotNull
115       public File getCheckoutDirectory() {
116         throw new UnsupportedOperationException();
117       }
118
119       @NotNull
120       public File getWorkingDirectory() {
121         throw new UnsupportedOperationException();
122       }
123
124       @Nullable
125       public String getArtifactsPaths() {
126         throw new UnsupportedOperationException();
127       }
128
129       public boolean getFailBuildOnExitCode() {
130         throw new UnsupportedOperationException();
131       }
132
133       @NotNull
134       public ResolvedParameters getResolvedParameters() {
135         throw new UnsupportedOperationException();
136       }
137
138       @NotNull
139       public String getRunType() {
140         throw new UnsupportedOperationException();
141       }
142
143       @NotNull
144       public UnresolvedParameters getUnresolvedParameters() {
145         throw new UnsupportedOperationException();
146       }
147
148       @NotNull
149       public BuildParametersMap getBuildParameters() {
150         return new BuildParametersMap() {
151           @NotNull
152           public Map<String, String> getEnvironmentVariables() {
153             return new HashMap<String, String>(0);
154           }
155
156           @NotNull
157           public Map<String, String> getSystemProperties() {
158             return new HashMap<String, String>(0);
159           }
160
161           @NotNull
162           public Map<String, String> getAllParameters() {
163             return new HashMap<String, String>(0);
164           }
165         };
166       }
167
168       @NotNull
169       public Map<String, String> getRunnerParameters() {
170         throw new UnsupportedOperationException();
171       }
172
173       @NotNull
174       public String getBuildNumber() {
175         throw new UnsupportedOperationException();
176       }
177
178       public void addSharedConfigParameter(final String key, final String value) {
179         throw new UnsupportedOperationException();
180       }
181
182       public void addSharedSystemProperty(final String key, final String value) {
183         throw new UnsupportedOperationException();
184       }
185
186       public void addSharedEnvironmentVariable(final String key, final String value) {
187         throw new UnsupportedOperationException();
188       }
189
190       @NotNull
191       public BuildParametersMap getSharedBuildParameters() {
192         return new BuildParametersMapImpl(mySharedBuildParameters);
193       }
194
195       @NotNull
196       public ValueResolver getSharedParametersResolver() {
197         throw new UnsupportedOperationException();
198       }
199
200       @NotNull
201       public Collection<AgentBuildFeature> getBuildFeatures() {
202         throw new UnsupportedOperationException();
203       }
204
205       @NotNull
206       public Collection<AgentBuildFeature> getBuildFeaturesOfType(final String type) {
207         throw new UnsupportedOperationException();
208       }
209
210       public void stopBuild(final String reason) {
211         throw new UnsupportedOperationException();
212       }
213
214       @Nullable
215       public BuildInterruptReason getInterruptReason() {
216         return null;
217       }
218
219       public boolean isBuildFailingOnServer() throws InterruptedException {
220         throw new UnsupportedOperationException();
221       }
222
223       public boolean isInAlwaysExecutingStage() {
224         throw new UnsupportedOperationException();
225       }
226
227       public String getProjectName() {
228         throw new UnsupportedOperationException();
229       }
230
231       @NotNull
232       public String getBuildTypeId() {
233         throw new UnsupportedOperationException();
234       }
235
236       @NotNull
237       public String getBuildTypeExternalId() {
238         throw new UnsupportedOperationException();
239       }
240
241       public String getBuildTypeName() {
242         throw new UnsupportedOperationException();
243       }
244
245       public long getBuildId() {
246         return 1;
247       }
248
249       public boolean isCleanBuild() {
250         throw new UnsupportedOperationException();
251       }
252
253       public boolean isPersonal() {
254         throw new UnsupportedOperationException();
255       }
256
257       public boolean isPersonalPatchAvailable() {
258         throw new UnsupportedOperationException();
259       }
260
261       public boolean isCheckoutOnAgent() {
262         throw new UnsupportedOperationException();
263       }
264
265       public boolean isCheckoutOnServer() {
266         throw new UnsupportedOperationException();
267       }
268
269       public long getExecutionTimeoutMinutes() {
270         throw new UnsupportedOperationException();
271       }
272
273       @NotNull
274       public List<ArtifactDependencyInfo> getArtifactDependencies() {
275         throw new UnsupportedOperationException();
276       }
277
278       @NotNull
279       public String getAccessUser() {
280         throw new UnsupportedOperationException();
281       }
282
283       @NotNull
284       public String getAccessCode() {
285         throw new UnsupportedOperationException();
286       }
287
288       @NotNull
289       public List<VcsRootEntry> getVcsRootEntries() {
290         if (myRootEntries == null)
291           throw new UnsupportedOperationException();
292         return myRootEntries;
293       }
294
295       public String getBuildCurrentVersion(final VcsRoot vcsRoot) {
296         throw new UnsupportedOperationException();
297       }
298
299       public String getBuildPreviousVersion(final VcsRoot vcsRoot) {
300         throw new UnsupportedOperationException();
301       }
302
303       public boolean isCustomCheckoutDirectory() {
304         throw new UnsupportedOperationException();
305       }
306
307       @NotNull
308       public List<VcsChangeInfo> getVcsChanges() {
309         throw new UnsupportedOperationException();
310       }
311
312       @NotNull
313       public List<VcsChangeInfo> getPersonalVcsChanges() {
314         throw new UnsupportedOperationException();
315       }
316
317       @NotNull
318       public File getAgentTempDirectory() {
319         throw new UnsupportedOperationException();
320       }
321
322       @NotNull
323       public BuildAgentConfiguration getAgentConfiguration() {
324         throw new UnsupportedOperationException();
325       }
326
327       public <T> T getBuildTypeOptionValue(final Option<T> option) {
328         throw new UnsupportedOperationException();
329       }
330
331       @NotNull
332       public File getDefaultCheckoutDirectory() {
333         throw new UnsupportedOperationException();
334       }
335
336       @NotNull
337       public String getVcsSettingsHashForCheckoutMode(AgentCheckoutMode agentCheckoutMode) {throw new UnsupportedOperationException();}
338
339       @Nullable
340       public AgentCheckoutMode getEffectiveCheckoutMode() {
341         return null;
342       }
343
344       @NotNull
345       public AgentBuild.CheckoutType getCheckoutType() {
346         return AgentBuild.CheckoutType.ON_AGENT;
347       }
348
349       public PasswordReplacer getPasswordReplacer() {
350         throw new UnsupportedOperationException();
351       }
352
353       @NotNull
354       @Override
355       public String describe(final boolean verbose) { return "no details";}
356
357       @NotNull
358       @Override
359       public Map<String, String> getArtifactStorageSettings() {
360         throw new UnsupportedOperationException();
361       }
362
363       @NotNull
364       @Override
365       public List<BuildRunnerSettings> getBuildRunners() {
366         throw new UnsupportedOperationException();
367       }
368     };
369   };
370
371 }