use of jakarta.el.ELProcessor in project tomcat by apache.
the class TestCollectionOperations method testAllMatch02.
@Test
public void testAllMatch02() {
ELProcessor processor = new ELProcessor();
Optional result = (Optional) processor.getValue("[1,2,3,4,5].stream().allMatch(x->x>0)", Object.class);
Assert.assertEquals(Boolean.TRUE, result.get());
}
use of jakarta.el.ELProcessor in project tomcat by apache.
the class TestCollectionOperations method testDistinct01.
@Test
public void testDistinct01() {
ELProcessor processor = new ELProcessor();
Object result = processor.getValue("['a', 'b', 'b', 'c'].stream().distinct().toList()", List.class);
List<String> expected = new ArrayList<>(3);
expected.add("a");
expected.add("b");
expected.add("c");
Assert.assertEquals(expected, result);
}
use of jakarta.el.ELProcessor in project tomcat by apache.
the class TestCollectionOperations method testReduceLambda02.
@Test(expected = ELException.class)
public void testReduceLambda02() {
ELProcessor processor = new ELProcessor();
Object result = processor.getValue("[].stream().reduce((x,y)->x+y)", Object.class);
((Optional) result).get();
}
use of jakarta.el.ELProcessor in project tomcat by apache.
the class TestCollectionOperations method testMin04.
@Test(expected = ELException.class)
public void testMin04() {
ELProcessor processor = new ELProcessor();
processor.defineBean("beans", beans);
processor.getValue("beans.stream().min()", Object.class);
}
use of jakarta.el.ELProcessor in project tomcat by apache.
the class TestCollectionOperations method testAverage02.
@Test
public void testAverage02() {
ELProcessor processor = new ELProcessor();
Object result = processor.getValue("[1,2,3,4,5,6].stream().average()", Object.class);
Number average = (Number) ((Optional) result).get();
Assert.assertTrue("Result: " + average.toString(), ELSupport.equals(null, Double.valueOf(3.5), average));
}
Aggregations