JdbcRevocableTokenProvisioning implements RevocableTokenProvisioning, SystemDeletable { @Override public RevocableToken create(RevocableToken t, String zoneId) { checkExpired(); template.update(INSERT_QUERY, t.getTokenId(), t.getClientId(), t.getUserId(), t.getFormat(), t.getResponseType().toString(), t.getIssuedAt(), t.getExpiresAt(), t.getScope(), t.getValue(), zoneId); return retrieve(t.getTokenId(), false, zoneId); } JdbcRevocableTokenProvisioning(JdbcTemplate jdbcTemplate,
                                          LimitSqlAdapter limitSqlAdapter,
                                          TimeService timeService); @Override List<RevocableToken> retrieveAll(String zoneId); RevocableToken retrieve(String id, boolean checkExpired, String zoneId); @Override RevocableToken retrieve(String id, String zoneId); @Override int deleteRefreshTokensForClientAndUserId(String clientId, String userId, String zoneId); @Override RevocableToken create(RevocableToken t, String zoneId); @Override RevocableToken update(String id, RevocableToken t, String zoneId); @Override RevocableToken delete(String id, int version, String zoneId); @Override int deleteByIdentityZone(String zoneId); @Override int deleteByClient(String clientId, String zoneId); @Override int deleteByUser(String userId, String zoneId); @Override Logger getLogger(); @Override List<RevocableToken> getUserTokens(String userId, String zoneId); @Override List<RevocableToken> getUserTokens(String userId, String clientId, String zoneId); @Override List<RevocableToken> getClientTokens(String clientId, String zoneId); void setMaxExpirationRuntime(long maxExpirationRuntime); void setTimeService(TimeService timeService);  }
@Test void addDuplicateFails() { jdbcRevocableTokenProvisioning.create(revocableToken, IdentityZoneHolder.get().getId()); assertThrows(DuplicateKeyException.class, () -> jdbcRevocableTokenProvisioning.create(revocableToken, IdentityZoneHolder.get().getId())); }
@Test void create() { RevocableToken createdToken = jdbcRevocableTokenProvisioning.create(revocableToken, IdentityZoneHolder.get().getId()); assertTokensAreEqual(revocableToken, createdToken); }