@@ -1021,7 +1021,7 @@ public void issue_309(){
1021
1021
assertThat ((String )doc .read ("$.jsonArr[0].name" )).isEqualTo ("nOne" );
1022
1022
assertThat ((String )doc .read ("$.jsonArr[1].name" )).isEqualTo ("Jayway" );
1023
1023
}
1024
-
1024
+
1025
1025
@ Test
1026
1026
public void issue_378 (){
1027
1027
@@ -1039,12 +1039,81 @@ public void issue_378(){
1039
1039
.jsonProvider (new JacksonJsonNodeJsonProvider ())
1040
1040
.mappingProvider (new JacksonMappingProvider ())
1041
1041
.build ();
1042
-
1042
+
1043
1043
DocumentContext ctx = JsonPath .using (configuration ).parse (json );
1044
1044
1045
1045
String path = "$.nodes[*][?(!([\" 1.2.3.4\" ] subsetof @.ntpServers))].ntpServers" ;
1046
1046
JsonPath jsonPath = JsonPath .compile (path );
1047
1047
1048
1048
ctx .read (jsonPath );
1049
1049
}
1050
+
1051
+ //CS304 (manually written) Issue link: https://github.com/json-path/JsonPath/issues/620
1052
+ @ Test
1053
+ public void issue_620_1 (){
1054
+ String json = "{\n " +
1055
+ " \" complexText\" : {\n " +
1056
+ " \" nestedFields\" : [\n " +
1057
+ " {\n " +
1058
+ " \" index\" : \" 0\" ,\n " +
1059
+ " \" name\" : \" A\" \n " +
1060
+ " },\n " +
1061
+ " {\n " +
1062
+ " \" index\" : \" 1\" ,\n " +
1063
+ " \" name\" : \" B\" \n " +
1064
+ " },\n " +
1065
+ " {\n " +
1066
+ " \" index\" : \" 2\" ,\n " +
1067
+ " \" name\" : \" C\" \n " +
1068
+ " }\n " +
1069
+ " ]\n " +
1070
+ " }\n " +
1071
+ "}" ;
1072
+
1073
+ String path1 = "$.concat($.complexText.nestedFields[?(@.index == '2')].name," +
1074
+ "$.complexText.nestedFields[?(@.index == '1')].name," +
1075
+ "$.complexText.nestedFields[?(@.index == '0')].name)" ;
1076
+ String path2 = "$.concat($.complexText.nestedFields[2].name," +
1077
+ "$.complexText.nestedFields[1].name," +
1078
+ "$.complexText.nestedFields[0].name)" ;
1079
+
1080
+ assertThat ((String )JsonPath .read (json ,path1 )).isEqualTo ("CBA" );
1081
+ assertThat ((String )JsonPath .read (json ,path2 )).isEqualTo ("CBA" );
1082
+ }
1083
+ //CS304 (manually written) Issue link: https://github.com/json-path/JsonPath/issues/620
1084
+ @ Test
1085
+ public void issue_620_2 (){
1086
+ String json = "{\n " +
1087
+ " \" complexText\" : {\n " +
1088
+ " \" nestedFields\" : [\n " +
1089
+ " {\n " +
1090
+ " \" index\" : \" 0\" ,\n " +
1091
+ " \" name\" : \" A\" \n " +
1092
+ " },\n " +
1093
+ " {\n " +
1094
+ " \" index\" : \" 1\" ,\n " +
1095
+ " \" name\" : \" B\" \n " +
1096
+ " },\n " +
1097
+ " {\n " +
1098
+ " \" index\" : \" 2\" ,\n " +
1099
+ " \" name\" : \" C\" \n " +
1100
+ " }\n " +
1101
+ " ]\n " +
1102
+ " }\n " +
1103
+ "}" ;
1104
+
1105
+ String path1 = "$.concat($.complexText.nestedFields[?(@.index == '2')].name," +
1106
+ "$.complexText.nestedFields[?((@.index == '1')].name," +
1107
+ "$.complexText.nestedFields[?(@.index == '0')].name)" ;
1108
+
1109
+ boolean thrown = false ;
1110
+
1111
+ try {
1112
+ Object result = (Object ) JsonPath .read (json ,path1 );
1113
+ } catch (Exception e ) {
1114
+ thrown = true ;
1115
+ }
1116
+
1117
+ assertTrue (thrown );
1118
+ }
1050
1119
}
0 commit comments