Search in sources :

Example 1 with ELProcessor

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

the class TestCollectionOperations method testNoneMatch03.

@Test
public void testNoneMatch03() {
    ELProcessor processor = new ELProcessor();
    Optional result = (Optional) processor.getValue("[1,2,3,4,5].stream().noneMatch(x->x>10)", Object.class);
    Assert.assertEquals(Boolean.TRUE, result.get());
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 2 with ELProcessor

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

the class TestCollectionOperations method testAverage06.

@Test(expected = ELException.class)
public void testAverage06() {
    ELProcessor processor = new ELProcessor();
    processor.getValue("[].stream().average().orElseGet(10)", Object.class);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 3 with ELProcessor

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

the class TestCollectionOperations method testAnyMatch02.

@Test
public void testAnyMatch02() {
    ELProcessor processor = new ELProcessor();
    Optional result = (Optional) processor.getValue("[1,2,3,4,5].stream().anyMatch(x->x==3)", Object.class);
    Assert.assertEquals(Boolean.TRUE, result.get());
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 4 with ELProcessor

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

the class TestCollectionOperations method testAverage05.

@Test
public void testAverage05() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("[].stream().average().orElseGet(()->()->10)", Object.class);
    Assert.assertEquals(Long.valueOf(10), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 5 with ELProcessor

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

the class TestCollectionOperations method testToList01.

@Test
public void testToList01() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("['a','b','c'].stream().toList()", List.class);
    List<String> expected = new ArrayList<>(3);
    expected.add("a");
    expected.add("b");
    expected.add("c");
    Assert.assertEquals(expected, result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

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