### Question:
RuleEngine { public ItemCollection evaluateBusinessRule(String script, ItemCollection documentContext, ItemCollection event) throws PluginException { boolean debug = logger.isLoggable(Level.FINE); if ("".equals(script.trim())) return null; scriptEngine.put("event", convertItemCollection(event)); scriptEngine.put("workitem", convertItemCollection(documentContext)); if (debug) { logger.finest("......SCRIPT:" + script); } try { scriptEngine.eval(script); } catch (ScriptException e) { logger.warning("Script Error in: " + script); throw new PluginException(RuleEngine.class.getSimpleName(), INVALID_SCRIPT, "BusinessRule contains invalid script:" + e.getMessage(), e); } ItemCollection result = convertScriptVariableToItemCollection("result"); return result; } RuleEngine();  RuleEngine(final String scriptLanguage); ScriptEngineManager getScriptEngineManager(); ScriptEngine getScriptEngine(); ItemCollection evaluateBusinessRule(String script, ItemCollection documentContext, ItemCollection event); ItemCollection evaluateJsonByScript(String json, String script); boolean evaluateBooleanExpression(String script, ItemCollection documentContext); Object[] evaluateNativeScriptArray(String expression); @SuppressWarnings({ "unchecked", "rawtypes" }) ItemCollection convertScriptVariableToItemCollection(String variable); static final String DEFAULT_SCRIPT_LANGUAGE; static final String INVALID_SCRIPT; }### Answer:
@Test public void testBasicScript() throws ScriptException, PluginException { ItemCollection workitem = new ItemCollection(); workitem.replaceItemValue("txtName", "Anna"); ItemCollection event = new ItemCollection(); String script = "var result={}; if (workitem.txtname && workitem.txtname[0]==='Anna') result.numage=50;"; workitem = ruleEngine.evaluateBusinessRule(script, workitem, event); Assert.assertNotNull(workitem); Assert.assertEquals(50, workitem.getItemValueInteger("numage")); }