Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ public SolveTrainingPuzzleResponse solveTrainingPuzzle(UserEntity user, Long puz
case "HIGH" -> TRAINING_HIGH_REWARD.getPrice();
default -> 0;
};
if(getReward) user.getReward(reward);
if(getReward){
UserEntity persistentUser = userRepository.findById(user.getId())
.orElseThrow(() -> new CustomException(ErrorCode.CANNOT_FIND_USER));
persistentUser.getReward(reward);
}

return SolveTrainingPuzzleResponse.builder()
.reward(reward)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ public void testSolveLessonPuzzle() {
when(trainingPuzzleRepository.findById(puzzleId))
.thenReturn(Optional.of(trainingPuzzle));

// 사용자 조회 성공 (영속 상태의 엔티티 반환)
when(userRepository.findById(userId))
.thenReturn(Optional.of(user));

// 저장 결과 더미 설정
when(solvedTrainingPuzzleRepository.save(any(SolvedTrainingPuzzle.class)))
.thenAnswer(invocation -> invocation.getArgument(0));
Expand Down