-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: solve user update error #208
Merged
Merged
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
47ab695
chore: TripleMeetingServiceTest commented
SangMinLeeAI 2357180
fix: change update user information to upsert user information
SangMinLeeAI db8bfc5
chore: commented broken test
SangMinLeeAI 4cd380e
feat: initialize repository test
SangMinLeeAI de6efa1
fix: remove gender update
SangMinLeeAI 996d501
chore: format
SangMinLeeAI c601964
fix: change findUserProfile due to misfunction
SangMinLeeAI 65580a1
fix: change update user information logic
SangMinLeeAI d7b405c
test: add user integration test
SangMinLeeAI afa3286
feat: move update user profile logic to user service
SangMinLeeAI 34e81ad
test: add user domain test
SangMinLeeAI b24984e
Merge branch 'main' into fix/user-update
SangMinLeeAI ae8a8e9
chore: fix some missing value due to solving conflict
SangMinLeeAI fd7ba18
chore: add service injection
SangMinLeeAI e1141a0
chore: delete comment
SangMinLeeAI fc5293e
fix: delete h2 mode
SangMinLeeAI 1dd7ef1
fix: add h2 option to avoid keyword
SangMinLeeAI 07bc2d4
fix: change url in user api
SangMinLeeAI e2d903a
chore: move private function to end
SangMinLeeAI 7415103
fix: delete making test-aplication.yml
SangMinLeeAI 85ebdd5
feat: add swagger for UserApi
SangMinLeeAI 7c18771
feat: change user creation logic
SangMinLeeAI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
src/test/kotlin/uoslife/servermeeting/domain/user/service/UserIntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package uoslife.servermeeting.domain.user.service | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.extensions.spring.SpringExtension | ||
import io.kotest.matchers.shouldBe | ||
import io.mockk.mockk | ||
import jakarta.persistence.EntityManager | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest | ||
import org.springframework.test.annotation.Rollback | ||
import uoslife.servermeeting.meetingteam.dao.UserTeamDao | ||
import uoslife.servermeeting.meetingteam.repository.UserTeamRepository | ||
import uoslife.servermeeting.meetingteam.service.BaseMeetingService | ||
import uoslife.servermeeting.meetingteam.util.Validator | ||
import uoslife.servermeeting.payment.service.PaymentService | ||
import uoslife.servermeeting.user.command.UserCommand | ||
import uoslife.servermeeting.user.dao.UserDao | ||
import uoslife.servermeeting.user.entity.User | ||
import uoslife.servermeeting.user.entity.enums.AppearanceType | ||
import uoslife.servermeeting.user.entity.enums.EyelidType | ||
import uoslife.servermeeting.user.entity.enums.SmokingType | ||
import uoslife.servermeeting.user.repository.UserInformationRepository | ||
import uoslife.servermeeting.user.repository.UserRepository | ||
import uoslife.servermeeting.user.service.UserService | ||
|
||
@DataJpaTest(showSql = true) | ||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) | ||
@Rollback(true) | ||
internal class UserIntegrationTest | ||
@Autowired | ||
constructor( | ||
private val userRepository: UserRepository, | ||
private val userTeamRepository: UserTeamRepository, | ||
private val userInformationRepository: UserInformationRepository, | ||
private val entityManager: EntityManager | ||
) : BehaviorSpec() { | ||
|
||
override fun extensions() = listOf(SpringExtension) | ||
init { | ||
val jpaQueryFactory = JPAQueryFactory(entityManager) | ||
val userDao = UserDao(jpaQueryFactory) | ||
val paymentService = mockk<PaymentService>() | ||
val userTeamDao = mockk<UserTeamDao>() | ||
val meetingService = mockk<BaseMeetingService>() | ||
val userService = | ||
UserService( | ||
userRepository = userRepository, | ||
userInformationRepository = userInformationRepository, | ||
paymentService = paymentService, | ||
userTeamRepository = userTeamRepository, | ||
userDao = userDao, | ||
validator = Validator(), | ||
userTeamDao = userTeamDao, | ||
singleMeetingService = meetingService, | ||
tripleMeetingService = meetingService | ||
) | ||
|
||
given("์ ์ ๊ฐ ์์ฑ๋์์๋") { | ||
val savedUser = userRepository.saveAllAndFlush(users) | ||
|
||
`when`("์ ์ info ์ ๋ฐ์ดํธ ์ ๋ณด ์์ฒญ์ด ๋ค์ด์ค๋ฉด") { | ||
then("์ ๋ฐ์ดํธ๋ฅผ ํ๋ค") { | ||
val firstUser = userService.updateUserInformation(initUserInformationCommand) | ||
entityManager.flush() | ||
|
||
firstUser.userInformation?.mbti shouldBe "INTJ" | ||
firstUser.userInformation?.interest shouldBe listOf("์ด๋", "๋ ์") | ||
firstUser.userInformation?.height shouldBe 180 | ||
firstUser.userInformation?.age shouldBe 25 | ||
firstUser.userInformation?.studentNumber shouldBe 2020830018 | ||
firstUser.userInformation?.department shouldBe "์ปดํจํฐ๊ณตํ๊ณผ" | ||
firstUser.userInformation?.eyelidType shouldBe EyelidType.DOUBLE | ||
firstUser.userInformation?.appearanceType shouldBe AppearanceType.ARAB | ||
} | ||
} | ||
`when`("์ ์ ํ๋กํ์ผ ์ ๋ฐ์ดํธ ์์ฒญ์ด ๋ค์ด์ค๋ฉด") { | ||
then("์ ๋ฐ์ดํธ๋ฅผ ํ๋ค") { | ||
val firstUser = | ||
userService.updateUserPersonalInformation(initUserProfileCommand) | ||
entityManager.flush() | ||
|
||
firstUser.name shouldBe "์์ฐ์ง" | ||
firstUser.phoneNumber shouldBe "010-1234-5678" | ||
firstUser.kakaoTalkId shouldBe "seok" | ||
} | ||
} | ||
`when`("์ ์ ์ ๋ณด๊ฐ ์ด๋ฏธ ์์๋") { | ||
userService.updateUserPersonalInformation(initUserProfileCommand) | ||
userService.updateUserInformation(initUserInformationCommand) | ||
|
||
then("userInformation์ ์ ๋ฐ์ดํธํ๋ค") { | ||
val firstUser = | ||
userService.updateUserInformation(updateUserPersonalInformationCommand) | ||
entityManager.flush() | ||
|
||
firstUser.userInformation?.smoking shouldBe SmokingType.E_CIGARETTE | ||
firstUser.userInformation?.mbti shouldBe "ENTP" | ||
firstUser.userInformation?.interest shouldBe listOf("์์", "์ฝ๋ฉ") | ||
firstUser.userInformation?.height shouldBe 185 | ||
firstUser.userInformation?.age shouldBe 23 | ||
firstUser.userInformation?.studentNumber shouldBe 2023830018 | ||
firstUser.userInformation?.department shouldBe "์ ์์ ๊ธฐ์ปดํจํฐ๊ณตํ๋ถ" | ||
firstUser.userInformation?.eyelidType shouldBe EyelidType.SINGLE | ||
firstUser.userInformation?.appearanceType shouldBe AppearanceType.TOFU | ||
} | ||
then("userProfile์ ์ ๋ฐ์ดํธํ๋ค") { | ||
val firstUser = | ||
userService.updateUserPersonalInformation(initUserProfileCommand) | ||
entityManager.flush() | ||
|
||
firstUser.name shouldBe "์์ฐ์ง" | ||
firstUser.phoneNumber shouldBe "010-1234-5678" | ||
firstUser.kakaoTalkId shouldBe "seok" | ||
} | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private val users = | ||
listOf( | ||
User(name = "์์ฐ์ง", email = "[email protected]"), | ||
User(name = "์ต๋์ค", email = "[email protected]"), | ||
) | ||
private val initUserInformationCommand = | ||
UserCommand.UpdateUserInformation( | ||
userId = 1L, | ||
smoking = SmokingType.FALSE, | ||
mbti = "INTJ", | ||
interest = listOf("์ด๋", "๋ ์"), | ||
height = 180, | ||
age = 25, | ||
studentNumber = 2020830018, | ||
department = "์ปดํจํฐ๊ณตํ๊ณผ", | ||
eyelidType = EyelidType.DOUBLE, | ||
appearanceType = AppearanceType.ARAB, | ||
) | ||
private val initUserProfileCommand = | ||
UserCommand.UpdateUserPersonalInformation( | ||
userId = 1L, | ||
name = "์์ฐ์ง", | ||
phoneNumber = "010-1234-5678", | ||
kakaoTalkId = "seok" | ||
) | ||
private val updateUserPersonalInformationCommand = | ||
UserCommand.UpdateUserInformation( | ||
userId = 1L, | ||
smoking = SmokingType.E_CIGARETTE, | ||
mbti = "ENTP", | ||
interest = listOf("์์", "์ฝ๋ฉ"), | ||
height = 185, | ||
age = 23, | ||
studentNumber = 2023830018, | ||
department = "์ ์์ ๊ธฐ์ปดํจํฐ๊ณตํ๋ถ", | ||
eyelidType = EyelidType.SINGLE, | ||
appearanceType = AppearanceType.TOFU, | ||
) | ||
private val updateUserProfileCommand = | ||
UserCommand.UpdateUserPersonalInformation( | ||
userId = 1L, | ||
name = "์์ฐ์ง", | ||
phoneNumber = "010-9006-8420", | ||
kakaoTalkId = "seok" | ||
) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด๊ฑฐ ๋งค๋ฒ ์ฒดํฌํ๊ธฐ๋ณด๋ค, ์ด๋ฉ์ผ๋ก ์ ์ ์์ฑํ ๋, ๋น ๊ฐ์ผ๋ก ๋์์ ๋ง๋ค๊ณ
๋์ค์ user.userinformation ?: throw exception ์ด์ฉํ๋ ๊ฒ ์ด๋ค๊ฐ์?
๋ ํจ์จ์ ์ธ ๊ฒ ๊ฐ์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ํ์ด๋ค