@Test void isPartLifetimePassed80Percent() { Instant now = Instant.now(); long issueToken = now.minusSeconds(800).toEpochMilli() / 1000; long expiration = now.plusSeconds(200).toEpochMilli() /1000; TokenExpirationInfoBO token = new TokenExpirationInfoBO(issueToken, expiration); assertThat(token.isPartLifetimePassed(0.25), is(true)); assertThat(token.isPartLifetimePassed(0.5), is(true)); assertThat(token.isPartLifetimePassed(0.75), is(true)); }
public boolean isPartLifetimePassed(double part) { Duration tokenDurationAllowedByIdentityProvider = getTokenExpirationDuration(); Duration actualTokenDuration = getTokenLifetimeDuration(); return tokenDurationAllowedByIdentityProvider.toMillis() * 1.0 * part < actualTokenDuration.toMillis(); }
TokenExpirationInfoBO { public boolean isPartLifetimePassed(double part) { Duration tokenDurationAllowedByIdentityProvider = getTokenExpirationDuration(); Duration actualTokenDuration = getTokenLifetimeDuration(); return tokenDurationAllowedByIdentityProvider.toMillis() * 1.0 * part < actualTokenDuration.toMillis(); } }
TokenExpirationInfoBO { public boolean isPartLifetimePassed(double part) { Duration tokenDurationAllowedByIdentityProvider = getTokenExpirationDuration(); Duration actualTokenDuration = getTokenLifetimeDuration(); return tokenDurationAllowedByIdentityProvider.toMillis() * 1.0 * part < actualTokenDuration.toMillis(); } TokenExpirationInfoBO();  TokenExpirationInfoBO(long issuedAt, long expiration); }
TokenExpirationInfoBO { public boolean isPartLifetimePassed(double part) { Duration tokenDurationAllowedByIdentityProvider = getTokenExpirationDuration(); Duration actualTokenDuration = getTokenLifetimeDuration(); return tokenDurationAllowedByIdentityProvider.toMillis() * 1.0 * part < actualTokenDuration.toMillis(); } TokenExpirationInfoBO();  TokenExpirationInfoBO(long issuedAt, long expiration); Duration getTokenExpirationDuration(); Duration getTokenLifetimeDuration(); boolean isDurationPassed(Duration duration); boolean isDurationPassed(Duration duration, Instant comparing); boolean isExpired(); boolean isPartLifetimePassed(double part); Instant getIssuedAt(); void setIssuedAt(Instant issuedAt); Instant getExpiration(); void setExpiration(Instant expiration); @Override String toString(); }
TokenExpirationInfoBO { public boolean isPartLifetimePassed(double part) { Duration tokenDurationAllowedByIdentityProvider = getTokenExpirationDuration(); Duration actualTokenDuration = getTokenLifetimeDuration(); return tokenDurationAllowedByIdentityProvider.toMillis() * 1.0 * part < actualTokenDuration.toMillis(); } TokenExpirationInfoBO();  TokenExpirationInfoBO(long issuedAt, long expiration); Duration getTokenExpirationDuration(); Duration getTokenLifetimeDuration(); boolean isDurationPassed(Duration duration); boolean isDurationPassed(Duration duration, Instant comparing); boolean isExpired(); boolean isPartLifetimePassed(double part); Instant getIssuedAt(); void setIssuedAt(Instant issuedAt); Instant getExpiration(); void setExpiration(Instant expiration); @Override String toString();  }