Search in sources :

Example 21 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestCollectionOperations method testCount02.

@Test
public void testCount02() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("[].stream().count()", Object.class);
    Assert.assertTrue("Result: " + result.toString(), ELSupport.equals(null, Long.valueOf(0), result));
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 22 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestCollectionOperations method testFindFirst02.

@Test(expected = ELException.class)
public void testFindFirst02() {
    ELProcessor processor = new ELProcessor();
    Optional result = (Optional) processor.getValue("[].stream().findFirst()", Object.class);
    result.get();
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 23 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestCollectionOperations method testMin03.

@Test(expected = ELException.class)
public void testMin03() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("[].stream().min()", Object.class);
    ((Optional) result).get();
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 24 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestCollectionOperations method testSubstreamStartEnd01.

@Test
public void testSubstreamStartEnd01() {
    ELProcessor processor = new ELProcessor();
    processor.defineBean("beans", beans);
    Object result = processor.getValue("beans.stream().substream(1,2).toList()", Object.class);
    List<TesterBeanA> expected = new ArrayList<>(2);
    expected.add(bean02);
    Assert.assertEquals(expected, result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) ArrayList(java.util.ArrayList) TesterBeanA(org.apache.el.TesterBeanA) Test(org.junit.Test)

Example 25 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestCollectionOperations method testMinLambda01.

@Test
public void testMinLambda01() {
    ELProcessor processor = new ELProcessor();
    processor.defineBean("beans", beans);
    Object result = processor.getValue("beans.stream().min((x,y)->x.name.compareTo(y.name))", Object.class);
    Assert.assertEquals(bean01, ((Optional) result).get());
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Aggregations

ELProcessor (jakarta.el.ELProcessor)138 Test (org.junit.Test)133 ArrayList (java.util.ArrayList)13 ELContext (jakarta.el.ELContext)8 ValueExpression (jakarta.el.ValueExpression)8 ExpressionFactory (jakarta.el.ExpressionFactory)7 TesterBeanA (org.apache.el.TesterBeanA)5 List (java.util.List)1