@@ -14,38 +14,44 @@ public class JsonEngineTest {
1414 public void testGetParentJsonPath_Nominal () {
1515
1616 // GIVEN
17- String jsonPath1 = "$['obj1']['obj2']" ;
17+ String jsonPath1 = "$['obj1']['obj2']['obj3'] " ;
1818 String jsonPath2 = "obj1.obj2" ;
1919 String jsonPath3 = "$.obj1.obj2" ;
20+ String jsonPath4 = "obj1" ;
2021
2122 // WHEN
2223 String parentJsonPath1 = JsonEngine .getParentJsonPath (jsonPath1 );
2324 String parentJsonPath2 = JsonEngine .getParentJsonPath (jsonPath2 );
2425 String parentJsonPath3 = JsonEngine .getParentJsonPath (jsonPath3 );
26+ String parentJsonPath4 = JsonEngine .getParentJsonPath (jsonPath4 );
2527
2628 // THEN
27- Assert .assertEquals ("$['obj1']" , parentJsonPath1 );
29+ Assert .assertEquals ("$['obj1']['obj2'] " , parentJsonPath1 );
2830 Assert .assertEquals ("$['obj1']" , parentJsonPath2 );
2931 Assert .assertEquals ("$['obj1']" , parentJsonPath3 );
32+ Assert .assertEquals ("$" , parentJsonPath4 );
3033 }
3134
3235 @ Test
3336 public void testGetJsonElementKey_Nominal () {
3437
3538 // GIVEN
36- String jsonPath1 = "$['obj1']['obj2']" ;
39+ String jsonPath1 = "$['obj0'][' obj1']['obj2']" ;
3740 String jsonPath2 = "obj1.obj2" ;
3841 String jsonPath3 = "$.obj1.obj2" ;
42+ String jsonPath4 = "obj2" ;
3943
4044 // WHEN
4145 String jsonElementKey1 = JsonEngine .getJsonElementKey (jsonPath1 );
4246 String jsonElementKey2 = JsonEngine .getJsonElementKey (jsonPath2 );
4347 String jsonElementKey3 = JsonEngine .getJsonElementKey (jsonPath3 );
48+ String jsonElementKey4 = JsonEngine .getJsonElementKey (jsonPath4 );
4449
4550 // THEN
4651 Assert .assertEquals ("obj2" , jsonElementKey1 );
4752 Assert .assertEquals ("obj2" , jsonElementKey2 );
4853 Assert .assertEquals ("obj2" , jsonElementKey3 );
54+ Assert .assertEquals ("obj2" , jsonElementKey3 );
4955 }
5056
5157 @ Test
0 commit comments