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 com
.github
.sebhoss
.warnings
.CompilerWarnings
;
18 import org
.joda
.time
.LocalDate
;
19 import org
.joda
.time
.Months
;
20 import org
.junit
.Assert
;
21 import org
.junit
.experimental
.theories
.DataPoints
;
22 import org
.junit
.experimental
.theories
.Theories
;
23 import org
.junit
.experimental
.theories
.Theory
;
24 import org
.junit
.runner
.RunWith
;
27 * Test cases for {@link FiscalDate#getCalendarMonth()}.
29 @RunWith(Theories
.class)
30 @SuppressWarnings(CompilerWarnings
.STATIC_METHOD
)
31 public class FiscalDateGetCalendarMonthTest
{
33 /** @see TestObjects#supportedMonths() */
35 public static final Months
[] START_DATES
= TestObjects
.supportedMonths();
37 /** @see TestObjects#startDates() */
39 public static final LocalDate
[] MONTH_START_DATES
= TestObjects
.startDates();
41 /** @see TestObjects#middleDates() */
43 public static final LocalDate
[] MONTH_MIDDLE_DATES
= TestObjects
.middleDates();
46 * Ensures that for any given date the correct calendar month will be returned in an early fiscal year.
49 * The start date of the fiscal year.
51 * The current date in a calendar year.
54 public void shouldReturnCalendarMonthInEarlyFiscalYear(final Months startDate
, final LocalDate currentDate
) {
56 final FiscalDate fiscalDate
= FiscalYears
.earlyFiscalYear(startDate
).createFromCalendarDate(currentDate
);
59 final int calendarMonth
= fiscalDate
.getCalendarMonth();
62 Assert
.assertEquals(currentDate
.getMonthOfYear(), calendarMonth
);
66 * Ensures that for any given date the correct calendar month will be returned in a late fiscal year.
69 * The start date of the fiscal year.
71 * The current date in a calendar year.
74 public void shouldReturnCalendarMonthInLateFiscalYear(final Months startDate
, final LocalDate currentDate
) {
76 final FiscalDate fiscalDate
= FiscalYears
.lateFiscalYear(startDate
).createFromCalendarDate(currentDate
);
79 final int calendarMonth
= fiscalDate
.getCalendarMonth();
82 Assert
.assertEquals(currentDate
.getMonthOfYear(), calendarMonth
);