Use new suppress-warnings package
[fiscal-year.java.git] / src / test / java / com / github / sebhoss / time / FiscalDateGetCalendarMonthTest.java
blobdc8df8fae87059654e7212a4ded728d8e294d38e
1 /*
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.
6 */
7 /*
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;
26 /**
27 * Test cases for {@link FiscalDate#getCalendarMonth()}.
29 @RunWith(Theories.class)
30 @SuppressWarnings(CompilerWarnings.STATIC_METHOD)
31 public class FiscalDateGetCalendarMonthTest {
33 /** @see TestObjects#supportedMonths() */
34 @DataPoints
35 public static final Months[] START_DATES = TestObjects.supportedMonths();
37 /** @see TestObjects#startDates() */
38 @DataPoints
39 public static final LocalDate[] MONTH_START_DATES = TestObjects.startDates();
41 /** @see TestObjects#middleDates() */
42 @DataPoints
43 public static final LocalDate[] MONTH_MIDDLE_DATES = TestObjects.middleDates();
45 /**
46 * Ensures that for any given date the correct calendar month will be returned in an early fiscal year.
48 * @param startDate
49 * The start date of the fiscal year.
50 * @param currentDate
51 * The current date in a calendar year.
53 @Theory
54 public void shouldReturnCalendarMonthInEarlyFiscalYear(final Months startDate, final LocalDate currentDate) {
55 // Given
56 final FiscalDate fiscalDate = FiscalYears.earlyFiscalYear(startDate).createFromCalendarDate(currentDate);
58 // When
59 final int calendarMonth = fiscalDate.getCalendarMonth();
61 // Then
62 Assert.assertEquals(currentDate.getMonthOfYear(), calendarMonth);
65 /**
66 * Ensures that for any given date the correct calendar month will be returned in a late fiscal year.
68 * @param startDate
69 * The start date of the fiscal year.
70 * @param currentDate
71 * The current date in a calendar year.
73 @Theory
74 public void shouldReturnCalendarMonthInLateFiscalYear(final Months startDate, final LocalDate currentDate) {
75 // Given
76 final FiscalDate fiscalDate = FiscalYears.lateFiscalYear(startDate).createFromCalendarDate(currentDate);
78 // When
79 final int calendarMonth = fiscalDate.getCalendarMonth();
81 // Then
82 Assert.assertEquals(currentDate.getMonthOfYear(), calendarMonth);