File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
main/java/org/elasticsearch/script
test/java/org/elasticsearch/script Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,17 @@ public Set<Entry<String, Object>> entrySet() {
9898
9999 @ Override
100100 public String toString () {
101- return delegate .toString ();
101+ StringBuilder sb = new StringBuilder ("DynamicMap [" );
102+ int count = 0 ;
103+ for (Map .Entry <String , Object > entry : entrySet ()) {
104+ sb .append (entry .getKey ());
105+ sb .append (": " );
106+ sb .append (entry .getValue ());
107+ if (++count < size ()) {
108+ sb .append (", " );
109+ }
110+ }
111+ sb .append ("]" );
112+ return sb .toString ();
102113 }
103114}
Original file line number Diff line number Diff line change 2929import java .util .HashMap ;
3030import java .util .Map ;
3131
32+ import static org .hamcrest .Matchers .both ;
33+ import static org .hamcrest .Matchers .contains ;
34+ import static org .hamcrest .Matchers .containsString ;
3235import static org .hamcrest .Matchers .equalTo ;
36+ import static org .hamcrest .Matchers .is ;
3337
3438public class ScriptTests extends ESTestCase {
3539
@@ -192,7 +196,6 @@ public void testDynamicMapToString() {
192196 map .put ("long" , 1L );
193197 map .put ("string" , "value" );
194198 DynamicMap dm = new DynamicMap (map , Collections .emptyMap ());
195- assertTrue (dm .toString ().contains ("string=value" ));
196- assertTrue (dm .toString ().contains ("long=1" ));
199+ assertThat (dm .toString (), both (containsString ("long: 1" )).and (containsString ("string: value" )));
197200 }
198201}
You can’t perform that action at this time.
0 commit comments