| 23 | import java.time.ZoneId; |
| 24 | |
| 25 | public class TickingClock extends Clock implements Sleeper { |
| 26 | |
| 27 | private long now = 17; |
| 28 | |
| 29 | public long now() { |
| 30 | return now; |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public void sleep(Duration duration) { |
| 35 | now += duration.toMillis(); |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public ZoneId getZone() { |
| 40 | return ZoneId.systemDefault(); |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public Clock withZone(ZoneId zone) { |
| 45 | return this; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public Instant instant() { |
| 50 | return Instant.ofEpochMilli(now); |
| 51 | } |
| 52 | } |
nothing calls this directly
no outgoing calls
no test coverage detected