Added missing documentation
[fiscal-year.java.git] / src / test / java / com / github / sebhoss / time / FiscalDateGetCalendarYearTest.java
blobb56850261d0c887753ce5094e3544d52e386d8af
1 /*
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.
7 */
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;
22 /**
23 * Test cases for {@link FiscalDate#getCalendarYear()}.
25 @RunWith(Theories.class)
26 @SuppressWarnings(CompilerWarnings.STATIC_METHOD)
27 public class FiscalDateGetCalendarYearTest {
29 /** @see TestObjects#supportedMonths() */
30 @DataPoints
31 public static Months[] START_DATES = TestObjects.supportedMonths();
33 /** @see TestObjects#startDates() */
34 @DataPoints
35 public static LocalDate[] MONTH_START_DATES = TestObjects.startDates();
37 /** @see TestObjects#middleDates() */
38 @DataPoints
39 public static LocalDate[] MONTH_MIDDLE_DATES = TestObjects.middleDates();
41 /** @see TestObjects#comparators() */
42 @DataPoints
43 public static Comparator<Months>[] COMPARATORS = TestObjects.comparators();
45 /**
46 * Ensures that for any given date the correct calendar year will be returned.
48 * @param startDate
49 * The start date of the fiscal year.
50 * @param monthComparator
51 * The comparator to use.
52 * @param currentDate
53 * The current date in a calendar year.
55 @Theory
56 public void shouldReturnCalendarYear(final Months startDate, final Comparator<Months> monthComparator,
57 final LocalDate currentDate) {
58 // Given
59 final FiscalDate fiscalDate = new FiscalDateImplementation(startDate, monthComparator, currentDate);
61 // When
62 final int calendarYear = fiscalDate.getCalendarYear();
64 // Then
65 Assert.assertEquals(currentDate.getYear(), calendarYear);