fixed compilation issues
[fiscal-year.java.git] / src / test / java / com / github / sebhoss / time / FiscalDateGetCalendarDayOfMonthTest.java
blob46ffff6747062f7ba3d2318ee1ba3128f5209820
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 java.time.LocalDate;
17 import java.time.Month;
19 import com.github.sebhoss.warnings.CompilerWarnings;
21 import org.junit.Assert;
22 import org.junit.experimental.theories.DataPoints;
23 import org.junit.experimental.theories.Theories;
24 import org.junit.experimental.theories.Theory;
25 import org.junit.runner.RunWith;
27 /**
28 * Test cases for {@link FiscalDate#getCalendarDayOfMonth()}.
30 @RunWith(Theories.class)
31 @SuppressWarnings(CompilerWarnings.STATIC_METHOD)
32 public class FiscalDateGetCalendarDayOfMonthTest {
34 /** @see TestObjects#supportedMonths() */
35 @DataPoints
36 public static final Month[] START_DATES = TestObjects.supportedMonths();
38 /** @see TestObjects#startDates() */
39 @DataPoints
40 public static final LocalDate[] MONTH_START_DATES = TestObjects.startDates();
42 /** @see TestObjects#middleDates() */
43 @DataPoints
44 public static final LocalDate[] MONTH_MIDDLE_DATES = TestObjects.middleDates();
46 /**
47 * Ensures that for any given date the correct calendar day of month will be returned in an early fiscal year.
49 * @param startDate
50 * The start date of the fiscal year.
51 * @param currentDate
52 * The current date in a calendar year.
54 @Theory
55 public void shouldReturnCalendarDayOfMonthInEarlyFiscalYear(final Month startDate, final LocalDate currentDate) {
56 // Given
57 final FiscalDate fiscalDate = FiscalYears.earlyFiscalYear(startDate).createFromCalendarDate(currentDate);
59 // When
60 final long calendarDayOfMonth = fiscalDate.getCalendarDayOfMonth();
62 // Then
63 Assert.assertEquals(currentDate.getDayOfMonth(), calendarDayOfMonth);
66 /**
67 * Ensures that for any given date the correct calendar day of month will be returned in a late fiscal year.
69 * @param startDate
70 * The start date of the fiscal year.
71 * @param currentDate
72 * The current date in a calendar year.
74 @Theory
75 public void shouldReturnCalendarDayOfMonthInLateFiscalYear(final Month startDate, final LocalDate currentDate) {
76 // Given
77 final FiscalDate fiscalDate = FiscalYears.lateFiscalYear(startDate).createFromCalendarDate(currentDate);
79 // When
80 final long calendarDayOfMonth = fiscalDate.getCalendarDayOfMonth();
82 // Then
83 Assert.assertEquals(currentDate.getDayOfMonth(), calendarDayOfMonth);