Exemplo n.º 1
0
        public virtual void test_of()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.Currency, USD);
            assertEquals(test.UnadjustedStartDate, START);
            assertEquals(test.StartDate, START_ADJUSTED);
            assertEquals(test.UnadjustedEndDate, END);
            assertEquals(test.EndDate, END_ADJUSTED);
            assertEquals(test.PaymentDate, END_ADJUSTED);
            assertEquals(test.DetachmentDate, DETACHMENT_DATE);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.YearFraction, YEAR_FRACTION);
            assertEquals(test.hasExCouponPeriod(), true);

            // the object is not changed
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), test);
            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(test.Currency, USD);
            assertEquals(test.UnadjustedStartDate, START);
            assertEquals(test.StartDate, START_ADJUSTED);
            assertEquals(test.UnadjustedEndDate, END);
            assertEquals(test.EndDate, END_ADJUSTED);
            assertEquals(test.PaymentDate, END_ADJUSTED);
            assertEquals(test.DetachmentDate, DETACHMENT_DATE);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.YearFraction, YEAR_FRACTION);
            assertEquals(test.hasExCouponPeriod(), true);
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FixedCouponBondPaymentPeriod test1 = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            coverImmutableBean(test1);
            FixedCouponBondPaymentPeriod test2 = FixedCouponBondPaymentPeriod.builder().currency(GBP).startDate(LocalDate.of(2014, 3, 4)).unadjustedStartDate(LocalDate.of(2014, 3, 2)).endDate(LocalDate.of(2015, 3, 4)).unadjustedEndDate(LocalDate.of(2015, 3, 3)).notional(1.0e8).fixedRate(0.005).yearFraction(1d).build();

            coverBeanEquals(test1, test2);
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void test_contains()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.contains(START.minusDays(1)), false);
            assertEquals(test.contains(START), true);
            assertEquals(test.contains(START.plusDays(1)), true);
            assertEquals(test.contains(END.minusDays(1)), true);
            assertEquals(test.contains(END), false);
        }
Exemplo n.º 4
0
 public virtual void test_of_wrongDates()
 {
     assertThrowsIllegalArg(() => FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(LocalDate.of(2015, 2, 3)).unadjustedEndDate(LocalDate.of(2015, 2, 2)).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build());
     assertThrowsIllegalArg(() => FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(LocalDate.of(2015, 8, 3)).unadjustedStartDate(LocalDate.of(2015, 8, 2)).endDate(LocalDate.of(2015, 8, 3)).unadjustedEndDate(LocalDate.of(2015, 8, 3)).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build());
     assertThrowsIllegalArg(() => FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(LocalDate.of(2015, 8, 6)).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build());
 }
Exemplo n.º 5
0
        public virtual void test_of_noExCoupon()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(END_ADJUSTED).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.hasExCouponPeriod(), false);
        }
Exemplo n.º 6
0
        public virtual void test_serialization()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertSerialization(test);
        }