@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); }
@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 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 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); }
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); }
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);  }