### Question:
Duration extends TimeBase<Duration> { public boolean sleep() { try { Thread.sleep( (this.secs * TimeBase.SECS_TO_MILLI) + ((long) ((double) this.nsecs / (double) TimeBase.MILLI_TO_NSECS)), this.nsecs % (int) TimeBase.MILLI_TO_NSECS); return true; } catch (InterruptedException e) { return false; } } Duration();  Duration(int secs, int nsecs);  Duration(double sec);  Duration(long nano); @Override Duration add(Duration d); @Override Duration subtract(Duration d); boolean sleep(); @Override Duration clone(); static Duration fromSec(double sec); static Duration fromNano(long nano); static Duration fromJsonString(String jsonString); static Duration fromJsonObject(JsonObject jsonObject); static final String TYPE; }### Answer:
@Test public void testSleep() { long t = System.nanoTime(); assertTrue(d2.sleep()); assertTrue(greaterThanEquals(System.nanoTime(), t + d2.toNSec())); }
@Test public void testSleepTooManyNanos() { Duration d = new Duration(0, 500000000); long t = System.nanoTime(); assertTrue(d.sleep()); assertTrue(greaterThanEquals(System.nanoTime(), t + d.toNSec())); }
@Test public void testSleepFailed() { long t = System.nanoTime(); Thread.currentThread().interrupt(); assertFalse(d3.sleep()); assertFalse(greaterThanEquals(System.nanoTime(), t + d3.toNSec())); }