### Question:
JavaExpressionCalibratorFactory { public static CalibratorProc compile(JavaExpressionCalibrator c) { String className = "Expression"+c.hashCode(); StringBuilder sb = new StringBuilder(); sb.append("package org.yamcs.xtceproc.jecf;\n") .append("public class ").append(className).append(" implements org.yamcs.xtceproc.CalibratorProc {\n") .append(" public double calibrate(double v) {\n") .append("return ").append(c.getFormula()).append(";\n") .append(" }\n") .append("}\n"); try { SimpleCompiler compiler = new SimpleCompiler(); compiler.cook(sb.toString()); Class<?> cexprClass = compiler.getClassLoader().loadClass("org.yamcs.xtceproc.jecf."+className); return (CalibratorProc) cexprClass.newInstance(); } catch (LocatedException e) { String msg = e.getMessage(); Location l = e.getLocation(); if(l!=null) { Location l1 = new Location(null, (short)(l.getLineNumber()-3), (short)(l.getColumnNumber()-7)); msg = l1.toString()+": "+msg.substring(l.toString().length()+1); } throw new IllegalArgumentException("Cannot compile expression '"+c.getFormula()+"': "+msg, e); } catch (Exception e) { throw new IllegalArgumentException("Cannot compile expression '"+c.getFormula()+"'", e); } }  static CalibratorProc compile(JavaExpressionCalibrator c);  }### Answer:
@Test public void test1() { JavaExpressionCalibrator jec = new JavaExpressionCalibrator("v+3"); CalibratorProc c = JavaExpressionCalibratorFactory.compile(jec); assertEquals(7, c.calibrate(4), 1e-5); }
@Test(expected=IllegalArgumentException.class) public void test2() { JavaExpressionCalibrator jec = new JavaExpressionCalibrator("\"blabala\""); CalibratorProc c = JavaExpressionCalibratorFactory.compile(jec); assertEquals(7, c.calibrate(4), 1e-5); }
@Test public void test3() { JavaExpressionCalibrator jec = new JavaExpressionCalibrator("v>0?v+5:v-5"); CalibratorProc c = JavaExpressionCalibratorFactory.compile(jec); assertEquals(9, c.calibrate(4), 1e-5); assertEquals(-7, c.calibrate(-2), 1e-5); }