Search in sources :

Example 1 with Dict

use of cn.hutool.core.lang.Dict in project hutool by looly.

the class DictTest method dictTest.

@Test
public void dictTest() {
    Dict dict = Dict.create().set("key1", // int
    1).set("key2", // long
    1000L).set("key3", // Date
    DateTime.now());
    Long v2 = dict.getLong("key2");
    Assert.assertEquals(Long.valueOf(1000L), v2);
}
Also used : Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Example 2 with Dict

use of cn.hutool.core.lang.Dict in project hutool by looly.

the class ExpressionUtilTest method jexlTest.

@Test
public void jexlTest() {
    ExpressionEngine engine = new JexlEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : JexlEngine(cn.hutool.extra.expression.engine.jexl.JexlEngine) Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Example 3 with Dict

use of cn.hutool.core.lang.Dict in project hutool by looly.

the class ExpressionUtilTest method rhinoTest.

@Test
public void rhinoTest() {
    ExpressionEngine engine = new RhinoEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : Dict(cn.hutool.core.lang.Dict) RhinoEngine(cn.hutool.extra.expression.engine.rhino.RhinoEngine) Test(org.junit.Test)

Example 4 with Dict

use of cn.hutool.core.lang.Dict in project hutool by looly.

the class ExpressionUtilTest method mvelTest.

@Test
public void mvelTest() {
    ExpressionEngine engine = new MvelEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : MvelEngine(cn.hutool.extra.expression.engine.mvel.MvelEngine) Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Example 5 with Dict

use of cn.hutool.core.lang.Dict in project hutool by looly.

the class ExpressionUtilTest method spELTest.

@Test
public void spELTest() {
    ExpressionEngine engine = new SpELEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("#a-(#b-#c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : SpELEngine(cn.hutool.extra.expression.engine.spel.SpELEngine) Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Aggregations

Dict (cn.hutool.core.lang.Dict)32 Test (org.junit.Test)24 File (java.io.File)4 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 ArrayList (java.util.ArrayList)3 BaseTest (cn.e3mall.common.freemarker.BaseTest)2 JexlEngine (cn.hutool.extra.expression.engine.jexl.JexlEngine)2 JfireELEngine (cn.hutool.extra.expression.engine.jfireel.JfireELEngine)2 MvelEngine (cn.hutool.extra.expression.engine.mvel.MvelEngine)2 RhinoEngine (cn.hutool.extra.expression.engine.rhino.RhinoEngine)2 SpELEngine (cn.hutool.extra.expression.engine.spel.SpELEngine)2 Configuration (freemarker.template.Configuration)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringWriter (java.io.StringWriter)2 Date (java.util.Date)2 List (java.util.List)2 Map (java.util.Map)2 Props (org.febit.wit.util.Props)2 Item (cn.e3mall.common.base.entity.Item)1