-
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.
[FEATURE] Fixed bug when progress of the playback was calculated wron…
…gly (#71) Fixed bug when progress was calculated wrongly because playStartTime, lastPauseTime weren't persisted to repository. Added NOT FRAGILE unit tests for playback progress calculation by inctroducing Clock object.
- Loading branch information
1 parent
a3eba97
commit 16b9dc2
Showing
12 changed files
with
335 additions
and
42 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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/odeyalo/sonata/connect/support/time/Clock.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,17 @@ | ||
package com.odeyalo.sonata.connect.support.time; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.time.Instant; | ||
|
||
/** | ||
* A wrapper around the system clock to allow custom implementations to be used in unit tests where we want to fake or control the clock behavior. | ||
*/ | ||
public interface Clock { | ||
|
||
@NotNull | ||
Instant now(); | ||
|
||
long currentTimeMillis(); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/odeyalo/sonata/connect/support/time/JavaClock.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,27 @@ | ||
package com.odeyalo.sonata.connect.support.time; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.time.Instant; | ||
|
||
public final class JavaClock implements Clock { | ||
private static final JavaClock INSTANCE = new JavaClock(); | ||
|
||
private JavaClock() {} | ||
|
||
@NotNull | ||
public static JavaClock instance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Instant now() { | ||
return Instant.now(); | ||
} | ||
|
||
@Override | ||
public long currentTimeMillis() { | ||
return now().toEpochMilli(); | ||
} | ||
} |
Oops, something went wrong.