156157158159160161162163164165166
} @Test public void testLambdaAsFunction01() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue("v = (x->y->x-y); v(2)(1)", Integer.class); Assert.assertEquals(Integer.valueOf(1), result); }
166167168169170171172173174175176
} @Test public void testLambdaAsFunction02() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue("v = (()->y->2-y); v()(1)", Integer.class); Assert.assertEquals(Integer.valueOf(1), result); }
176177178179180181182183184185186
} @Test public void testLambdaAsFunction03() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue("v = (()->y->()->2-y); v()(1)()", Integer.class); Assert.assertEquals(Integer.valueOf(1), result); }
186187188189190191192193194195
} @Test(expected=ELException.class) public void testLambdaAsFunction04() { ELProcessor processor = new ELProcessor(); // More method parameters than there are nested lambda expressions processor.getValue("v = (()->y->()->2-y); v()(1)()()", Integer.class); }
195196197198199200201202203204205
} @Test public void testLambdaAsFunction05() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue("v = (()->y->()->x->x-y); v()(1)()(2)", Integer.class); Assert.assertEquals(Integer.valueOf(1), result); }
205206207208209210211212213214215
} @Test public void testLambdaAsFunction06() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue("v = (()->y->()->()->x->x-y); v()(1)()()(2)", Integer.class); Assert.assertEquals(Integer.valueOf(1), result); }
215216217218219220221222223224225
} @Test public void testLambdaAsFunction07() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue("v = (()->y->()->()->x->x-y); v()(1)()(3)(2)", Integer.class); Assert.assertEquals(Integer.valueOf(1), result); }
293294295296297298299300301302303304305306
} @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);
309310311312313314315316317318319320321322
} @Test public void testToArray01() { ELProcessor processor = new ELProcessor(); processor.defineBean("beans", beans); Object result = processor.getValue( "beans.stream().toArray()", Object.class); Object[] expected = new Object[3]; expected[0] = bean01;
327328329330331332333334335336337338339
} @Test public void testReduceLambda01() { ELProcessor processor = new ELProcessor(); Object result = processor.getValue( "[1,2,3,4,5].stream().reduce((x,y)->x+y)", Object.class); Assert.assertEquals(Long.valueOf(15), ((Optional) result).get()); }