Skip to content

Commit

Permalink
bruk kotlin annoteringer for å redefinere getters
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Olav Eide committed Oct 14, 2024
1 parent 3f3c81d commit 22c3c9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package no.nav.security.token.support.client.core.oauth2

data class OAuth2AccessTokenResponse (var access_token : String? = null, var expires_at : Int? = null, var expires_in : Int? = 60, private val additionalParameters : Map<String, Any> = emptyMap()) {
val accessToken = access_token
val expiresAt = expires_at
val expiresIn = expires_in
data class OAuth2AccessTokenResponse (@get:JvmName("getAccessToken") var access_token : String? = null,
@get:JvmName("getExpiresAt") var expires_at : Int? = null,
@get:JvmName("getExpiresIn") var expires_in : Int? = 60,
private val additionalParameters : Map<String, Any> = emptyMap()) {

@Deprecated(message = "Ikke bruk denne", replaceWith = ReplaceWith("getAccessToken()"))
fun getAccess_token() = access_token
@Deprecated(message = "Ikke bruk denne", replaceWith = ReplaceWith("getExpiresAt()"))
fun getExpires_at() = expires_at
@Deprecated(message = "Ikke bruk denne", replaceWith = ReplaceWith("getExpiresIn()"))
fun getExpires_in() = expires_in
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ internal class OAuth2AccessTokenServiceTest {
val res1 = oAuth2AccessTokenService.getAccessToken(clientProperties)
verify(onBehalfOfTokenResponseClient).getTokenResponse(reifiedAny(OnBehalfOfGrantRequest::class.java))
assertThat(res1).hasNoNullFieldsOrProperties()
assertThat(res1.accessToken).isEqualTo("first_access_token")
assertThat(res1.getAccessToken()).isEqualTo("first_access_token")
Thread.sleep(1000)

//entry should be missing from cache due to expiry
Expand Down

0 comments on commit 22c3c9b

Please sign in to comment.