Skip to content

Commit 1b1129b

Browse files
committed
Merge branch 'plot_correct_properties_files'
2 parents 3dbff2c + 78610bb commit 1b1129b

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PlotContext.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class PlotContext implements Context {
6262
this.logarithmic = logarithmic
6363
}
6464

65-
void propertiesFile(String fileName, @DslContext(PlotSeriesContext) Closure plotSeriesClosure = null) {
65+
void propertiesFile(String fileName, @DslContext(PlotPropertiesSeriesContext) Closure plotSeriesClosure = null) {
6666
checkArgument(!Strings.isNullOrEmpty(fileName), 'fileName must not be null or empty')
6767

68-
PlotSeriesContext plotSeriesContext = new PlotSeriesContext(fileName, 'properties', 'PropertiesSeries')
68+
PlotSeriesContext plotSeriesContext = new PlotPropertiesSeriesContext(fileName)
6969
ContextHelper.executeInContext(plotSeriesClosure, plotSeriesContext)
7070

7171
dataSeriesList << plotSeriesContext
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package javaposse.jobdsl.dsl.helpers.publisher
2+
3+
class PlotPropertiesSeriesContext extends PlotSeriesContext {
4+
String label
5+
6+
PlotPropertiesSeriesContext(String fileName) {
7+
super(fileName, 'properties', 'PropertiesSeries')
8+
}
9+
10+
void label(String label) {
11+
this.label = label
12+
}
13+
}

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PlotSeriesContext.groovy

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@ package javaposse.jobdsl.dsl.helpers.publisher
22

33
import javaposse.jobdsl.dsl.Context
44

5-
class PlotSeriesContext implements Context {
5+
abstract class PlotSeriesContext implements Context {
66
final String fileName
77
final String fileType
88
final String seriesType
9-
String label
109

11-
PlotSeriesContext(String fileName, String fileType, String seriesType) {
10+
protected PlotSeriesContext(String fileName, String fileType, String seriesType) {
1211
this.fileName = fileName
1312
this.fileType = fileType
1413
this.seriesType = seriesType
1514
}
16-
17-
void label(String label) {
18-
this.label = label
19-
}
2015
}

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,10 @@ class PublisherContext implements Context {
386386
plot.dataSeriesList.each { PlotSeriesContext data ->
387387
"hudson.plugins.plot.${data.seriesType}" {
388388
file(data.fileName)
389-
label(data.label ?: '')
390389
fileType(data.fileType)
390+
if (data instanceof PlotPropertiesSeriesContext) {
391+
label(data.label ?: '')
392+
}
391393
if (data instanceof PlotXMLSeriesContext) {
392394
xpathString(data.xpath ?: '')
393395
url(data.url ?: '')

job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,9 +3228,8 @@ class PublisherContextSpec extends Specification {
32283228
exclZero[0].value() == false
32293229
logarithmic[0].value() == false
32303230
with(series[0].'hudson.plugins.plot.XMLSeries'[0]) {
3231-
children().size() == 6
3231+
children().size() == 5
32323232
file[0].value() == 'data.prop'
3233-
label[0].value() == ''
32343233
fileType[0].value() == 'xml'
32353234
nodeTypeString[0].value() == 'NODESET'
32363235
url[0].value() == ''
@@ -3246,7 +3245,6 @@ class PublisherContextSpec extends Specification {
32463245
context.plotBuildData {
32473246
plot('my group', 'some.csv') {
32483247
xmlFile('data.prop') {
3249-
label('some label')
32503248
nodeType('NODE')
32513249
url('http://somewhere')
32523250
xpath('an xpath string')
@@ -3272,9 +3270,8 @@ class PublisherContextSpec extends Specification {
32723270
exclZero[0].value() == false
32733271
logarithmic[0].value() == false
32743272
with(series[0].'hudson.plugins.plot.XMLSeries'[0]) {
3275-
children().size() == 6
3273+
children().size() == 5
32763274
file[0].value() == 'data.prop'
3277-
label[0].value() == 'some label'
32783275
fileType[0].value() == 'xml'
32793276
nodeTypeString[0].value() == 'NODE'
32803277
url[0].value() == 'http://somewhere'

0 commit comments

Comments
 (0)