//-------------------------------------------------------------------------
        public virtual void test_cashFlowEquivalentAndSensitivity()
        {
            ResolvedSwap swap = ResolvedSwap.of(IBOR_LEG, FIXED_LEG);
            ImmutableMap <Payment, PointSensitivityBuilder> computedFull = CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap, PROVIDER);
            ImmutableList <Payment> keyComputedFull = computedFull.Keys.asList();
            ImmutableList <PointSensitivityBuilder>         valueComputedFull = computedFull.values().asList();
            ImmutableMap <Payment, PointSensitivityBuilder> computedIborLeg   = CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivityIborLeg(IBOR_LEG, PROVIDER);
            ImmutableMap <Payment, PointSensitivityBuilder> computedFixedLeg  = CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivityFixedLeg(FIXED_LEG, PROVIDER);

            assertEquals(computedFixedLeg.Keys.asList(), keyComputedFull.subList(0, 2));
            assertEquals(computedIborLeg.Keys.asList(), keyComputedFull.subList(2, 6));
            assertEquals(computedFixedLeg.values().asList(), valueComputedFull.subList(0, 2));
            assertEquals(computedIborLeg.values().asList(), valueComputedFull.subList(2, 6));

            double eps = 1.0e-7;
            RatesFiniteDifferenceSensitivityCalculator calc = new RatesFiniteDifferenceSensitivityCalculator(eps);
            int size = keyComputedFull.size();

            for (int i = 0; i < size; ++i)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int index = i;
                int index = i;
                CurrencyParameterSensitivities expected = calc.sensitivity(PROVIDER, p => ((NotionalExchange)CashFlowEquivalentCalculator.cashFlowEquivalentSwap(swap, p).PaymentEvents.get(index)).PaymentAmount);
                SwapPaymentEvent               @event   = CashFlowEquivalentCalculator.cashFlowEquivalentSwap(swap, PROVIDER).PaymentEvents.get(index);
                PointSensitivityBuilder        point    = computedFull.get(((NotionalExchange)@event).Payment);
                CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build());
                assertTrue(computed.equalWithTolerance(expected, eps * NOTIONAL));
            }
        }
        public virtual void test_cashFlowEquivalentAndSensitivity_wrongSwap()
        {
            ResolvedSwap swap1 = ResolvedSwap.of(IBOR_LEG, FIXED_LEG, IBOR_LEG);

            assertThrowsIllegalArg(() => CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap1, PROVIDER));
            ResolvedSwap swap2 = ResolvedSwap.of(FIXED_LEG, FIXED_LEG);

            assertThrowsIllegalArg(() => CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap2, PROVIDER));
            ResolvedSwap swap3 = ResolvedSwap.of(FIXED_LEG, CashFlowEquivalentCalculator.cashFlowEquivalentIborLeg(IBOR_LEG, PROVIDER));

            assertThrowsIllegalArg(() => CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap3, PROVIDER));
        }
        public virtual void test_cashFlowEquivalentAndSensitivity_compounding()
        {
            RatePaymentPeriod iborCmp    = RatePaymentPeriod.builder().paymentDate(PAYMENT2).accrualPeriods(IBOR1, IBOR2).dayCount(ACT_365F).currency(GBP).notional(-NOTIONAL).build();
            ResolvedSwapLeg   iborLegCmp = ResolvedSwapLeg.builder().type(IBOR).payReceive(PAY).paymentPeriods(iborCmp).build();
            ResolvedSwap      swap1      = ResolvedSwap.of(iborLegCmp, FIXED_LEG);

            assertThrowsIllegalArg(() => CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap1, PROVIDER));
            RatePaymentPeriod fixedCmp    = RatePaymentPeriod.builder().paymentDate(PAYMENT2).accrualPeriods(FIXED1, FIXED2).dayCount(ACT_365F).currency(GBP).notional(NOTIONAL).build();
            ResolvedSwapLeg   fixedLegCmp = ResolvedSwapLeg.builder().type(FIXED).payReceive(RECEIVE).paymentPeriods(fixedCmp).build();
            ResolvedSwap      swap2       = ResolvedSwap.of(IBOR_LEG, fixedLegCmp);

            assertThrowsIllegalArg(() => CashFlowEquivalentCalculator.cashFlowEquivalentAndSensitivitySwap(swap2, PROVIDER));
        }