-
-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy pathMavenModuleWithDetails.java
More file actions
128 lines (104 loc) · 3.18 KB
/
MavenModuleWithDetails.java
File metadata and controls
128 lines (104 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Copyright (c) 2018 Cosmin Stejerean, Karl Heinz Marbaise, and contributors.
*
* Distributed under the MIT license: http://opensource.org/licenses/MIT
*/
package com.offbytwo.jenkins.model;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import static com.google.common.collect.Lists.transform;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
/**
* Model Class for Maven Modules
*
* @author Jakub Zacek
*/
public class MavenModuleWithDetails extends BaseModel {
private List<Build> builds;
private List actions;
private String displayName;
private BuildResult result;
private String url;
private long duration;
private long timestamp;
public List getActions() {
return actions;
}
public void setActions(List actions) {
this.actions = actions;
}
public void setBuilds(List<Build> builds) {
this.builds = builds;
}
public List<Build> getBuilds() {
if (builds == null) {
return Collections.emptyList();
} else {
return transform(builds, new Function<Build, Build>() {
@Override
public Build apply(Build from) {
return buildWithClient(from);
}
});
}
}
public Build getBuildByNumber(final int buildNumber) {
Predicate<Build> isMatchingBuildNumber = new Predicate<Build>() {
@Override
public boolean apply(Build input) {
return input.getNumber() == buildNumber;
}
};
Optional<Build> optionalBuild = Iterables.tryFind(builds, isMatchingBuildNumber);
// TODO: Check if we could use Build#NO...instead of Null?
return optionalBuild.orNull() == null ? null : buildWithClient(optionalBuild.orNull());
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public BuildResult getResult() {
return result;
}
public void setResult(BuildResult result) {
this.result = result;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public long getDuration() {
return duration;
}
public void setDuration(long duration) {
this.duration = duration;
}
public String getConsoleOutputText() throws IOException {
return client.get(getUrl() + "/logText/progressiveText");
}
public TestReport getTestReport() throws IOException {
return client.get(this.getUrl() + "/testReport/?depth=1", TestReport.class);
}
private Build buildWithClient(Build from) {
Build ret = from;
if (from != null) {
ret = new Build(from);
ret.setClient(client);
}
return ret;
}
}