-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathAdapter.java
More file actions
98 lines (87 loc) · 3.28 KB
/
Adapter.java
File metadata and controls
98 lines (87 loc) · 3.28 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
package io.jenkins.plugins.coverage;
import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.PageArea;
import org.jenkinsci.test.acceptance.po.PageAreaImpl;
import io.jenkins.plugins.coverage.AdapterThreshold.AdapterThresholdTarget;
/**
* Adapter which can be added in the configuration of the {@link CoveragePublisher} of a FreeStyle Project.
*/
public class Adapter extends PageAreaImpl {
private final Control reportFilePath = control("path");
private final Control threshold = control("repeatable-add");
private final Control mergeToOneReport = control("mergeToOneReport");
private final Control delete = control("repeatable-delete");
private final Control advancedOptions = control("advanced-button");
/**
* Constructor to create {@link Adapter} for {@link CoveragePublisher}.
*
* @param reportPublisher
* which should be created, f. e. jacoco or cobertura
* @param path
* of parent page
*/
public Adapter(PageArea reportPublisher, String path) {
super(reportPublisher, path);
}
/**
* Setter for path of report file.
*
* @param reportFilePath
* path to report file.
*/
public void setReportFilePath(String reportFilePath) {
this.reportFilePath.set(reportFilePath);
}
/**
* Setter for merging to one report.
*
* @param mergeReports
* boolean for merging to one report
*/
public void setMergeToOneReport(boolean mergeReports) {
ensureAdvancedOptionsIsActivated();
mergeToOneReport.check(mergeReports);
}
/**
* Adds empty {@link AdapterThreshold}.
* @return new Threshold to Adapter
*/
public AdapterThreshold createThresholdsPageArea() {
ensureAdvancedOptionsIsActivated();
String path = createPageArea("thresholds", () -> this.threshold.click());
return new AdapterThreshold(this, path);
}
/**
* Adds {@link AdapterThreshold} with values.
* @param thresholdTarget value using {@link AdapterThresholdTarget}
* @param unhealthyThreshold value to be set
* @param unstableThreshold value to be set
* @param failUnhealthy value for setting if build should fail on unhealthy
* @return threshold
*/
public AdapterThreshold createThresholdsPageArea(AdapterThresholdTarget thresholdTarget, double unhealthyThreshold,
double unstableThreshold, boolean failUnhealthy) {
ensureAdvancedOptionsIsActivated();
String path = createPageArea("thresholds", () -> this.threshold.click());
AdapterThreshold adapterThreshold = new AdapterThreshold(this, path);
adapterThreshold.setThresholdTarget(thresholdTarget);
adapterThreshold.setUnhealthyThreshold(unhealthyThreshold);
adapterThreshold.setUnstableThreshold(unstableThreshold);
adapterThreshold.setFailUnhealthy(failUnhealthy);
return adapterThreshold;
}
/**
* Activates advanced options to use setters of {@link Adapter}.
*/
public void ensureAdvancedOptionsIsActivated() {
if (advancedOptions.exists()) {
advancedOptions.click();
}
}
/**
* Removes adapter.
*/
public void deleteAdapter() {
this.delete.click();
}
}