@@ -36,8 +36,8 @@ public void jsonObjectFromEnum() {
3636 Object doc = Configuration .defaultConfiguration ().jsonProvider ()
3737 .parse (jsonObject .toString ());
3838 assertTrue ("expecting 2 items in top level object" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
39- assertTrue ("expecting val 2" , "val 2" .equals (JsonPath . read ( doc , "$. value" )));
40- assertTrue ("expecting 2" , Integer .valueOf (2 ).equals (JsonPath . read ( doc , "$. intVal" )));
39+ assertTrue ("expecting val 2" , "val 2" .equals (jsonObject . query ( "/ value" )));
40+ assertTrue ("expecting 2" , Integer .valueOf (2 ).equals (jsonObject . query ( "/ intVal" )));
4141
4242 /**
4343 * class which contains enum instances. Each enum should be stored
@@ -53,8 +53,8 @@ public void jsonObjectFromEnum() {
5353 assertTrue ("expecting 2 items in top level object" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
5454 assertTrue ("expecting 2 items in myEnumField object" , ((Map <?,?>)(JsonPath .read (doc , "$.myEnumField" ))).size () == 2 );
5555 assertTrue ("expecting 0 items in myEnum object" , ((Map <?,?>)(JsonPath .read (doc , "$.myEnum" ))).size () == 0 );
56- assertTrue ("expecting 3" , Integer .valueOf (3 ).equals (JsonPath . read ( doc , "$. myEnumField. intVal" )));
57- assertTrue ("expecting val 3" , "val 3" .equals (JsonPath . read ( doc , "$. myEnumField. value" )));
56+ assertTrue ("expecting 3" , Integer .valueOf (3 ).equals (jsonObject . query ( "/ myEnumField/ intVal" )));
57+ assertTrue ("expecting val 3" , "val 3" .equals (jsonObject . query ( "/ myEnumField/ value" )));
5858 }
5959
6060 /**
@@ -74,19 +74,19 @@ public void jsonObjectFromEnumWithNames() {
7474 // validate JSON object
7575 Object doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
7676 assertTrue ("expected 3 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 3 );
77- assertTrue ("expected VAL1" , " VAL1" .equals (JsonPath . read ( doc , "$. VAL1" )));
78- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. VAL2" )));
79- assertTrue ("expected VAL3" , " VAL3" .equals (JsonPath . read ( doc , "$. VAL3" )));
77+ assertTrue ("expected VAL1" , MyEnum . VAL1 .equals (jsonObject . query ( "/ VAL1" )));
78+ assertTrue ("expected VAL2" , MyEnum . VAL2 .equals (jsonObject . query ( "/ VAL2" )));
79+ assertTrue ("expected VAL3" , MyEnum . VAL3 .equals (jsonObject . query ( "/ VAL3" )));
8080
8181 MyEnumField myEnumField = MyEnumField .VAL3 ;
8282 names = JSONObject .getNames (myEnumField );
8383 // The values will be MyEnmField fields
8484 jsonObject = new JSONObject (myEnumField , names );
8585 doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
8686 assertTrue ("expected 3 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 3 );
87- assertTrue ("expected VAL1" , " VAL1" .equals (JsonPath . read ( doc , "$. VAL1" )));
88- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. VAL2" )));
89- assertTrue ("expected VAL3" , " VAL3" .equals (JsonPath . read ( doc , "$. VAL3" )));
87+ assertTrue ("expected VAL1" , MyEnumField . VAL1 .equals (jsonObject . query ( "/ VAL1" )));
88+ assertTrue ("expected VAL2" , MyEnumField . VAL2 .equals (jsonObject . query ( "/ VAL2" )));
89+ assertTrue ("expected VAL3" , myEnumField . VAL3 .equals (jsonObject . query ( "/ VAL3" )));
9090
9191 }
9292
@@ -105,8 +105,8 @@ public void enumPut() {
105105 // validate JSON content
106106 Object doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
107107 assertTrue ("expected 2 top level objects" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
108- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. myEnum" )));
109- assertTrue ("expected VAL1" , " VAL1" .equals (JsonPath . read ( doc , "$. myEnumField" )));
108+ assertTrue ("expected VAL2" , MyEnum . VAL2 .equals (jsonObject . query ( "/ myEnum" )));
109+ assertTrue ("expected VAL1" , MyEnumField . VAL1 .equals (jsonObject . query ( "/ myEnumField" )));
110110
111111 JSONArray jsonArray = new JSONArray ();
112112 jsonArray .put (myEnum );
@@ -115,8 +115,8 @@ public void enumPut() {
115115 // validate JSON content
116116 doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonArray .toString ());
117117 assertTrue ("expected 2 top level objects" , ((List <?>)(JsonPath .read (doc , "$" ))).size () == 2 );
118- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$[0] " )));
119- assertTrue ("expected VAL1" , " VAL1" .equals (JsonPath . read ( doc , "$[1] " )));
118+ assertTrue ("expected VAL2" , MyEnum . VAL2 .equals (jsonArray . query ( "/0 " )));
119+ assertTrue ("expected VAL1" , MyEnumField . VAL1 .equals (jsonArray . query ( "/1 " )));
120120
121121 /**
122122 * Leaving these tests because they exercise get, opt, and remove
@@ -174,8 +174,8 @@ public void enumToString() {
174174 // validate JSON content
175175 Object doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
176176 assertTrue ("expected 2 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
177- assertTrue ("expected val 2" , "val 2" .equals (JsonPath . read ( doc , "$. value" )));
178- assertTrue ("expected 2" , Integer .valueOf (2 ).equals (JsonPath . read ( doc , "$. intVal" )));
177+ assertTrue ("expected val 2" , "val 2" .equals (jsonObject . query ( "/ value" )));
178+ assertTrue ("expected 2" , Integer .valueOf (2 ).equals (jsonObject . query ( "/ intVal" )));
179179
180180 MyEnumClass myEnumClass = new MyEnumClass ();
181181 myEnumClass .setMyEnum (MyEnum .VAL1 );
@@ -187,28 +187,28 @@ public void enumToString() {
187187 assertTrue ("expected 2 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
188188 assertTrue ("expected 2 myEnumField items" , ((Map <?,?>)(JsonPath .read (doc , "$.myEnumField" ))).size () == 2 );
189189 assertTrue ("expected 0 myEnum items" , ((Map <?,?>)(JsonPath .read (doc , "$.myEnum" ))).size () == 0 );
190- assertTrue ("expected 3" , Integer .valueOf (3 ).equals (JsonPath . read ( doc , "$. myEnumField. intVal" )));
191- assertTrue ("expected val 3" , "val 3" .equals (JsonPath . read ( doc , "$. myEnumField. value" )));
190+ assertTrue ("expected 3" , Integer .valueOf (3 ).equals (jsonObject . query ( "/ myEnumField/ intVal" )));
191+ assertTrue ("expected val 3" , "val 3" .equals (jsonObject . query ( "/ myEnumField/ value" )));
192192
193193 String [] names = JSONObject .getNames (myEnum );
194194 jsonObject = new JSONObject (myEnum , names );
195195
196196 // validate JSON content
197197 doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
198198 assertTrue ("expected 3 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 3 );
199- assertTrue ("expected VAL1" , " VAL1" .equals (JsonPath . read ( doc , "$. VAL1" )));
200- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. VAL2" )));
201- assertTrue ("expected VAL3" , " VAL3" .equals (JsonPath . read ( doc , "$. VAL3" )));
199+ assertTrue ("expected VAL1" , MyEnum . VAL1 .equals (jsonObject . query ( "/ VAL1" )));
200+ assertTrue ("expected VAL2" , MyEnum . VAL2 .equals (jsonObject . query ( "/ VAL2" )));
201+ assertTrue ("expected VAL3" , MyEnum . VAL3 .equals (jsonObject . query ( "/ VAL3" )));
202202
203203 names = JSONObject .getNames (myEnumField );
204204 jsonObject = new JSONObject (myEnumField , names );
205205
206206 // validate JSON content
207207 doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
208208 assertTrue ("expected 3 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 3 );
209- assertTrue ("expected VAL1" , " VAL1" .equals (JsonPath . read ( doc , "$. VAL1" )));
210- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. VAL2" )));
211- assertTrue ("expected VAL3" , " VAL3" .equals (JsonPath . read ( doc , "$. VAL3" )));
209+ assertTrue ("expected VAL1" , MyEnumField . VAL1 .equals (jsonObject . query ( "/ VAL1" )));
210+ assertTrue ("expected VAL2" , MyEnumField . VAL2 .equals (jsonObject . query ( "/ VAL2" )));
211+ assertTrue ("expected VAL3" , MyEnumField . VAL3 .equals (jsonObject . query ( "/ VAL3" )));
212212
213213 expectedStr = "{\" myEnum\" :\" VAL2\" , \" myEnumField\" :\" VAL2\" }" ;
214214 jsonObject = new JSONObject ();
@@ -218,8 +218,8 @@ public void enumToString() {
218218 // validate JSON content
219219 doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
220220 assertTrue ("expected 2 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
221- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. myEnum" )));
222- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$. myEnumField" )));
221+ assertTrue ("expected VAL2" , MyEnum . VAL2 .equals (jsonObject . query ( "/ myEnum" )));
222+ assertTrue ("expected VAL2" , MyEnumField . VAL2 .equals (jsonObject . query ( "/ myEnumField" )));
223223
224224 JSONArray jsonArray = new JSONArray ();
225225 jsonArray .put (myEnum );
@@ -228,8 +228,8 @@ public void enumToString() {
228228 // validate JSON content
229229 doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonArray .toString ());
230230 assertTrue ("expected 2 top level items" , ((List <?>)(JsonPath .read (doc , "$" ))).size () == 2 );
231- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$[0] " )));
232- assertTrue ("expected VAL2" , " VAL2" .equals (JsonPath . read ( doc , "$[1] " )));
231+ assertTrue ("expected VAL2" , MyEnum . VAL2 .equals (jsonArray . query ( "/0 " )));
232+ assertTrue ("expected VAL2" , MyEnumField . VAL2 .equals (jsonArray . query ( "/1 " )));
233233 }
234234
235235 /**
@@ -248,8 +248,8 @@ public void wrap() {
248248 // validate JSON content
249249 Object doc = Configuration .defaultConfiguration ().jsonProvider ().parse (jsonObject .toString ());
250250 assertTrue ("expected 2 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
251- assertTrue ("expected val 2" , "val 2" .equals (JsonPath . read ( doc , "$. value" )));
252- assertTrue ("expected 2" , Integer .valueOf (2 ).equals (JsonPath . read ( doc , "$. intVal" )));
251+ assertTrue ("expected val 2" , "val 2" .equals (jsonObject . query ( "/ value" )));
252+ assertTrue ("expected 2" , Integer .valueOf (2 ).equals (jsonObject . query ( "/ intVal" )));
253253
254254 MyEnumClass myEnumClass = new MyEnumClass ();
255255 myEnumClass .setMyEnum (MyEnum .VAL1 );
@@ -261,8 +261,8 @@ public void wrap() {
261261 assertTrue ("expected 2 top level items" , ((Map <?,?>)(JsonPath .read (doc , "$" ))).size () == 2 );
262262 assertTrue ("expected 2 myEnumField items" , ((Map <?,?>)(JsonPath .read (doc , "$.myEnumField" ))).size () == 2 );
263263 assertTrue ("expected 0 myEnum items" , ((Map <?,?>)(JsonPath .read (doc , "$.myEnum" ))).size () == 0 );
264- assertTrue ("expected 3" , Integer .valueOf (3 ).equals (JsonPath . read ( doc , "$. myEnumField. intVal" )));
265- assertTrue ("expected val 3" , "val 3" .equals (JsonPath . read ( doc , "$. myEnumField. value" )));
264+ assertTrue ("expected 3" , Integer .valueOf (3 ).equals (jsonObject . query ( "/ myEnumField/ intVal" )));
265+ assertTrue ("expected val 3" , "val 3" .equals (jsonObject . query ( "/ myEnumField/ value" )));
266266
267267 }
268268
0 commit comments