### Question:
Time extends TimeBase<Time> { public boolean isValid() { return !this.isZero(); } Time();  Time(int secs, int nsecs);  Time(double sec);  Time(long nano); @Override Time add(Time t); @Override Time subtract(Time t); boolean isValid(); Date toDate(); static boolean sleepUntil(Time t); @Override Time clone(); static Time now(); static Time fromSec(double sec); static Time fromNano(long nano); static Time fromDate(Date date); static Time fromJsonString(String jsonString); static Time fromJsonObject(JsonObject jsonObject); static final String TYPE; }### Answer:
@Test public void testConstructor() { assertEquals(0, empty.secs); assertEquals(0, empty.nsecs); assertEquals(0, empty.getSecs()); assertEquals(0, empty.getNsecs()); assertTrue(empty.isZero()); assertEquals(0.0, empty.toSec(), 0); assertEquals(0l, empty.toNSec()); assertFalse(empty.isValid()); assertEquals("{\"secs\":0,\"nsecs\":0}", empty.toString()); assertEquals(2, empty.toJsonObject().size()); assertEquals(0, empty.toJsonObject().getInt(TimeBase.FIELD_SECS)); assertEquals(0, empty.toJsonObject().getInt(TimeBase.FIELD_NSECS)); assertEquals(Time.TYPE, empty.getPrimitiveType()); }
@Test public void testDoubleConstructor() { assertEquals(10, t1.secs); assertEquals(200000000, t1.nsecs); assertEquals(10, t1.getSecs()); assertEquals(200000000, t1.getNsecs()); assertFalse(t1.isZero()); assertEquals(10.2, t1.toSec(), 0); assertEquals(10200000000l, t1.toNSec()); assertTrue(t1.isValid()); assertEquals("{\"secs\":10,\"nsecs\":200000000}", t1.toString()); assertEquals(2, t1.toJsonObject().size()); assertEquals(10, t1.toJsonObject().getInt(TimeBase.FIELD_SECS)); assertEquals(200000000, t1.toJsonObject().getInt(TimeBase.FIELD_NSECS)); assertEquals(Time.TYPE, t1.getPrimitiveType()); }
@Test public void testLongConstructor() { assertEquals(0, t2.secs); assertEquals(1024, t2.nsecs); assertEquals(0, t2.getSecs()); assertEquals(1024, t2.getNsecs()); assertFalse(t2.isZero()); assertEquals(1.024e-6, t2.toSec(), 0); assertEquals(1024l, t2.toNSec()); assertTrue(t2.isValid()); assertEquals("{\"secs\":0,\"nsecs\":1024}", t2.toString()); assertEquals(2, t2.toJsonObject().size()); assertEquals(0, t2.toJsonObject().getInt(TimeBase.FIELD_SECS)); assertEquals(1024, t2.toJsonObject().getInt(TimeBase.FIELD_NSECS)); assertEquals(Time.TYPE, t2.getPrimitiveType()); }
@Test public void testIntAndIntConstructor() { assertEquals(10, t3.secs); assertEquals(20, t3.nsecs); assertEquals(10, t3.getSecs()); assertEquals(20, t3.getNsecs()); assertFalse(t3.isZero()); assertEquals(10.00000002, t3.toSec(), 0); assertEquals(10000000020l, t3.toNSec()); assertTrue(t3.isValid()); assertEquals("{\"secs\":10,\"nsecs\":20}", t3.toString()); assertEquals(2, t3.toJsonObject().size()); assertEquals(10, t3.toJsonObject().getInt(TimeBase.FIELD_SECS)); assertEquals(20, t3.toJsonObject().getInt(TimeBase.FIELD_NSECS)); assertEquals(Time.TYPE, t3.getPrimitiveType()); }