CountSegment implements Segment { @Override public boolean validateToken(final String token) { try { Long.parseLong(token); return true; } catch (NumberFormatException ex) { return false; } } CountSegment(); @Override String getStaticText(); @Override String createToken(final String prefix, final Timestamp timestamp); @Override boolean validateToken(final String token);  }
@Test public void validateValidToken() { CountSegment segment = new CountSegment(); assertThat(segment.validateToken("42")).isTrue(); }
@Test public void validateInvalidToken() { CountSegment segment = new CountSegment(); assertThat(segment.validateToken("abc")).isFalse(); }