Search in sources :

Example 1 with TesterBeanA

use of org.apache.el.TesterBeanA in project tomcat by apache.

the class TestCollectionOperations method testLimit01.

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

Example 2 with TesterBeanA

use of org.apache.el.TesterBeanA 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(javax.el.ELProcessor) ArrayList(java.util.ArrayList) TesterBeanA(org.apache.el.TesterBeanA) Test(org.junit.Test)

Example 3 with TesterBeanA

use of org.apache.el.TesterBeanA in project tomcat by apache.

the class TestCollectionOperations method testFilter01.

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

Example 4 with TesterBeanA

use of org.apache.el.TesterBeanA in project tomcat by apache.

the class TestCollectionOperations method testSubstreamStart01.

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

Example 5 with TesterBeanA

use of org.apache.el.TesterBeanA in project tomcat by apache.

the class TestCollectionOperations method testPeek01.

@Test
public void testPeek01() {
    ELProcessor processor = new ELProcessor();
    List<TesterBeanA> debug = new ArrayList<>();
    processor.defineBean("beans", beans);
    processor.defineBean("debug", debug);
    Object result = processor.getValue("beans.stream().peek(b->debug.add(b)).toList()", Object.class);
    List<TesterBeanA> expected = new ArrayList<>(3);
    expected.add(bean01);
    expected.add(bean02);
    expected.add(bean03);
    Assert.assertEquals(expected, result);
    Assert.assertEquals(expected, debug);
}
Also used : ELProcessor(javax.el.ELProcessor) ArrayList(java.util.ArrayList) TesterBeanA(org.apache.el.TesterBeanA) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)5 ELProcessor (javax.el.ELProcessor)5 TesterBeanA (org.apache.el.TesterBeanA)5 Test (org.junit.Test)5