SpreadCurveShiftFunction implements CurveShiftFunction<SpreadDoublesCurve> { @Override public SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double shift) { ArgumentChecker.notNull(curve, "curve"); return evaluate(curve, shift, "PARALLEL_SHIFT_" + curve.getName()); }  @Override SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double shift); @Override SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double shift, final String newName); @Override SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double x, final double shift); @Override SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double x, final double shift, final String newName); @Override SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double[] x, final double[] y); @Override SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double[] x, final double[] y, final String newName);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurve1() { F.evaluate(null, 1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurve2() { F.evaluate(null, 1, "B"); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test1() { F.evaluate(SPREAD, 2, 1); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test2() { F.evaluate(SPREAD, 2, 1, "A"); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test3() { F.evaluate(SPREAD, new double[] {2}, new double[] {1}); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void test4() { F.evaluate(SPREAD, new double[] {2}, new double[] {1}, "A"); }
@Test public void testParallel() { SpreadDoublesCurve shifted = F.evaluate(SPREAD, SHIFT); Curve<Double, Double>[] c = shifted.getUnderlyingCurves(); assertEquals(c[0], CURVE1); assertEquals(c[1], CURVE2); assertEquals(c[2].getClass(), ConstantDoublesCurve.class); assertArrayEquals(c[2].getYData(), new Double[] {SHIFT}); for (int i = 0; i < N; i++) { assertEquals(SPREAD.getYValue(X[i]) + SHIFT, shifted.getYValue(X[i]), EPS); } assertEquals(shifted.getName(), "PARALLEL_SHIFT_" + SPREAD.getName()); final String newName = "B"; shifted = F.evaluate(SPREAD, SHIFT, newName); c = shifted.getUnderlyingCurves(); assertEquals(c[0], CURVE1); assertEquals(c[1], CURVE2); assertEquals(c[2].getClass(), ConstantDoublesCurve.class); assertArrayEquals(c[2].getYData(), new Double[] {SHIFT}); for (int i = 0; i < N; i++) { assertEquals(SPREAD.getYValue(X[i]) + SHIFT, shifted.getYValue(X[i]), EPS); } assertEquals(shifted.getName(), newName); }