### Question:
ExpressionConfigWrapper extends BaseThresholdDefConfigWrapper { @Override public double evaluate(Map<String, Double> values) throws ThresholdExpressionException { Map<String,Object> context = new HashMap<String,Object>(); context.putAll(values); context.put("datasources", new HashMap<String, Double>(values)); context.put("math", new MathBinding()); double result = Double.NaN; try { Object resultObject = new JexlEngine().createExpression(m_expression.getExpression()).evaluate(new MapContext(context)); result = Double.parseDouble(resultObject.toString()); } catch (Throwable e) { throw new ThresholdExpressionException("Error while evaluating expression " + m_expression.getExpression() + ": " + e.getMessage(), e); } return result; } ExpressionConfigWrapper(Expression expression); @Override String getDatasourceExpression(); @Override Collection<String> getRequiredDatasources(); @Override double evaluate(Map<String, Double> values);  }### Answer:
@Test public void testSlowInterface() throws Exception { Map<String, Double> values = new HashMap<String,Double>(); values.put("ifInOctets", 200000.0); values.put("ifSpeed", 10000000.0); double value = wrapper.evaluate(values); Assert.assertTrue(value == 16.0); }
@Test public void testFastInterface() throws Exception { Map<String, Double> values = new HashMap<String,Double>(); values.put("ifHCInOctets", 20000000.0); values.put("ifSpeed", 100000000.0); values.put("ifHighSpeed", 1000.0); double value = wrapper.evaluate(values); Assert.assertTrue(value == 16.0); }
@Test public void testDivisionByZeroA() throws Exception { Map<String, Double> values = new HashMap<String,Double>(); values.put("ifHCInOctets", 20000000.0); values.put("ifSpeed", 100000000.0); values.put("ifHighSpeed", 1000.0); double value = wrapper.evaluate(values); Assert.assertTrue(value == 16.0); }
@Test public void testDivisionByZeroB() throws Exception { Map<String, Double> values = new HashMap<String,Double>(); values.put("ifInOctets", 200000.0); values.put("ifSpeed", 0.0); values.put("ifHighSpeed", 0.0); double value = wrapper.evaluate(values); Assert.assertTrue(value == 0.0); }
@Test public void testDivisionByZeroC() throws Exception { Map<String, Double> values = new HashMap<String,Double>(); values.put("ifHCInOctets", 20000000.0); values.put("ifSpeed", 0.0); values.put("ifHighSpeed", 0.0); double value = wrapper.evaluate(values); Assert.assertTrue(value == 0.0); }
@Test public void testMath() throws Exception { Expression exp = new Expression(); exp.setExpression("math.max(data, 5)"); wrapper = new ExpressionConfigWrapper(exp); Map<String, Double> values = new HashMap<String,Double>(); values.put("data", 10.0); Assert.assertTrue(10.0 == wrapper.evaluate(values)); }