GeneratorPriceIndexCurveInterpolatedAnchor extends GeneratorPriceIndexCurve { @Override public GeneratorPriceIndexCurve finalGenerator(final Object data) { ArgumentChecker.isTrue(data instanceof InstrumentDerivative[], "data should be an array of InstrumentDerivative"); final InstrumentDerivative[] instruments = (InstrumentDerivative[]) data; final double[] node = new double[instruments.length]; for (int loopins = 0; loopins < instruments.length; loopins++) { node[loopins] = instruments[loopins].accept(_nodeTimeCalculator); } return new GeneratorPriceIndexCurveInterpolatedAnchorNode(node, _interpolator, _anchorNode, _anchorValue); } GeneratorPriceIndexCurveInterpolatedAnchor(
      final InstrumentDerivativeVisitorAdapter<Object, Double> nodeTimeCalculator, final Interpolator1D interpolator,
      final double anchorNode, final double anchorValue); double getAnchorNode(); double getAnchorValue(); @Override int getNumberOfParameter(); @Override PriceIndexCurve generateCurve(final String name, final double[] parameters); @Override PriceIndexCurve generateCurve(final String name, final InflationProviderInterface multicurve, final double[] parameters); @Override GeneratorPriceIndexCurve finalGenerator(final Object data);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void wrongData() { GENERATOR.finalGenerator(new double[2]); }
@Test public void finalGenerator() { GeneratorPriceIndexCurve finalGen = GENERATOR.finalGenerator(new InstrumentDerivative[] {FRA_1, FRA_2}); assertTrue("GeneratorPriceIndexCurveInterpolatedAnchor: final generator", finalGen instanceof GeneratorPriceIndexCurveInterpolatedAnchorNode); GeneratorPriceIndexCurveInterpolatedAnchorNode genNode = (GeneratorPriceIndexCurveInterpolatedAnchorNode) finalGen; assertTrue("GeneratorPriceIndexCurveInterpolatedAnchor: final generator", genNode.getNumberOfParameter() == 2); assertEquals("GeneratorPriceIndexCurveInterpolatedAnchor: final generator", ANCHOR_NODE, genNode.getAnchorNode()); assertEquals("GeneratorPriceIndexCurveInterpolatedAnchor: final generator", ANCHOR_VALUE, genNode.getAnchorValue()); double[] nodePointsExpected = new double[2]; nodePointsExpected[0] = FRA_1.accept(LAST_FIXING_END_CALCULATOR); nodePointsExpected[1] = FRA_2.accept(LAST_FIXING_END_CALCULATOR); ArrayAsserts.assertArrayEquals(nodePointsExpected, genNode.getNodePoints(), TOLERANCE_NODE); }