-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add holiday list for month only display
Added maven enforcer plugin requiring mvn >= v3.2.5 Show holidays for the active month in the month only display Moves display holidays code to the holiay class Display locale when in debug mode (near the command line switch output) Tweaked month validation when both month & year are given Added another calendar output test (for Nov 2026)
- Loading branch information
Showing
7 changed files
with
234 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/****************************************************************************** | ||
* Cal - A command line calendar utility | ||
* | ||
* Copyright (c) 2019-2024 Michael Fross | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
******************************************************************************/ | ||
package org.fross.cal; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.Locale; | ||
import java.util.TreeMap; | ||
|
||
import org.fross.library.Output; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class HolidaysTest { | ||
|
||
// Test holiday list - US | ||
@Test | ||
void holidayListTestUS() { | ||
// ------------------------------------------------------------------------ | ||
// For now, skip this test if the JVM does not report it's in the US | ||
// ------------------------------------------------------------------------ | ||
if (Locale.getDefault().getDisplayCountry().toString().compareTo("United States") != 0) { | ||
Output.println("Current locale set to: '" + Locale.getDefault().getDisplayCountry() + "' -- Skipping Test"); | ||
return; | ||
} | ||
|
||
Output.print("Current locale set to: '" + Locale.getDefault().getDisplayCountry() + "'"); | ||
|
||
// Get the holiday list for the US in 2023 | ||
TreeMap<String, String> holidayListUS = Holidays.getHolidays(2023); | ||
|
||
// There should be 12 holidays in 2023 | ||
assertEquals(12, holidayListUS.size()); | ||
|
||
String[] correctValuesUS = { "2023-01-02", "2023-01-16", "2023-02-20", "2023-04-07", "2023-05-29", "2023-06-19", "2023-07-04", "2023-09-04", | ||
"2023-10-09", "2023-11-10", "2023-11-23", "2023-12-25" }; | ||
|
||
// Loop through the results and verify the keys (dates) | ||
int i = 0; | ||
for (String key : holidayListUS.keySet()) { | ||
assertEquals(correctValuesUS[i], key); | ||
i = i + 1; | ||
} | ||
Output.println("...Holiday Test Complete"); | ||
|
||
} | ||
|
||
// // Test holiday list - CA | ||
// @Test | ||
// void holidayListTestCA() { | ||
// // ------------------------------------------------------------------------ | ||
// // Set the default country to Canada | ||
// // ------------------------------------------------------------------------ | ||
// Locale.setDefault(Locale.CANADA); | ||
// Output.println("Current locale set to: " + Locale.getDefault().getDisplayCountry()); | ||
// | ||
// // Get the holiday list for the 2023 Canadian holidays | ||
// TreeMap<String, String> holidayListCA = Holidays.getHolidays(2024); | ||
// | ||
// // There should be 19 holidays in 2023 | ||
// assertEquals(19, holidayListCA.size()); | ||
// | ||
// String[] correctValuesCA = { "2024-01-01", "2024-02-19", "2024-03-17", "2024-03-29", "2024-04-01", "2024-04-23", "2024-05-20", "2024-06-21", | ||
// "2024-06-24", "2024-07-01", "2024-07-12", "2024-08-05", "2024-08-19", "2024-09-02", "2024-09-30", "2024-10-14", "2024-11-11", "2024-12-25", | ||
// "2024-12-26" }; | ||
// | ||
// // Loop through the results and verify the keys (dates) | ||
// int i = 0; | ||
// for (String key : holidayListCA.keySet()) { | ||
// assertEquals(correctValuesCA[i], key); | ||
// i = i + 1; | ||
// } | ||
// | ||
// Output.println("Canada Holiday Test Complete"); | ||
// } | ||
} |