public virtual void test_ofFixedBeta_shift()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition test = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, 0.01, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());

            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.Index, USD_LIBOR_3M);
            assertEquals(test.Interpolator, LINEAR);
            assertEquals(test.ExtrapolatorLeft, FLAT);
            assertEquals(test.ExtrapolatorRight, FLAT);
            assertEquals(test.Name, NAME);
            assertEquals(test.BetaCurve.get(), ConstantCurve.of(Curves.sabrParameterByExpiry(NAME.Name + "-Beta", ACT_ACT_ISDA, SABR_BETA), 0.5));
            assertFalse(test.RhoCurve.Present);
            assertEquals(test.SabrVolatilityFormula, SabrVolatilityFormula.hagan());
            assertEquals(test.ShiftCurve, ConstantCurve.of("Shift curve", 0.01));
        }
        public virtual void test_builder()
        {
            Curve betaCurve = ConstantCurve.of(Curves.sabrParameterByExpiry(NAME.Name + "-Beta", ACT_ACT_ISDA, SABR_BETA), 0.65);
            SabrIborCapletFloorletVolatilityBootstrapDefinition test = SabrIborCapletFloorletVolatilityBootstrapDefinition.builder().index(USD_LIBOR_3M).name(NAME).interpolator(LINEAR).extrapolatorLeft(FLAT).extrapolatorRight(CurveExtrapolators.LINEAR).dayCount(ACT_ACT_ISDA).sabrVolatilityFormula(SabrVolatilityFormula.hagan()).betaCurve(betaCurve).build();

            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.Index, USD_LIBOR_3M);
            assertEquals(test.Interpolator, LINEAR);
            assertEquals(test.ExtrapolatorLeft, FLAT);
            assertEquals(test.ExtrapolatorRight, CurveExtrapolators.LINEAR);
            assertEquals(test.Name, NAME);
            assertEquals(test.BetaCurve.get(), betaCurve);
            assertFalse(test.RhoCurve.Present);
            assertEquals(test.SabrVolatilityFormula, SabrVolatilityFormula.hagan());
            assertEquals(test.ShiftCurve, ConstantCurve.of("Zero shift", 0d));
        }
        public virtual void test_serialization()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition test = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());

            assertSerialization(test);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition test1 = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());

            coverImmutableBean(test1);
            SabrIborCapletFloorletVolatilityBootstrapDefinition test2 = SabrIborCapletFloorletVolatilityBootstrapDefinition.builder().index(GBP_LIBOR_3M).name(IborCapletFloorletVolatilitiesName.of("other")).interpolator(STEP_UPPER).extrapolatorLeft(FLAT).extrapolatorRight(CurveExtrapolators.LINEAR).rhoCurve(ConstantCurve.of("rho", 0.1d)).shiftCurve(ConstantCurve.of("shift", 0.01d)).dayCount(ACT_365F).sabrVolatilityFormula(SabrVolatilityFormula.hagan()).build();

            coverBeanEquals(test1, test2);
        }
        public virtual void test_createMetadata_wrongValueType()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition @base = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());
            RawOptionData capData = RawOptionData.of(ImmutableList.of(Period.ofYears(1), Period.ofYears(5)), DoubleArray.of(0.005, 0.01, 0.015), ValueType.STRIKE, DoubleMatrix.copyOf(new double[][]
            {
                new double[] { 0.15, 0.12, 0.13 },
                new double[] { 0.1, 0.08, 0.09 }
            }), ValueType.PRICE);

            assertThrowsIllegalArg(() => @base.createMetadata(capData));
        }
 //-------------------------------------------------------------------------
 public virtual void test_of_wrongInterpolator()
 {
     assertThrowsIllegalArg(() => SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, DOUBLE_QUADRATIC, FLAT, FLAT, SabrVolatilityFormula.hagan()));
 }
        public virtual void test_createMetadata_black()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition @base = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());
            RawOptionData capData = RawOptionData.of(ImmutableList.of(Period.ofYears(1), Period.ofYears(5)), DoubleArray.of(0.005, 0.01, 0.015), ValueType.STRIKE, DoubleMatrix.copyOf(new double[][]
            {
                new double[] { 0.15, 0.12, 0.13 },
                new double[] { 0.1, 0.08, 0.09 }
            }), ValueType.BLACK_VOLATILITY);
            SurfaceMetadata expected = Surfaces.blackVolatilityByExpiryStrike(NAME.Name, ACT_ACT_ISDA);
            SurfaceMetadata computed = @base.createMetadata(capData);

            assertEquals(computed, expected);
        }
        public virtual void test_createSabrParameterMetadata()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition @base = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());
            ImmutableList <CurveMetadata> expected = ImmutableList.of(Curves.sabrParameterByExpiry(NAME.Name + "-Alpha", ACT_ACT_ISDA, SABR_ALPHA), Curves.sabrParameterByExpiry(NAME.Name + "-Beta", ACT_ACT_ISDA, SABR_BETA), Curves.sabrParameterByExpiry(NAME.Name + "-Rho", ACT_ACT_ISDA, SABR_RHO), Curves.sabrParameterByExpiry(NAME.Name + "-Nu", ACT_ACT_ISDA, SABR_NU));
            ImmutableList <CurveMetadata> computed = @base.createSabrParameterMetadata();

            assertEquals(computed, expected);
        }
        public virtual void test_createCap()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition @base = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, STEP_UPPER, FLAT, FLAT, SabrVolatilityFormula.hagan());
            LocalDate       startDate = LocalDate.of(2012, 4, 20);
            LocalDate       endDate   = LocalDate.of(2017, 4, 20);
            double          strike    = 0.01;
            IborCapFloorLeg expected  = IborCapFloorLeg.builder().calculation(IborRateCalculation.of(USD_LIBOR_3M)).capSchedule(ValueSchedule.of(strike)).currency(USD_LIBOR_3M.Currency).notional(ValueSchedule.ALWAYS_1).paymentDateOffset(DaysAdjustment.NONE).paymentSchedule(PeriodicSchedule.of(startDate, endDate, Frequency.of(USD_LIBOR_3M.Tenor.Period), BusinessDayAdjustment.of(BusinessDayConventions.MODIFIED_FOLLOWING, USD_LIBOR_3M.FixingCalendar), StubConvention.NONE, RollConventions.NONE)).payReceive(PayReceive.RECEIVE).build();
            IborCapFloorLeg computed  = @base.createCap(startDate, endDate, strike);

            assertEquals(computed, expected);
        }