Skip to content

Commit 9ab153b

Browse files
authored
Merge pull request #558 from gooddata/jmi-header
add TotalHeaderItem's constructor from Total
2 parents f3f37c6 + 0ff4510 commit 9ab153b

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/com/gooddata/executeafm/response/TotalHeaderItem.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
import com.fasterxml.jackson.annotation.JsonProperty;
1010
import com.fasterxml.jackson.annotation.JsonTypeInfo;
1111
import com.fasterxml.jackson.annotation.JsonTypeName;
12+
import com.gooddata.md.report.Total;
1213
import com.gooddata.util.GoodDataToStringBuilder;
1314

15+
import static com.gooddata.util.Validate.notNull;
16+
1417
/**
1518
* Header of total
1619
*/
@@ -29,6 +32,14 @@ public TotalHeaderItem(@JsonProperty("name") final String name) {
2932
this.name = name;
3033
}
3134

35+
/**
36+
* Creates new header
37+
* @param total total value
38+
*/
39+
public TotalHeaderItem(final Total total) {
40+
this(notNull(total, "total").toString());
41+
}
42+
3243
/**
3344
* @return name of total
3445
*/

src/test/groovy/com/gooddata/executeafm/response/TotalHeaderItemTest.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
package com.gooddata.executeafm.response
77

8+
import com.gooddata.md.report.Total
89
import spock.lang.Specification
910

1011
import static com.gooddata.util.ResourceUtils.readObjectFromResource
@@ -18,7 +19,7 @@ class TotalHeaderItemTest extends Specification {
1819

1920
def "should serialize"() {
2021
expect:
21-
that new TotalHeaderItem('avg'),
22+
that new TotalHeaderItem(Total.AVG),
2223
jsonEquals(resource(TOTAL_HEADER_ITEM_JSON))
2324
}
2425

0 commit comments

Comments
 (0)