All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.houbb.value.extraction.test.bs.ExpressionTest Maven / Gradle / Ivy

The newest version!
package com.github.houbb.value.extraction.test.bs;

import com.github.houbb.value.extraction.core.bs.ValueExtractionBs;
import com.github.houbb.value.extraction.core.support.extraction.ValueExtractions;
import com.googlecode.aviator.AviatorEvaluator;
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class ExpressionTest {

    @Test
    public void test() {
        int[] a = {1, 2, 3, 4, 5};
        Map env = new HashMap<>(1);
        env.put("a", a);

        //求数组长度
        AviatorEvaluator.execute("count(a)", env);

        Map result = ValueExtractionBs.newInstance()
                .scripts(Arrays.asList("count(a)"))
                .valueExtraction(ValueExtractions.aviator())
                .dataMap(env)
                .extract();

        Assert.assertEquals(5L, result.get("count(a)"));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy