Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ArtifactStub |
|
| 1.0980392156862746;1,098 |
1 | package org.apache.maven.plugin.testing.stubs; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.io.File; | |
23 | import java.util.Collection; | |
24 | import java.util.List; | |
25 | ||
26 | import org.apache.maven.artifact.Artifact; | |
27 | import org.apache.maven.artifact.handler.ArtifactHandler; | |
28 | import org.apache.maven.artifact.metadata.ArtifactMetadata; | |
29 | import org.apache.maven.artifact.repository.ArtifactRepository; | |
30 | import org.apache.maven.artifact.resolver.filter.ArtifactFilter; | |
31 | import org.apache.maven.artifact.versioning.ArtifactVersion; | |
32 | import org.apache.maven.artifact.versioning.OverConstrainedVersionException; | |
33 | import org.apache.maven.artifact.versioning.VersionRange; | |
34 | ||
35 | /** | |
36 | * Stub class for {@link Artifact} testing. | |
37 | * | |
38 | * @author jesse | |
39 | * @version $Id: ArtifactStub.java 815947 2009-09-16 20:13:21Z olamy $ | |
40 | */ | |
41 | 0 | public class ArtifactStub |
42 | implements Artifact | |
43 | { | |
44 | private String groupId; | |
45 | ||
46 | private String artifactId; | |
47 | ||
48 | private String version; | |
49 | ||
50 | private String scope; | |
51 | ||
52 | private String type; | |
53 | ||
54 | private String classifier; | |
55 | ||
56 | private File file; | |
57 | ||
58 | private ArtifactRepository artifactRepository; | |
59 | ||
60 | /** | |
61 | * By default, return <code>0</code> | |
62 | * | |
63 | * @see java.lang.Comparable#compareTo(java.lang.Object) | |
64 | */ | |
65 | public int compareTo( Artifact artifact ) | |
66 | { | |
67 | 0 | return 0; |
68 | } | |
69 | ||
70 | /** {@inheritDoc} */ | |
71 | public String getGroupId() | |
72 | { | |
73 | 0 | return groupId; |
74 | } | |
75 | ||
76 | /** {@inheritDoc} */ | |
77 | public String getArtifactId() | |
78 | { | |
79 | 0 | return artifactId; |
80 | } | |
81 | ||
82 | /** {@inheritDoc} */ | |
83 | public String getVersion() | |
84 | { | |
85 | 0 | return version; |
86 | } | |
87 | ||
88 | /** {@inheritDoc} */ | |
89 | public void setVersion( String version ) | |
90 | { | |
91 | 0 | this.version = version; |
92 | 0 | } |
93 | ||
94 | /** {@inheritDoc} */ | |
95 | public String getScope() | |
96 | { | |
97 | 0 | return scope; |
98 | } | |
99 | ||
100 | /** {@inheritDoc} */ | |
101 | public String getType() | |
102 | { | |
103 | 0 | return type; |
104 | } | |
105 | ||
106 | /** | |
107 | * Set a new type | |
108 | * | |
109 | * @param type | |
110 | */ | |
111 | public void setType( String type ) | |
112 | { | |
113 | 0 | this.type = type; |
114 | 0 | } |
115 | ||
116 | /** {@inheritDoc} */ | |
117 | public String getClassifier() | |
118 | { | |
119 | 0 | return classifier; |
120 | } | |
121 | ||
122 | /** {@inheritDoc} */ | |
123 | public boolean hasClassifier() | |
124 | { | |
125 | 0 | return classifier != null; |
126 | } | |
127 | ||
128 | /** {@inheritDoc} */ | |
129 | public File getFile() | |
130 | { | |
131 | 0 | return file; |
132 | } | |
133 | ||
134 | /** {@inheritDoc} */ | |
135 | public void setFile( File file ) | |
136 | { | |
137 | 0 | this.file = file; |
138 | 0 | } |
139 | ||
140 | /** | |
141 | * @return <code>null</code>. | |
142 | * @see org.apache.maven.artifact.Artifact#getBaseVersion() | |
143 | */ | |
144 | public String getBaseVersion() | |
145 | { | |
146 | 0 | return null; |
147 | } | |
148 | ||
149 | /** | |
150 | * By default, do nothing. | |
151 | * | |
152 | * @see org.apache.maven.artifact.Artifact#setBaseVersion(java.lang.String) | |
153 | */ | |
154 | public void setBaseVersion( String string ) | |
155 | { | |
156 | // nop | |
157 | 0 | } |
158 | ||
159 | /** | |
160 | * @return <code>null</code>. | |
161 | * @see org.apache.maven.artifact.Artifact#getId() | |
162 | */ | |
163 | public String getId() | |
164 | { | |
165 | 0 | return null; |
166 | } | |
167 | ||
168 | /** | |
169 | * @return <code>groupId:artifactId:type:classifier</code>. | |
170 | * @see org.apache.maven.artifact.Artifact#getDependencyConflictId() | |
171 | */ | |
172 | public String getDependencyConflictId() | |
173 | { | |
174 | 0 | StringBuffer buffer = new StringBuffer(); |
175 | ||
176 | 0 | buffer.append( getGroupId() ); |
177 | 0 | buffer.append( ":" ).append( getArtifactId() ); |
178 | 0 | buffer.append( ":" ).append( getType() ); |
179 | 0 | buffer.append( ":" ).append( getClassifier() ); |
180 | ||
181 | 0 | return buffer.toString(); |
182 | } | |
183 | ||
184 | /** | |
185 | * By default, do nothing. | |
186 | * | |
187 | * @see org.apache.maven.artifact.Artifact#addMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata) | |
188 | */ | |
189 | public void addMetadata( ArtifactMetadata artifactMetadata ) | |
190 | { | |
191 | // nop | |
192 | 0 | } |
193 | ||
194 | /** | |
195 | * @return <code>null</code>. | |
196 | * @see org.apache.maven.artifact.Artifact#getMetadataList() | |
197 | */ | |
198 | public Collection getMetadataList() | |
199 | { | |
200 | 0 | return null; |
201 | } | |
202 | ||
203 | /** {@inheritDoc} */ | |
204 | public void setRepository( ArtifactRepository artifactRepository ) | |
205 | { | |
206 | 0 | this.artifactRepository = artifactRepository; |
207 | 0 | } |
208 | ||
209 | /** {@inheritDoc} */ | |
210 | public ArtifactRepository getRepository() | |
211 | { | |
212 | 0 | return artifactRepository; |
213 | } | |
214 | ||
215 | /** | |
216 | * By default, do nothing. | |
217 | * | |
218 | * @see org.apache.maven.artifact.Artifact#updateVersion(java.lang.String, org.apache.maven.artifact.repository.ArtifactRepository) | |
219 | */ | |
220 | public void updateVersion( String string, ArtifactRepository artifactRepository ) | |
221 | { | |
222 | // nop | |
223 | 0 | } |
224 | ||
225 | /** | |
226 | * @return <code>null</code>. | |
227 | * @see org.apache.maven.artifact.Artifact#getDownloadUrl() | |
228 | */ | |
229 | public String getDownloadUrl() | |
230 | { | |
231 | 0 | return null; |
232 | } | |
233 | ||
234 | /** | |
235 | * By default, do nothing. | |
236 | * | |
237 | * @see org.apache.maven.artifact.Artifact#setDownloadUrl(java.lang.String) | |
238 | */ | |
239 | public void setDownloadUrl( String string ) | |
240 | { | |
241 | // nop | |
242 | 0 | } |
243 | ||
244 | /** | |
245 | * @return <code>null</code>. | |
246 | * @see org.apache.maven.artifact.Artifact#getDependencyFilter() | |
247 | */ | |
248 | public ArtifactFilter getDependencyFilter() | |
249 | { | |
250 | 0 | return null; |
251 | } | |
252 | ||
253 | /** | |
254 | * By default, do nothing. | |
255 | * | |
256 | * @see org.apache.maven.artifact.Artifact#setDependencyFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) | |
257 | */ | |
258 | public void setDependencyFilter( ArtifactFilter artifactFilter ) | |
259 | { | |
260 | // nop | |
261 | 0 | } |
262 | ||
263 | /** | |
264 | * @return <code>null</code>. | |
265 | * @see org.apache.maven.artifact.Artifact#getArtifactHandler() | |
266 | */ | |
267 | public ArtifactHandler getArtifactHandler() | |
268 | { | |
269 | 0 | return null; |
270 | } | |
271 | ||
272 | /** | |
273 | * @return <code>null</code>. | |
274 | * @see org.apache.maven.artifact.Artifact#getDependencyTrail() | |
275 | */ | |
276 | public List getDependencyTrail() | |
277 | { | |
278 | 0 | return null; |
279 | } | |
280 | ||
281 | /** | |
282 | * By default, do nothing. | |
283 | * | |
284 | * @see org.apache.maven.artifact.Artifact#setDependencyTrail(java.util.List) | |
285 | */ | |
286 | public void setDependencyTrail( List list ) | |
287 | { | |
288 | // nop | |
289 | 0 | } |
290 | ||
291 | /** {@inheritDoc} */ | |
292 | public void setScope( String scope ) | |
293 | { | |
294 | 0 | this.scope = scope; |
295 | 0 | } |
296 | ||
297 | /** | |
298 | * @return <code>null</code>. | |
299 | * @see org.apache.maven.artifact.Artifact#getVersionRange() | |
300 | */ | |
301 | public VersionRange getVersionRange() | |
302 | { | |
303 | 0 | return null; |
304 | } | |
305 | ||
306 | /** | |
307 | * By default, do nothing. | |
308 | * | |
309 | * @see org.apache.maven.artifact.Artifact#setVersionRange(org.apache.maven.artifact.versioning.VersionRange) | |
310 | */ | |
311 | public void setVersionRange( VersionRange versionRange ) | |
312 | { | |
313 | // nop | |
314 | 0 | } |
315 | ||
316 | /** | |
317 | * By default, do nothing. | |
318 | * | |
319 | * @see org.apache.maven.artifact.Artifact#selectVersion(java.lang.String) | |
320 | */ | |
321 | public void selectVersion( String string ) | |
322 | { | |
323 | // nop | |
324 | 0 | } |
325 | ||
326 | /** {@inheritDoc} */ | |
327 | public void setGroupId( String groupId ) | |
328 | { | |
329 | 0 | this.groupId = groupId; |
330 | 0 | } |
331 | ||
332 | /** {@inheritDoc} */ | |
333 | public void setArtifactId( String artifactId ) | |
334 | { | |
335 | 0 | this.artifactId = artifactId; |
336 | 0 | } |
337 | ||
338 | /** | |
339 | * @return <code>false</code>. | |
340 | * @see org.apache.maven.artifact.Artifact#isSnapshot() | |
341 | */ | |
342 | public boolean isSnapshot() | |
343 | { | |
344 | 0 | return Artifact.VERSION_FILE_PATTERN.matcher( getVersion() ).matches() |
345 | || getVersion().endsWith( Artifact.SNAPSHOT_VERSION ); | |
346 | } | |
347 | ||
348 | /** | |
349 | * By default, do nothing. | |
350 | * | |
351 | * @see org.apache.maven.artifact.Artifact#setResolved(boolean) | |
352 | */ | |
353 | public void setResolved( boolean b ) | |
354 | { | |
355 | // nop | |
356 | 0 | } |
357 | ||
358 | /** | |
359 | * @return <code>false</code>. | |
360 | * @see org.apache.maven.artifact.Artifact#isResolved() | |
361 | */ | |
362 | public boolean isResolved() | |
363 | { | |
364 | 0 | return false; |
365 | } | |
366 | ||
367 | /** | |
368 | * By default, do nothing. | |
369 | * | |
370 | * @see org.apache.maven.artifact.Artifact#setResolvedVersion(java.lang.String) | |
371 | */ | |
372 | public void setResolvedVersion( String string ) | |
373 | { | |
374 | // nop | |
375 | 0 | } |
376 | ||
377 | /** | |
378 | * By default, do nothing. | |
379 | * | |
380 | * @see org.apache.maven.artifact.Artifact#setArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) | |
381 | */ | |
382 | public void setArtifactHandler( ArtifactHandler artifactHandler ) | |
383 | { | |
384 | // nop | |
385 | 0 | } |
386 | ||
387 | /** | |
388 | * @return <code>false</code>. | |
389 | * @see org.apache.maven.artifact.Artifact#isRelease() | |
390 | */ | |
391 | public boolean isRelease() | |
392 | { | |
393 | 0 | return !isSnapshot(); |
394 | } | |
395 | ||
396 | /** | |
397 | * By default, do nothing. | |
398 | * | |
399 | * @see org.apache.maven.artifact.Artifact#setRelease(boolean) | |
400 | */ | |
401 | public void setRelease( boolean b ) | |
402 | { | |
403 | // nop | |
404 | 0 | } |
405 | ||
406 | /** | |
407 | * @return <code>null</code>. | |
408 | * @see org.apache.maven.artifact.Artifact#getAvailableVersions() | |
409 | */ | |
410 | public List getAvailableVersions() | |
411 | { | |
412 | 0 | return null; |
413 | } | |
414 | ||
415 | /** | |
416 | * By default, do nothing. | |
417 | * | |
418 | * @see org.apache.maven.artifact.Artifact#setAvailableVersions(java.util.List) | |
419 | */ | |
420 | public void setAvailableVersions( List list ) | |
421 | { | |
422 | // nop | |
423 | 0 | } |
424 | ||
425 | /** | |
426 | * @return <code>false</code>. | |
427 | * @see org.apache.maven.artifact.Artifact#isOptional() | |
428 | */ | |
429 | public boolean isOptional() | |
430 | { | |
431 | 0 | return false; |
432 | } | |
433 | ||
434 | /** | |
435 | * By default, do nothing. | |
436 | * | |
437 | * @param b | |
438 | */ | |
439 | public void setOptional( boolean b ) | |
440 | { | |
441 | // nop | |
442 | 0 | } |
443 | ||
444 | /** | |
445 | * @return <code>null</code>. | |
446 | * @see org.apache.maven.artifact.Artifact#getSelectedVersion() | |
447 | */ | |
448 | public ArtifactVersion getSelectedVersion() | |
449 | throws OverConstrainedVersionException | |
450 | { | |
451 | 0 | return null; |
452 | } | |
453 | ||
454 | /** | |
455 | * @return <code>false</code>. | |
456 | * @see org.apache.maven.artifact.Artifact#isSelectedVersionKnown() | |
457 | */ | |
458 | public boolean isSelectedVersionKnown() | |
459 | throws OverConstrainedVersionException | |
460 | { | |
461 | 0 | return false; |
462 | } | |
463 | ||
464 | /** | |
465 | * @see java.lang.Object#toString() | |
466 | */ | |
467 | public String toString() | |
468 | { | |
469 | 0 | StringBuffer sb = new StringBuffer(); |
470 | 0 | if ( getGroupId() != null ) |
471 | { | |
472 | 0 | sb.append( getGroupId() ); |
473 | 0 | sb.append( ":" ); |
474 | } | |
475 | 0 | appendArtifactTypeClassifierString( sb ); |
476 | 0 | if ( version != null ) |
477 | { | |
478 | 0 | sb.append( ":" ); |
479 | 0 | sb.append( getVersion() ); |
480 | } | |
481 | 0 | if ( scope != null ) |
482 | { | |
483 | 0 | sb.append( ":" ); |
484 | 0 | sb.append( scope ); |
485 | } | |
486 | 0 | return sb.toString(); |
487 | } | |
488 | ||
489 | private void appendArtifactTypeClassifierString( StringBuffer sb ) | |
490 | { | |
491 | 0 | sb.append( getArtifactId() ); |
492 | 0 | sb.append( ":" ); |
493 | 0 | sb.append( getType() ); |
494 | 0 | if ( hasClassifier() ) |
495 | { | |
496 | 0 | sb.append( ":" ); |
497 | 0 | sb.append( getClassifier() ); |
498 | } | |
499 | 0 | } |
500 | ||
501 | public boolean isFromAuthoritativeRepository() | |
502 | { | |
503 | 0 | return true; |
504 | } | |
505 | ||
506 | public void setFromAuthoritativeRepository( boolean fromAuthoritativeRepository ) | |
507 | { | |
508 | // nothing | |
509 | 0 | } |
510 | } |