### Question:
TimeDuration implements Comparable<TimeDuration> { public static TimeDuration of(String durationString) { Matcher matcher = DURATION_PATTERN.matcher(durationString); if (matcher.matches()) { long duration = Long.parseLong(matcher.group(2)); if (matcher.group(1) != null) { duration = duration * -1; } return new TimeDuration(durationString, duration * getDurationMultiplier(matcher.group(3))); } else { throw new IllegalArgumentException("Invalid duration '" + durationString + "'"); } } private  TimeDuration(String durationString, long durationMs); static TimeDuration of(String durationString); long getMillis(); @Override String toString(); @Override int compareTo(TimeDuration o); static final Pattern DURATION_PATTERN; }### Answer:
@Test void testParseUnitInvalid() { for (String invalid : List.of(" 1s", "1 s", "1s ", "1h")) { assertThatCode(() -> TimeDuration.of(invalid)).isInstanceOf(IllegalArgumentException.class); } }