VolatilityAnnualizingFunction implements Function<Double, Double> { @Override public Double evaluate(final Double... x) { ArgumentChecker.notEmpty(x, "x"); ArgumentChecker.noNulls(x, "x"); return Math.sqrt(_periodsPerYear / x[0]); } VolatilityAnnualizingFunction(final double periodsPerYear); @Override Double evaluate(final Double... x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull1() { new VolatilityAnnualizingFunction(DAYS_PER_YEAR).evaluate((Double[]) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull2() { new VolatilityAnnualizingFunction(DAYS_PER_YEAR).evaluate((Double) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmpty() { new VolatilityAnnualizingFunction(DAYS_PER_YEAR).evaluate(new Double[0]); }
@Test public void test() { final VolatilityAnnualizingFunction f1 = new VolatilityAnnualizingFunction(DAYS_PER_YEAR); final VolatilityAnnualizingFunction f2 = new VolatilityAnnualizingFunction(WORKING_DAYS_PER_YEAR); final double eps = 1e-12; assertEquals(f1.evaluate(10.), 6, eps); assertEquals(f2.evaluate(10.), 5., eps); }