File tree 2 files changed +31
-0
lines changed
main/java/org/springframework/graphql/data
test/java/org/springframework/graphql/data
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,23 @@ public int hashCode() {
137
137
return result ;
138
138
}
139
139
140
+ /**
141
+ * Returns a non-empty string representation of this {@code ArgumentValue}
142
+ * suitable for debugging.
143
+ *
144
+ * @return the string representation of this instance
145
+ */
146
+ @ Override
147
+ public String toString () {
148
+ if (this .omitted ) {
149
+ return "ArgumentValue.omitted" ;
150
+ }
151
+ if (this .value == null ){
152
+ return "ArgumentValue.empty" ;
153
+ }
154
+ return "ArgumentValue[%s]" .formatted (this .value );
155
+ }
156
+
140
157
141
158
/**
142
159
* Static factory method for an argument value that was provided, even if
Original file line number Diff line number Diff line change @@ -80,4 +80,18 @@ void ifPresentShouldSkipWhenOmitted() {
80
80
assertThat (called .get ()).isFalse ();
81
81
}
82
82
83
+ @ Test
84
+ void toStringShouldReturnOmittedWhenOmitted () {
85
+ assertThat (ArgumentValue .omitted ()).hasToString ("ArgumentValue.omitted" );
86
+ }
87
+
88
+ @ Test
89
+ void toStringShouldReturnEmptyWhenNull () {
90
+ assertThat (ArgumentValue .ofNullable (null )).hasToString ("ArgumentValue.empty" );
91
+ }
92
+
93
+ @ Test
94
+ void toStringShouldReturnValueWhenValue () {
95
+ assertThat (ArgumentValue .ofNullable ("hello" )).hasToString ("ArgumentValue[hello]" );
96
+ }
83
97
}
You can’t perform that action at this time.
0 commit comments