AccessToken { public static AccessToken fromString(String tokenString) throws NotAnAccessTokenException { try { return new AccessToken(UUID.fromString(tokenString)); } catch (IllegalArgumentException e) { throw new NotAnAccessTokenException(e); } } private  AccessToken(UUID token); static AccessToken fromString(String tokenString); static AccessToken generate(); String serialize(); UUID asUUID(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test void fromStringShouldThrowWhenNotAnUUID() { assertThatThrownBy(() -> AccessToken.fromString("bad")) .isInstanceOf(NotAnAccessTokenException.class); }