-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mapping for sy:updatePeriod and sy:updateFrequency (#181)
- Loading branch information
Showing
8 changed files
with
82 additions
and
5 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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/apptasticsoftware/rssreader/util/Util.java
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,30 @@ | ||
package com.apptasticsoftware.rssreader.util; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* Utility class for RSS reader. | ||
*/ | ||
public class Util { | ||
|
||
private Util() { | ||
|
||
} | ||
|
||
/** | ||
* Convert a time period string to hours. | ||
* | ||
* @param period the time period string (e.g., "daily", "weekly", "monthly", "yearly", "hourly") | ||
* @return the number of hours in the given time period, or 1 if the period is not recognized | ||
*/ | ||
public static int toMinutes(String period) { | ||
switch (period.toLowerCase(Locale.ENGLISH)) { | ||
case "daily": return 1440; | ||
case "weekly": return 10080; | ||
case "monthly": return 43800; | ||
case "yearly": return 525600; | ||
case "hourly": | ||
default: return 60; | ||
} | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/test/java/com/apptasticsoftware/rssreader/util/UtilTest.java
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,29 @@ | ||
package com.apptasticsoftware.rssreader.util; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class UtilTest { | ||
|
||
@ParameterizedTest(name = "{0} is expected to output {1}") | ||
@MethodSource("periodToHoursTestData") | ||
void periodToHours(String period, int expectedHours) { | ||
assertEquals(expectedHours, Util.toMinutes(period)); | ||
} | ||
|
||
private static Stream<Arguments> periodToHoursTestData() { | ||
return Stream.of( | ||
Arguments.of("daily", 1440), | ||
Arguments.of("weekly", 10080), | ||
Arguments.of("monthly", 43800), | ||
Arguments.of("yearly", 525600), | ||
Arguments.of("hourly", 60), | ||
Arguments.of("unknown", 60) | ||
); | ||
} | ||
} |
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