### Question:
SampleCommand implements CliCommand { @Option(name = "--interval", aliases = {"-i"}, usage = "minimal wait time before invoking second sample") public void setInterval(String interval) throws CmdLineException { Matcher matcher = Pattern.compile("^(\\d+)([a-z]*)$").matcher(interval); if (!matcher.find()) throw new CmdLineException("Invalid interval specified: " + interval); int number = Integer.parseInt(matcher.group(1)); String unit = matcher.group(2); if (unit.isEmpty() || "s".equals(unit)) { this.interval = TimeUnit.SECONDS.toMillis(number); } else if ("ms".equals(unit)) { this.interval = number; } else if ("m".equals(unit)) { this.interval = TimeUnit.MINUTES.toMillis(number); } else if ("h".equals(unit)) { this.interval = TimeUnit.HOURS.toMillis(number); } }  @Option(name = "--number", aliases = {"-n"}, usage = "Number of samples to take") void setNumber(int number); @Option(name = "--interval", aliases = {"-i"}, usage = "minimal wait time before invoking second sample") void setInterval(String interval); @Override @Nonnull String getName(); @Override @Nonnull String getDescription(); @Override int run(@Nonnull ProcessStream process); @Option(name = "--out", aliases = {"-o"}, usage = "Output files to write the result")
    public String output; public long interval; }### Answer:
@Test public void parseInterval() throws Exception { SampleCommand sc = new SampleCommand(); sc.setInterval("50"); assertThat(sc.interval, equalTo(50000L)); sc.setInterval("1s"); assertThat(sc.interval, equalTo(1000L)); sc.setInterval("100ms"); assertThat(sc.interval, equalTo(100L)); sc.setInterval("5m"); assertThat(sc.interval, equalTo(1000L * 60 * 5)); sc.setInterval("1h"); assertThat(sc.interval, equalTo(1000L * 60 * 60)); try { sc.setInterval("1d"); } catch (CmdLineException ex) { } }