### Question:
Duration implements Comparable<Duration> { @Override public int compareTo(Duration d) { if ((secs > d.secs) || ((secs == d.secs) && nsecs > d.nsecs)) { return 1; } if ((secs == d.secs) && (nsecs == d.nsecs)) { return 0; } return -1; } Duration();  Duration(int secs, int nsecs);  Duration(double secs);  Duration(Duration t); Duration add(Duration d); Duration subtract(Duration d); static Duration fromMillis(long durationInMillis); static Duration fromNano(long durationInNs); void normalize(); long totalNsecs(); boolean isZero(); boolean isPositive(); boolean isNegative(); @Override String toString(); @Override int hashCode(); @Override /** * Check for equality between Time objects. * equals() does not normalize Time representations, so fields must match exactly. */ boolean equals(Object obj); @Override int compareTo(Duration d); static final Duration MAX_VALUE; public int secs; public int nsecs; }### Answer:
@Test public void testComparable() { assertEquals(0, new Duration(0, 0).compareTo(new Duration(0, 0))); assertEquals(0, new Duration(1, 0).compareTo(new Duration(1, 0))); assertTrue(new Duration(0, 0).compareTo(new Duration(0, -1)) > 0); assertTrue(new Duration(0, -1).compareTo(new Duration(0, 0)) < 0); assertTrue(new Duration(0, 0).compareTo(new Duration(-1, 0)) > 0); assertTrue(new Duration(-1, 0).compareTo(new Duration(0, 0)) < 0); assertTrue(new Duration(1, 0).compareTo(new Duration(0, 0)) > 0); assertTrue(new Duration(0, 0).compareTo(new Duration(1, 0)) < 0); assertTrue(new Duration(0, 1).compareTo(new Duration(0, 0)) > 0); assertTrue(new Duration(0, 0).compareTo(new Duration(0, 1)) < 0); }