Skip to content

Commit f25b048

Browse files
committed
test(refactor): 테스트 리팩토링
- 소나 큐브 이슈 해결
1 parent b0b3490 commit f25b048

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

src/test/java/com/somemore/user/repository/usercommonattribute/UserCommonAttributeRepositoryImplTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ void saveUserCommonAttribute() {
2929
UserCommonAttribute savedUserCommonAttribute = userCommonAttributeRepository.save(userCommonAttribute);
3030

3131
// then
32-
assertThat(savedUserCommonAttribute).isNotNull();
33-
assertThat(savedUserCommonAttribute).isEqualTo(userCommonAttribute);
32+
assertThat(savedUserCommonAttribute)
33+
.isNotNull()
34+
.isEqualTo(userCommonAttribute);
3435

3536
assertThat(savedUserCommonAttribute.getId()).isNotNull();
3637
assertThat(savedUserCommonAttribute.getUserId()).isEqualTo(userId);
3738
assertThat(savedUserCommonAttribute.getImgUrl()).isEqualTo(ImageUploadService.DEFAULT_IMAGE_URL);
38-
assertThat(savedUserCommonAttribute.isCustomized()).isEqualTo(false);
39+
assertThat(savedUserCommonAttribute.isCustomized()).isFalse();
3940

4041
}
4142
}

src/test/java/com/somemore/user/repository/usersetting/UserSettingRepositoryImplTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ void findByUserId() {
3030
Optional<UserSetting> foundUserSetting = userSettingRepository.findByUserId(userId);
3131

3232
// then
33-
assertThat(foundUserSetting).isNotNull();
34-
assertThat(foundUserSetting).get().isEqualTo(savedUserSetting);
33+
assertThat(foundUserSetting)
34+
.isPresent()
35+
.hasValue(savedUserSetting);
3536
}
3637

3738
@DisplayName("유저 세팅을 저장할 수 있다.")
@@ -47,7 +48,7 @@ void saveUserSetting() {
4748
// then
4849
assertThat(savedUserSetting).isNotNull();
4950
assertThat(savedUserSetting.getId()).isNotNull();
50-
assertThat(savedUserSetting.isAuthenticated()).isEqualTo(false);
51-
assertThat(savedUserSetting.isSmsAgreed()).isEqualTo(false);
51+
assertThat(savedUserSetting.isAuthenticated()).isFalse();
52+
assertThat(savedUserSetting.isSmsAgreed()).isFalse();
5253
}
5354
}

src/test/java/com/somemore/user/service/RegisterUserServiceTest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ class RegisterUserServiceTest extends IntegrationTestSupport {
3737
@Autowired
3838
private UserCommonAttributeRepository userCommonAttributeRepository;
3939

40-
@BeforeEach
41-
void setup() {
42-
}
43-
4440
@DisplayName("OAuth 사용자를 기본 ROLE인 봉사자로 등록할 수 있다.")
4541
@Test
4642
void registerOAuthUser() {
@@ -58,8 +54,8 @@ void registerOAuthUser() {
5854

5955
assertThat(savedUser).isNotNull();
6056
assertThat(savedUser.getRole()).isEqualTo(UserRole.getOAuthUserDefaultRole());
61-
assertThat(savedUser.getEmail().length()).isEqualTo(UUID.randomUUID().toString().length() + provider.getProviderName().length());
62-
57+
assertThat(savedUser.getEmail())
58+
.hasSize(UUID.randomUUID().toString().length() + provider.getProviderName().length());
6359
assertThat(savedSetting).isNotNull();
6460
assertThat(savedSetting.getUserId()).isEqualTo(savedUser.getId());
6561
boolean userDefaultSetting = false;
@@ -68,7 +64,7 @@ void registerOAuthUser() {
6864

6965
assertThat(savedCommonAttribute).isNotNull();
7066
assertThat(savedCommonAttribute.getUserId()).isEqualTo(savedUser.getId());
71-
assertThat(savedCommonAttribute.getNickname().length()).isEqualTo(8);
67+
assertThat(savedCommonAttribute.getNickname()).hasSize(8);
7268
assertThat(savedCommonAttribute.getIntroduce()).isEqualTo("");
7369
assertThat(savedCommonAttribute.getImgUrl()).isEqualTo(ImageUploadService.DEFAULT_IMAGE_URL);
7470
assertThat(savedCommonAttribute.isCustomized()).isEqualTo(userDefaultSetting);
@@ -102,7 +98,7 @@ void registerLocalUser() {
10298

10399
assertThat(savedCommonAttribute).isNotNull();
104100
assertThat(savedCommonAttribute.getUserId()).isEqualTo(savedUser.getId());
105-
assertThat(savedCommonAttribute.getNickname().length()).isEqualTo(8);
101+
assertThat(savedCommonAttribute.getNickname()).hasSize(8);
106102
assertThat(savedCommonAttribute.getIntroduce()).isEqualTo("");
107103
assertThat(savedCommonAttribute.getImgUrl()).isEqualTo(ImageUploadService.DEFAULT_IMAGE_URL);
108104
assertThat(savedCommonAttribute.isCustomized()).isEqualTo(userDefaultSetting);

src/test/java/com/somemore/user/service/UserQueryServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ void getIsCustomizedByUserId_ReturnsFalse_WhenDefaultValue() {
7272
boolean isCustomized = userQueryService.getIsCustomizedByUserId(user.getId());
7373

7474
// then
75-
assertThat(isCustomized).isEqualTo(false);
75+
assertThat(isCustomized).isFalse();
7676
}
7777
}

0 commit comments

Comments
 (0)