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 java
.util
.Comparator
;
12 import org
.joda
.time
.LocalDate
;
13 import org
.joda
.time
.Months
;
14 import org
.junit
.Assert
;
15 import org
.junit
.experimental
.theories
.DataPoints
;
16 import org
.junit
.experimental
.theories
.Theories
;
17 import org
.junit
.experimental
.theories
.Theory
;
18 import org
.junit
.runner
.RunWith
;
20 import com
.github
.sebhoss
.common
.annotation
.CompilerWarnings
;
23 * Test cases for {@link FiscalDate#getCalendarYear()}.
25 @RunWith(Theories
.class)
26 @SuppressWarnings(CompilerWarnings
.STATIC_METHOD
)
27 public class FiscalDateGetCalendarYearTest
{
29 /** @see TestObjects#supportedMonths() */
31 public static Months
[] START_DATES
= TestObjects
.supportedMonths();
33 /** @see TestObjects#startDates() */
35 public static LocalDate
[] MONTH_START_DATES
= TestObjects
.startDates();
37 /** @see TestObjects#middleDates() */
39 public static LocalDate
[] MONTH_MIDDLE_DATES
= TestObjects
.middleDates();
41 /** @see TestObjects#comparators() */
43 public static Comparator
<Months
>[] COMPARATORS
= TestObjects
.comparators();
46 * Ensures that for any given date the correct calendar year will be returned.
49 * The start date of the fiscal year.
50 * @param monthComparator
51 * The comparator to use.
53 * The current date in a calendar year.
56 public void shouldReturnCalendarYear(final Months startDate
, final Comparator
<Months
> monthComparator
,
57 final LocalDate currentDate
) {
59 final FiscalDate fiscalDate
= new FiscalDateImplementation(startDate
, monthComparator
, currentDate
);
62 final int calendarYear
= fiscalDate
.getCalendarYear();
65 Assert
.assertEquals(currentDate
.getYear(), calendarYear
);