33import static org .assertj .core .api .Assertions .assertThat ;
44
55import com .fasterxml .jackson .annotation .JsonValue ;
6+ import com .google .common .collect .ImmutableMap ;
67import com .google .common .collect .Lists ;
78import com .hubspot .jinjava .BaseJinjavaTest ;
89import com .hubspot .jinjava .objects .serialization .PyishSerializable ;
@@ -25,6 +26,17 @@ public void setup() {
2526 new User (2 , false , null , new Option (2 , "option2" ))
2627 )
2728 );
29+ jinjava
30+ .getGlobalContext ()
31+ .put (
32+ "numbers" ,
33+ Lists .newArrayList (
34+ ImmutableMap .of ("number" , 1 ),
35+ ImmutableMap .of ("number" , 2 ),
36+ ImmutableMap .of ("number" , 3 ),
37+ ImmutableMap .of ("number" , 4 )
38+ )
39+ );
2840 }
2941
3042 @ Test
@@ -101,6 +113,50 @@ public void selectAttrWithNestedProperty() {
101113 .isEqualTo ("[2]" );
102114 }
103115
116+ @ Test
117+ public void selectAttrWithSymbolicLtExp () {
118+ assertThat (
119+ jinjava .render (
120+ "{{ numbers|selectattr('number', '<', '3')|map('number') }}" ,
121+ new HashMap <String , Object >()
122+ )
123+ )
124+ .isEqualTo ("[1, 2]" );
125+ }
126+
127+ @ Test
128+ public void selectAttrWithSymbolicLeExp () {
129+ assertThat (
130+ jinjava .render (
131+ "{{ numbers|selectattr('number', '<=', '3')|map('number') }}" ,
132+ new HashMap <String , Object >()
133+ )
134+ )
135+ .isEqualTo ("[1, 2, 3]" );
136+ }
137+
138+ @ Test
139+ public void selectAttrWithSymbolicGtExp () {
140+ assertThat (
141+ jinjava .render (
142+ "{{ numbers|selectattr('number', '>', '3')|map('number') }}" ,
143+ new HashMap <String , Object >()
144+ )
145+ )
146+ .isEqualTo ("[4]" );
147+ }
148+
149+ @ Test
150+ public void selectAttrWithSymbolicGeExp () {
151+ assertThat (
152+ jinjava .render (
153+ "{{ numbers|selectattr('number', '>=', '3')|map('number') }}" ,
154+ new HashMap <String , Object >()
155+ )
156+ )
157+ .isEqualTo ("[3, 4]" );
158+ }
159+
104160 public static class User implements PyishSerializable {
105161 private long num ;
106162 private boolean isActive ;
0 commit comments