Skip to content

Commit

Permalink
refactor: coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
lohas1107 committed Jul 8, 2023
1 parent de054f8 commit 675f80c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions domain/src/main/kotlin/tw/waterballsa/gaas/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class User(
private const val NICKNAME_MAXIMUM_BYTE_SIZE = 16
}

constructor(email: String, nickname: String, identities: MutableList<String> ) :
this(null, email, nickname, identities)

fun changeNickname(nickname: String) {
val nicknameByteSize = nickname.toByteArray().size

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OAuth2Controller(
}

val Jwt.email: String
get() = claims["email"]?.let { it as String }
get() = claims["email"]?.toString()
?: throw PlatformException("JWT email should exist.")

val Jwt.identityProviderId: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ class UserControllerTest @Autowired constructor(
}

private fun givenUserNickname(nickname: String): User {
val user = User(null, "[email protected]", nickname, mockUser.identities)
val user = User("[email protected]", nickname, mockUser.identities)
return userRepository.createUser(user)
}

private fun givenAnotherUserNickname(nickname: String): User {
val user = User(null, "[email protected]", nickname, mockUser.identities)
val user = User("[email protected]", nickname, mockUser.identities)
return userRepository.createUser(user)
}

Expand All @@ -103,7 +103,6 @@ class UserControllerTest @Autowired constructor(
.withJwt(toJwt())
)


private fun ResultActions.thenGetUserSuccessfully() {
this.andExpect(status().isOk)
.andExpect(jsonPath("$.id").value(mockUser.id!!.value))
Expand All @@ -119,10 +118,10 @@ class UserControllerTest @Autowired constructor(
}

private fun ResultActions.thenUserNicknameShouldBeChanged(nickname: String) {
val userViewModel = andExpect(status().isOk)
val user = andExpect(status().isOk)
.getBody(UpdateUserViewModel::class.java)

userRepository.findById(userViewModel.id)
userRepository.findById(user.id)
.also { assertThat(it).isNotNull }
.also { assertThat(it!!.nickname).isEqualTo(nickname) }
}
Expand Down

0 comments on commit 675f80c

Please sign in to comment.