2 * This program is free software. It comes without any warranty, to
3 * the extent permitted by applicable law. You can redistribute it
4 * and/or modify it under the terms of the Do What The Fuck You Want
5 * To Public License, Version 2, as published by Sam Hocevar. See
6 * http://www.wtfpl.net/ for more details.
8 package com
.github
.sebhoss
.time
;
10 import org
.joda
.time
.LocalDate
;
11 import org
.joda
.time
.Months
;
12 import org
.junit
.Assert
;
13 import org
.junit
.experimental
.theories
.DataPoints
;
14 import org
.junit
.experimental
.theories
.Theories
;
15 import org
.junit
.experimental
.theories
.Theory
;
16 import org
.junit
.runner
.RunWith
;
18 import com
.github
.sebhoss
.common
.annotation
.CompilerWarnings
;
21 * Test cases for {@link FiscalDate#getCalendarYear()}.
23 @RunWith(Theories
.class)
24 @SuppressWarnings(CompilerWarnings
.STATIC_METHOD
)
25 public class FiscalDateGetCalendarYearTest
{
27 /** @see TestObjects#supportedMonths() */
29 public static Months
[] START_DATES
= TestObjects
.supportedMonths();
31 /** @see TestObjects#startDates() */
33 public static LocalDate
[] MONTH_START_DATES
= TestObjects
.startDates();
35 /** @see TestObjects#middleDates() */
37 public static LocalDate
[] MONTH_MIDDLE_DATES
= TestObjects
.middleDates();
40 * Ensures that for any given date the correct calendar year will be returned in an early fiscal year.
43 * The start date of the fiscal year.
45 * The current date in a calendar year.
48 public void shouldReturnCalendarYearInEarlyFiscalYear(final Months startDate
, final LocalDate currentDate
) {
50 final FiscalDate fiscalDate
= FiscalYears
.earlyFiscalYear(startDate
).create(currentDate
);
53 final int calendarYear
= fiscalDate
.getCalendarYear();
56 Assert
.assertEquals(currentDate
.getYear(), calendarYear
);
60 * Ensures that for any given date the correct calendar year will be returned in a late fiscal year.
63 * The start date of the fiscal year.
65 * The current date in a calendar year.
68 public void shouldReturnCalendarYearInLateFiscalYear(final Months startDate
, final LocalDate currentDate
) {
70 final FiscalDate fiscalDate
= FiscalYears
.lateFiscalYear(startDate
).create(currentDate
);
73 final int calendarYear
= fiscalDate
.getCalendarYear();
76 Assert
.assertEquals(currentDate
.getYear(), calendarYear
);