Skip to content

Commit

Permalink
use kotlin map
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-olaveide committed Feb 28, 2022
1 parent dcde030 commit 4f93da8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfigu
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.test.context.ActiveProfiles
import java.util.Map

@SpringBootTest(classes = [OAuth2ClientConfiguration::class, RestTemplateAutoConfiguration::class])
@ActiveProfiles("test")
Expand All @@ -28,7 +27,7 @@ internal class ClientConfigurationPropertiesTest {
fun testClientConfigIsValid() {
assertThat(clientConfigurationProperties).isNotNull
assertThat(clientConfigurationProperties.registration).isNotNull
val clientProperties = clientConfigurationProperties.registration.values().stream().findFirst().orElse(null)
val clientProperties = clientConfigurationProperties.registration.values.stream().findFirst().orElse(null)
assertThat(clientProperties).isNotNull
val auth = clientProperties.authentication
assertThat(auth).isNotNull
Expand All @@ -46,7 +45,7 @@ internal class ClientConfigurationPropertiesTest {
assertThat(clientConfigurationProperties.registration).isNotNull
val clientProperties = clientConfigurationProperties.registration["example1-token-exchange1"]
assertThat(clientProperties).isNotNull
assertThat(clientProperties.tokenExchange.audience).isNotBlank
assertThat(clientProperties!!.tokenExchange.audience).isNotBlank
}

@Test
Expand All @@ -55,7 +54,7 @@ internal class ClientConfigurationPropertiesTest {
assertThat(clientConfigurationProperties.registration).isNotNull
val clientProperties = clientConfigurationProperties.registration["example1-clientcredentials3"]
assertThat(clientProperties).isNotNull
val auth = clientProperties.authentication
val auth = clientProperties!!.authentication
assertThat(auth).isNotNull
assertThat(auth.clientAuthMethod).isEqualTo(ClientAuthenticationMethod.PRIVATE_KEY_JWT)
assertThat(auth.clientId).isNotNull
Expand All @@ -67,8 +66,8 @@ internal class ClientConfigurationPropertiesTest {

@Test
fun testDifferentClientPropsShouldNOTBeEqualAndShouldMakeSurroundingRequestsUnequalToo() {
val props: Map<String, ClientProperties>? = clientConfigurationProperties.registration
assertThat(props!!.size()).isGreaterThan(1)
val props = clientConfigurationProperties.registration
assertThat(props.size).isGreaterThan(1)
val p1 = props.get("example1-onbehalfof")
val p2 = props.get("example1-onbehalfof2")
assertThat(p1 == p2).isFalse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class ClientConfigurationPropertiesTestWithResourceUrl {
fun testClientConfigIsValid() {
assertThat(clientConfigurationProperties).isNotNull
assertThat(clientConfigurationProperties.registration).isNotNull
val clientProperties = clientConfigurationProperties.registration.values().stream().findFirst().orElse(null)
val clientProperties = clientConfigurationProperties.registration.values.stream().findFirst().orElse(null)
assertThat(clientProperties).isNotNull
val auth = clientProperties.authentication
assertThat(auth).isNotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class ClientConfigurationPropertiesTestWithWellKnownUrl {
fun testClientConfigIsValid() {
assertThat(clientConfigurationProperties).isNotNull
assertThat(clientConfigurationProperties.registration).isNotNull
val clientProperties = clientConfigurationProperties.registration.values().stream().findFirst().orElse(null)
val clientProperties = clientConfigurationProperties.registration.values.stream().findFirst().orElse(null)
assertThat(clientProperties).isNotNull
val auth = clientProperties.authentication
assertThat(auth).isNotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class OAuth2AccessTokenServiceIntegrationTest {
get() {
var clientProperties = clientConfigurationProperties.registration["example1-onbehalfof"]
Assertions.assertThat(clientProperties).isNotNull
clientProperties = clientProperties.toBuilder()
clientProperties = clientProperties!!.toBuilder()
.tokenEndpointUrl(tokenEndpointUrl)
.build()
server!!.enqueue(TestUtils.jsonResponse(TOKEN_RESPONSE))
Expand Down Expand Up @@ -110,7 +110,7 @@ internal class OAuth2AccessTokenServiceIntegrationTest {
var clientProperties = clientConfigurationProperties.registration["example1-token" +
"-exchange1"]
Assertions.assertThat(clientProperties).isNotNull
clientProperties = clientProperties.toBuilder()
clientProperties = clientProperties!!.toBuilder()
.tokenEndpointUrl(tokenEndpointUrl)
.build()
server!!.enqueue(TestUtils.jsonResponse(TOKEN_RESPONSE))
Expand Down Expand Up @@ -138,7 +138,7 @@ internal class OAuth2AccessTokenServiceIntegrationTest {
get() {
var clientProperties = clientConfigurationProperties.registration["example1-clientcredentials1"]
Assertions.assertThat(clientProperties).isNotNull
clientProperties = clientProperties.toBuilder()
clientProperties = clientProperties!!.toBuilder()
.tokenEndpointUrl(tokenEndpointUrl)
.build()
server!!.enqueue(TestUtils.jsonResponse(TOKEN_RESPONSE))
Expand Down

0 comments on commit 4f93da8

Please sign in to comment.