-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #32 - tests should work against a fixed "today"
Introduced a calendar provider. The real implementation provides real today to run time. The stub implementation provides a fixed date. Took a big refactor to do this.
- Loading branch information
1 parent
e1ba0e1
commit 5d75dfd
Showing
107 changed files
with
1,983 additions
and
1,309 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
20 changes: 20 additions & 0 deletions
20
...er-analytics/src/main/java/org/schoellerfamily/gedbrowser/analytics/CalendarProvider.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,20 @@ | ||
package org.schoellerfamily.gedbrowser.analytics; | ||
|
||
import java.util.Calendar; | ||
|
||
import org.joda.time.LocalDate; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
public interface CalendarProvider { | ||
/** | ||
* @return the provider's understanding of now as a Calendar | ||
*/ | ||
Calendar now(); | ||
|
||
/** | ||
* @return the provider's understanding of now as a LocalDate | ||
*/ | ||
LocalDate nowDate(); | ||
} |
26 changes: 26 additions & 0 deletions
26
...nalytics/src/main/java/org/schoellerfamily/gedbrowser/analytics/CalendarProviderImpl.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,26 @@ | ||
package org.schoellerfamily.gedbrowser.analytics; | ||
|
||
import java.util.Calendar; | ||
|
||
import org.joda.time.LocalDate; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
public final class CalendarProviderImpl implements CalendarProvider { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Calendar now() { | ||
return Calendar.getInstance(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public LocalDate nowDate() { | ||
return new LocalDate(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...nalytics/src/main/java/org/schoellerfamily/gedbrowser/analytics/CalendarProviderStub.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,33 @@ | ||
package org.schoellerfamily.gedbrowser.analytics; | ||
|
||
import java.util.Calendar; | ||
import java.util.Locale; | ||
|
||
import org.joda.time.LocalDate; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
public final class CalendarProviderStub implements CalendarProvider { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Calendar now() { | ||
final int birthYear = 2015; | ||
final int birthDay = 14; | ||
final Calendar referenceCalendar = Calendar.getInstance(Locale.US); | ||
referenceCalendar.set(Calendar.YEAR, birthYear); | ||
referenceCalendar.set(Calendar.MONTH, Calendar.DECEMBER); | ||
referenceCalendar.set(Calendar.DAY_OF_MONTH, birthDay); | ||
return referenceCalendar; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public LocalDate nowDate() { | ||
return new LocalDate(now()); | ||
} | ||
} |
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
Oops, something went wrong.