// Path: src/main/java/com/plexobject/rbac/eval/PredicateEvaluator.java
// public interface PredicateEvaluator {
//     public boolean evaluate(String expression, Map<String, Object> args);
// }
// 
// Path: src/main/java/com/plexobject/rbac/utils/IDUtils.java
// public class IDUtils {
//     @SuppressWarnings("unchecked")
//     public static String getIdsAsString(
//             Collection<? extends Identifiable> objects) {
//         StringBuilder sb = new StringBuilder("[");
//         for (Identifiable o : objects) {
//             if (sb.length() > 1) {
//                 sb.append(",");
//             }
//             sb.append("\"" + o.getId() + "\"");
//         }
//         sb.append("]");
//         return sb.toString();
//     }
// 
//     public static Collection<Integer> getIdsAsIntegers(
//             Collection<? extends Identifiable<Integer>> objects) {
//         Collection<Integer> ids = new ArrayList<Integer>();
//         for (Identifiable<Integer> o : objects) {
//             ids.add(o.getId());
//         }
//         return ids;
//     }
// 
//     public static Collection<String> getIdsAsString(
//             Collection<? extends Identifiable<String>> objects) {
//         Collection<String> ids = new ArrayList<String>();
//         for (Identifiable<String> o : objects) {
//             ids.add(o.getId());
//         }
//         return ids;
//     }
// 
//     public static Map<String, Object> toMap(final Object... keyValues) {
//         Map<String, Object> map = new HashMap<String, Object>();
//         for (int i = 0; i < keyValues.length - 1; i += 2) {
//             map.put(keyValues[i].toString(), keyValues[i + 1]);
//         }
//         return map;
//     }
// }


import org.junit.Assert;
import org.junit.Test;
import com.plexobject.rbac.eval.PredicateEvaluator;
import com.plexobject.rbac.utils.IDUtils;
package com.plexobject.rbac.eval.js;



public class JavascriptEvaluatorTest {
    PredicateEvaluator evaluator = new JavascriptEvaluator();

    @Test
    public void testGetSetContext() {
        String expr = "var time=new Date(2010, 0, 1, 12, 0, 0, 0);\namount <= 500 && dept == 'SALES' && time.getHours() >= 8 && time.getHours() <= 17";

// Path: src/main/java/com/plexobject/rbac/eval/PredicateEvaluator.java
// public interface PredicateEvaluator {
//     public boolean evaluate(String expression, Map<String, Object> args);
// }
// 
// Path: src/main/java/com/plexobject/rbac/utils/IDUtils.java
// public class IDUtils {
//     @SuppressWarnings("unchecked")
//     public static String getIdsAsString(
//             Collection<? extends Identifiable> objects) {
//         StringBuilder sb = new StringBuilder("[");
//         for (Identifiable o : objects) {
//             if (sb.length() > 1) {
//                 sb.append(",");
//             }
//             sb.append("\"" + o.getId() + "\"");
//         }
//         sb.append("]");
//         return sb.toString();
//     }
// 
//     public static Collection<Integer> getIdsAsIntegers(
//             Collection<? extends Identifiable<Integer>> objects) {
//         Collection<Integer> ids = new ArrayList<Integer>();
//         for (Identifiable<Integer> o : objects) {
//             ids.add(o.getId());
//         }
//         return ids;
//     }
// 
//     public static Collection<String> getIdsAsString(
//             Collection<? extends Identifiable<String>> objects) {
//         Collection<String> ids = new ArrayList<String>();
//         for (Identifiable<String> o : objects) {
//             ids.add(o.getId());
//         }
//         return ids;
//     }
// 
//     public static Map<String, Object> toMap(final Object... keyValues) {
//         Map<String, Object> map = new HashMap<String, Object>();
//         for (int i = 0; i < keyValues.length - 1; i += 2) {
//             map.put(keyValues[i].toString(), keyValues[i + 1]);
//         }
//         return map;
//     }
// }


// Path: src/test/java/com/plexobject/rbac/eval/js/JavascriptEvaluatorTest.java
import org.junit.Assert;
import org.junit.Test;
import com.plexobject.rbac.eval.PredicateEvaluator;
import com.plexobject.rbac.utils.IDUtils;

package com.plexobject.rbac.eval.js;



public class JavascriptEvaluatorTest {
    PredicateEvaluator evaluator = new JavascriptEvaluator();

    @Test
    public void testGetSetContext() {
        String expr = "var time=new Date(2010, 0, 1, 12, 0, 0, 0);\namount <= 500 && dept == 'SALES' && time.getHours() >= 8 && time.getHours() <= 17";

        Assert.assertTrue(evaluator.evaluate(expr, IDUtils.toMap("amount",