### Question:
LeaseDuration { public static LeaseDuration of(String initial, String max, String step) { return builder().setInitial(initial).setMax(max).setStep(step).build(); } private  LeaseDuration(long initial, long max, long step); static Builder builder(); static LeaseDuration of(String initial, String max, String step); static LeaseDuration of(long initial, long max, long step); long getInitial(); long getMax(); long getStep(); long calcInitialLease(String requestedInitialLease); long calcInitialLease(long requestedInitialLease); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final LeaseDuration FOREVER_LEASE_DURATION; }### Answer:
@Test public void testLeaseDurationJsonRelativeTime() { LeaseDuration leaseDuration = LeaseDuration.of("7d", "0", "0"); Assert.assertEquals(leaseDuration, GSON.fromJson("{\"initial\":\"7d\",\"max\":\"0\",\"step\":\"0\"}", LeaseDuration.class)); }
@Test public void testLeaseDurationJsonAbsoluteTime() { LeaseDuration leaseDuration = LeaseDuration.of(123, 0, 1); Assert.assertEquals(leaseDuration, GSON.fromJson("{\"initial\":123,\"max\":0,\"step\":1}", LeaseDuration.class)); }
@Test public void testLeaseDurationJsonMissingMax() { LeaseDuration leaseDuration = LeaseDuration.of(123, 0, 1); Assert.assertEquals(leaseDuration, GSON.fromJson("{\"initial\":123,\"step\":1}", LeaseDuration.class)); }
@Test(expected = IllegalArgumentException.class) public void testNegativeArgStringConstructor() { LeaseDuration.of("-15s", "0", "0"); }
@Test(expected = RuntimeException.class) public void testUnsupportedArgStringConstructor() { LeaseDuration.of("1v", "0", "0"); }
@Test(expected = RuntimeException.class) public void testInvalidArgStringConstructor() { LeaseDuration.of("invalidNumbers", "0", "0"); }