55import static java .util .Map .of ;
66import static org .junit .jupiter .api .Assertions .assertEquals ;
77import java .util .Arrays ;
8+ import java .util .List ;
89import java .util .Map ;
910import org .junit .jupiter .api .Assertions ;
1011import org .junit .jupiter .api .Disabled ;
@@ -20,32 +21,47 @@ public void testArray() {
2021 var res2 = expr2 .evaluate (of ("key" , asList (of ("x" , "y" ), of ("a" , "b" ))));
2122 assertEquals (res1 , res2 );
2223 }
23-
24+
2425 @ Test
2526 public void filterTest () {
2627 // Frame value not evaluated if used in array filter #45
2728 Jsonata expr = jsonata ("($arr := [{'x':1}, {'x':2}];$arr[x=$number($$.variable.field)])" );
2829 Assertions .assertNotNull (expr .evaluate (Map .of ("variable" , Map .of ("field" , "1" ))));
2930 }
30-
31+
3132 @ Disabled
3233 @ Test
3334 public void testIndex () {
3435 Jsonata expr = jsonata ("($x:=['a','b']; $x#$i.$i)" );
3536 Assertions .assertEquals (Arrays .asList (0 , 1 ), expr .evaluate (1 ));
3637 Assertions .assertEquals (Arrays .asList (0 , 1 ), expr .evaluate (null ));
3738 }
38-
39+
3940 @ Test
4041 public void testSort () {
4142 Jsonata expr = jsonata ("$sort([{'x': 2}, {'x': 1}], function($l, $r){$l.x > $r.x})" );
4243 Assertions .assertEquals (Arrays .asList (Map .of ("x" , 1 ), Map .of ("x" , 2 )), expr .evaluate (null ));
4344 }
44-
45+
4546 @ Disabled
4647 @ Test
4748 public void testSortNull () {
4849 Jsonata expr = jsonata ("$sort([{'x': 2}, {'x': 1}], function($l, $r){$l.y > $r.y})" );
4950 Assertions .assertEquals (Arrays .asList (Map .of ("x" , 2 ), Map .of ("x" , 1 )), expr .evaluate (null ));
5051 }
52+
53+ @ Disabled
54+ @ Test
55+ public void testWildcardFilter () {
56+ Object value1 = Map .of ("value" , Map .of (Map .of ("Name" , "Cell1" ), Map .of ("Product" , "Product1" )));
57+ Object value2 = Map .of ("value" , Map .of (Map .of ("Name" , "Cell2" ), Map .of ("Product" , "Product2" )));
58+ Object data = List .of (value1 , value2 );
59+
60+ // Expecting the first object in the array
61+ var expression = jsonata ("*[value.Product = 'Product1']" );
62+ Assertions .assertEquals (value1 , expression .evaluate (data ));
63+
64+ var expression2 = jsonata ("**[value.Product = 'Product1']" );
65+ Assertions .assertEquals (value1 , expression2 .evaluate (data ));
66+ }
5167}
0 commit comments