File tree Expand file tree Collapse file tree
main/java/com/gooddata/executeafm/result
test/groovy/com/gooddata/executeafm/result Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import com .fasterxml .jackson .annotation .JsonTypeInfo ;
1010import com .gooddata .util .GoodDataToStringBuilder ;
1111
12- import static com .gooddata .util .Validate .notEmpty ;
12+ import static com .gooddata .util .Validate .notNull ;
1313
1414/**
1515 * Represent header items available in {@link ExecutionResult}
@@ -25,7 +25,7 @@ public abstract class ResultHeaderItem {
2525 private final String name ;
2626
2727 protected ResultHeaderItem (final String name ) {
28- this .name = notEmpty (name , "name" );
28+ this .name = notNull (name , "name" );
2929 }
3030
3131 /**
Original file line number Diff line number Diff line change @@ -24,6 +24,22 @@ public class ResultTotalHeaderItem extends ResultHeaderItem {
2424
2525 private final String type ;
2626
27+ /**
28+ * Creates new instance of given total type, type is used for the name as well
29+ * @param type total type
30+ */
31+ public ResultTotalHeaderItem (final String type ) {
32+ this (type , type );
33+ }
34+
35+ /**
36+ * Creates new instance of given total type, type is used for the name as well
37+ * @param type total type
38+ */
39+ public ResultTotalHeaderItem (final Total type ) {
40+ this (notNull (type , "type" ).toString ());
41+ }
42+
2743 /**
2844 * Creates new instance of given header name and total type
2945 * @param name header name
Original file line number Diff line number Diff line change @@ -25,4 +25,17 @@ class ResultHeaderItemTest extends Specification {
2525 typeClass << [AttributeHeaderItem , ResultMeasureHeaderItem , ResultTotalHeaderItem ]
2626 type = typeClass. simpleName. uncapitalize()
2727 }
28+
29+ def " should allow empty name" () {
30+ expect :
31+ new ResultHeaderItem (' ' ) {}. name == ' '
32+ }
33+
34+ def " should not allow null name" () {
35+ when :
36+ new ResultHeaderItem (null ) {}
37+
38+ then :
39+ thrown(IllegalArgumentException )
40+ }
2841}
Original file line number Diff line number Diff line change @@ -32,4 +32,16 @@ class ResultTotalHeaderItemTest extends Specification {
3232 item. name == ' Some total'
3333 item. type == ' avg'
3434 }
35+
36+ def " should create from type only" () {
37+ expect :
38+ with(new ResultTotalHeaderItem (' avg' )) {
39+ name == ' avg'
40+ type == ' avg'
41+ }
42+ with(new ResultTotalHeaderItem (Total . SUM )) {
43+ name == ' sum'
44+ type == ' sum'
45+ }
46+ }
3547}
You can’t perform that action at this time.
0 commit comments