2 * Copyright © 2013 Sebastian Hoß <mail@shoss.de>
3 * This work is free. You can redistribute it and/or modify it under the
4 * terms of the Do What The Fuck You Want To Public License, Version 2,
5 * as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
8 * This program is free software. It comes without any warranty, to
9 * the extent permitted by applicable law. You can redistribute it
10 * and/or modify it under the terms of the Do What The Fuck You Want
11 * To Public License, Version 2, as published by Sam Hocevar. See
12 * http://www.wtfpl.net/ for more details.
14 package com
.github
.sebhoss
.time
;
16 import java
.time
.LocalDate
;
17 import java
.time
.Month
;
19 import com
.github
.sebhoss
.warnings
.CompilerWarnings
;
21 import org
.junit
.Assert
;
22 import org
.junit
.experimental
.theories
.DataPoints
;
23 import org
.junit
.experimental
.theories
.Theories
;
24 import org
.junit
.experimental
.theories
.Theory
;
25 import org
.junit
.runner
.RunWith
;
28 * Test cases for {@link FiscalDate#getCalendarDayOfMonth()}.
30 @RunWith(Theories
.class)
31 @SuppressWarnings(CompilerWarnings
.STATIC_METHOD
)
32 public class FiscalDateGetCalendarDayOfMonthTest
{
34 /** @see TestObjects#supportedMonths() */
36 public static final Month
[] START_DATES
= TestObjects
.supportedMonths();
38 /** @see TestObjects#startDates() */
40 public static final LocalDate
[] MONTH_START_DATES
= TestObjects
.startDates();
42 /** @see TestObjects#middleDates() */
44 public static final LocalDate
[] MONTH_MIDDLE_DATES
= TestObjects
.middleDates();
47 * Ensures that for any given date the correct calendar day of month will be returned in an early fiscal year.
50 * The start date of the fiscal year.
52 * The current date in a calendar year.
55 public void shouldReturnCalendarDayOfMonthInEarlyFiscalYear(final Month startDate
, final LocalDate currentDate
) {
57 final FiscalDate fiscalDate
= FiscalYears
.earlyFiscalYear(startDate
).createFromCalendarDate(currentDate
);
60 final long calendarDayOfMonth
= fiscalDate
.getCalendarDayOfMonth();
63 Assert
.assertEquals(currentDate
.getDayOfMonth(), calendarDayOfMonth
);
67 * Ensures that for any given date the correct calendar day of month will be returned in a late fiscal year.
70 * The start date of the fiscal year.
72 * The current date in a calendar year.
75 public void shouldReturnCalendarDayOfMonthInLateFiscalYear(final Month startDate
, final LocalDate currentDate
) {
77 final FiscalDate fiscalDate
= FiscalYears
.lateFiscalYear(startDate
).createFromCalendarDate(currentDate
);
80 final long calendarDayOfMonth
= fiscalDate
.getCalendarDayOfMonth();
83 Assert
.assertEquals(currentDate
.getDayOfMonth(), calendarDayOfMonth
);