public virtual void test_ofBusinessDays2_adjust()
        {
            DaysAdjustment test  = DaysAdjustment.ofBusinessDays(2, SAT_SUN);
            LocalDate      @base = date(2014, 8, 15);                              // Fri

            assertEquals(test.adjust(@base, REF_DATA), date(2014, 8, 19));         // Tue
            assertEquals(test.resolve(REF_DATA).adjust(@base), date(2014, 8, 19)); // Tue
        }
        public virtual void test_ofBusinessDays3_fourDays()
        {
            DaysAdjustment test = DaysAdjustment.ofBusinessDays(4, SAT_SUN, BDA_FOLLOW_WED_THU);

            assertEquals(test.Days, 4);
            assertEquals(test.Calendar, SAT_SUN);
            assertEquals(test.Adjustment, BDA_FOLLOW_WED_THU);
            assertEquals(test.ToString(), "4 business days using calendar Sat/Sun then apply Following using " + "calendar WedThu");
        }
        public virtual void test_ofBusinessDays2_threeDays()
        {
            DaysAdjustment test = DaysAdjustment.ofBusinessDays(3, SAT_SUN);

            assertEquals(test.Days, 3);
            assertEquals(test.Calendar, SAT_SUN);
            assertEquals(test.Adjustment, BDA_NONE);
            assertEquals(test.ToString(), "3 business days using calendar Sat/Sun");
        }
        //-------------------------------------------------------------------------
        public virtual void test_ofBusinessDays2_oneDay()
        {
            DaysAdjustment test = DaysAdjustment.ofBusinessDays(1, SAT_SUN);

            assertEquals(test.Days, 1);
            assertEquals(test.Calendar, SAT_SUN);
            assertEquals(test.Adjustment, BDA_NONE);
            assertEquals(test.ToString(), "1 business day using calendar Sat/Sun");
        }
        public virtual void test_ofBusinessDays3_adjust()
        {
            ImmutableHolidayCalendar cal     = ImmutableHolidayCalendar.of(WED_THU, ImmutableList.of(), WEDNESDAY, THURSDAY);
            ReferenceData            refData = ImmutableReferenceData.of(ImmutableMap.of(WED_THU, cal)).combinedWith(REF_DATA);
            DaysAdjustment           test    = DaysAdjustment.ofBusinessDays(3, SAT_SUN, BDA_FOLLOW_WED_THU);
            LocalDate @base = date(2014, 8, 15);                                  // Fri

            assertEquals(test.adjust(@base, refData), date(2014, 8, 22));         // Fri (3 days gives Wed, following moves to Fri)
            assertEquals(test.resolve(refData).adjust(@base), date(2014, 8, 22)); // Fri (3 days gives Wed, following moves to Fri)
        }
        //-------------------------------------------------------------------------
        public virtual void Equals()
        {
            DaysAdjustment a = DaysAdjustment.ofBusinessDays(3, NO_HOLIDAYS, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment b = DaysAdjustment.ofBusinessDays(4, NO_HOLIDAYS, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment c = DaysAdjustment.ofBusinessDays(3, WED_THU, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment d = DaysAdjustment.ofBusinessDays(3, NO_HOLIDAYS, BDA_FOLLOW_WED_THU);

            assertEquals(a.Equals(b), false);
            assertEquals(a.Equals(c), false);
            assertEquals(a.Equals(d), false);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Normalizes the adjustment.
 /// <para>
 /// If the number of days is zero, the calendar is set no 'NoHolidays'.
 /// If the number of days is non-zero and the calendar equals the adjustment calendar,
 /// the adjustment is removed.
 ///
 /// </para>
 /// </summary>
 /// <returns> the normalized adjustment </returns>
 public DaysAdjustment normalized()
 {
     if (days == 0)
     {
         if (calendar != HolidayCalendarIds.NO_HOLIDAYS)
         {
             return(DaysAdjustment.ofCalendarDays(days, adjustment));
         }
         return(this);
     }
     if (calendar.Equals(adjustment.Calendar))
     {
         return(DaysAdjustment.ofBusinessDays(days, calendar));
     }
     return(this);
 }
        //-------------------------------------------------------------------------
        public virtual void test_normalized()
        {
            DaysAdjustment zeroDays             = DaysAdjustment.ofCalendarDays(0, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment zeroDaysWithCalendar = DaysAdjustment.ofBusinessDays(0, WED_THU, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment twoDays                 = DaysAdjustment.ofCalendarDays(2, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment twoDaysWithCalendar     = DaysAdjustment.ofBusinessDays(2, WED_THU, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment twoDaysWithSameCalendar = DaysAdjustment.ofBusinessDays(2, SAT_SUN, BDA_FOLLOW_SAT_SUN);
            DaysAdjustment twoDaysWithNoAdjust     = DaysAdjustment.ofBusinessDays(2, SAT_SUN);

            assertEquals(zeroDays.normalized(), zeroDays);
            assertEquals(zeroDaysWithCalendar.normalized(), zeroDays);
            assertEquals(twoDays.normalized(), twoDays);
            assertEquals(twoDaysWithCalendar.normalized(), twoDaysWithCalendar);
            assertEquals(twoDaysWithSameCalendar.normalized(), twoDaysWithNoAdjust);
            assertEquals(twoDaysWithNoAdjust.normalized(), twoDaysWithNoAdjust);
        }
        public virtual void test_getResultCalendar2()
        {
            DaysAdjustment test = DaysAdjustment.ofBusinessDays(3, SAT_SUN, BDA_FOLLOW_WED_THU);

            assertEquals(test.ResultCalendar, WED_THU);
        }
        //-------------------------------------------------------------------------
        public virtual void test_getResultCalendar1()
        {
            DaysAdjustment test = DaysAdjustment.ofBusinessDays(3, SAT_SUN);

            assertEquals(test.ResultCalendar, SAT_SUN);
        }
 public virtual void test_ofBusinessDays3_null()
 {
     assertThrowsIllegalArg(() => DaysAdjustment.ofBusinessDays(3, null, BDA_FOLLOW_SAT_SUN));
     assertThrowsIllegalArg(() => DaysAdjustment.ofBusinessDays(3, SAT_SUN, null));
     assertThrowsIllegalArg(() => DaysAdjustment.ofBusinessDays(3, null, null));
 }
 public virtual void test_ofBusinessDays2_null()
 {
     assertThrowsIllegalArg(() => DaysAdjustment.ofBusinessDays(2, null));
 }