From 205de236e267bbf33de5f3a6d094a79eb168292d Mon Sep 17 00:00:00 2001 From: Sangwon Yang Date: Wed, 11 Dec 2024 09:52:35 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=9D=BD=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD=20(#726)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoginUserIdDistributedLockAspect.java | 5 ++++- .../domain/pick/service/PickServiceTest.java | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/backend/techpick-api/src/main/java/techpick/api/infrastructure/lock/util/LoginUserIdDistributedLockAspect.java b/backend/techpick-api/src/main/java/techpick/api/infrastructure/lock/util/LoginUserIdDistributedLockAspect.java index a7901ab49..ed9141a53 100644 --- a/backend/techpick-api/src/main/java/techpick/api/infrastructure/lock/util/LoginUserIdDistributedLockAspect.java +++ b/backend/techpick-api/src/main/java/techpick/api/infrastructure/lock/util/LoginUserIdDistributedLockAspect.java @@ -29,7 +29,10 @@ public Object handleDistributedLock(ProceedingJoinPoint joinPoint, long timeout = loginUserIdDistributedLock.timeout(); Long userId = getUserIdFromArgs(joinPoint); - lockProvider.acquireLock(key, timeout, userId); + boolean lockCheck = lockProvider.acquireLock(key, timeout, userId); + if (!lockCheck) { + throw new LockException("락 설정 실패 : " + key); + } try { return joinPoint.proceed(); diff --git a/backend/techpick-api/src/test/java/techpick/api/domain/pick/service/PickServiceTest.java b/backend/techpick-api/src/test/java/techpick/api/domain/pick/service/PickServiceTest.java index 185dd2d37..81c997c62 100644 --- a/backend/techpick-api/src/test/java/techpick/api/domain/pick/service/PickServiceTest.java +++ b/backend/techpick-api/src/test/java/techpick/api/domain/pick/service/PickServiceTest.java @@ -69,7 +69,8 @@ void setUp( ) { // save test user user = userRepository.save( - User.builder() + User + .builder() .email("test@test.com") .nickname("test") .password("test") @@ -87,9 +88,12 @@ void setUp( general = folderRepository.save(Folder.createEmptyGeneralFolder(user, root, "React.js")); // save tag - tag1 = tagRepository.save(Tag.builder().user(user).name("tag1").colorNumber(1).build()); - tag2 = tagRepository.save(Tag.builder().user(user).name("tag2").colorNumber(1).build()); - tag3 = tagRepository.save(Tag.builder().user(user).name("tag3").colorNumber(1).build()); + tag1 = tagRepository.save(Tag + .builder().user(user).name("tag1").colorNumber(1).build()); + tag2 = tagRepository.save(Tag + .builder().user(user).name("tag2").colorNumber(1).build()); + tag3 = tagRepository.save(Tag + .builder().user(user).name("tag3").colorNumber(1).build()); } @AfterEach @@ -167,9 +171,10 @@ void folder_list_in_pick_list_test() { PickCommand.ReadList readListCommand = pickApiMapper.toReadListCommand(user.getId(), folderIdList); // when - List folderPickList = pickService.getFolderListChildPickList(readListCommand); + List folderPickList = pickService.getFolderListChildPickList( + readListCommand); - for (PickResult.FolderPickList list : folderPickList) { + for (PickResult.FolderPickWithViewCountList list : folderPickList) { log.info("list: {} ", list.toString()); } @@ -293,7 +298,7 @@ void update_data_with_null_test() { // then assertThat(updatePick.title()).isNotEqualTo(savePick.title()).isEqualTo(newTitle); // changed assertThat(updatePick.tagIdOrderedList()).isNotEqualTo(savePick.tagIdOrderedList()) - .isEqualTo(newTagOrder); // changed + .isEqualTo(newTagOrder); // changed } }