### Question:
TimeWithUnit { public long getTime() { return time; } private  TimeWithUnit();  TimeWithUnit(TimeUnit unit, long time); String getTimeUnit(); long getTime(); long getTime(String unit); long getTime(TimeUnit unit);  }### Answer:
@Test public void convertFromSecondsToMilliseconds() { TimeWithUnit twu = new TimeWithUnit(TimeUnit.SECONDS, 123); long duration = twu.getTime(TimeUnit.MILLISECONDS.name()); assertThat(duration, is(123000L)); }
@Test public void convertFromMilliSecondsToSeconds() { TimeWithUnit twu = new TimeWithUnit(TimeUnit.MILLISECONDS, 123456); long duration = twu.getTime(TimeUnit.SECONDS.name()); assertThat(duration, is(123L)); }
@Test(expected = IllegalArgumentException.class) public void unknownUnit() { TimeWithUnit twu = new TimeWithUnit(TimeUnit.DAYS, 123); twu.getTime("Foo"); }