Skip to content

Commit 1eb3c35

Browse files
committed
test(img): 로직 변경에 따른 테스트 코드 수정
1 parent eee5747 commit 1eb3c35

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
package com.somemore.center.service;
1+
package com.somemore.user.service;
22

33
import com.somemore.center.domain.NEWCenter;
4-
import com.somemore.center.dto.request.CenterProfileImgUpdateRequestDto;
54
import com.somemore.center.repository.NEWCenterRepository;
6-
import com.somemore.global.imageupload.usecase.ImageUploadUseCase;
75
import com.somemore.support.IntegrationTestSupport;
86
import com.somemore.user.domain.UserCommonAttribute;
7+
import com.somemore.user.dto.request.ImgUrlRequestDto;
98
import com.somemore.user.repository.usercommonattribute.UserCommonAttributeRepository;
109
import org.junit.jupiter.api.DisplayName;
1110
import org.junit.jupiter.api.Test;
@@ -16,25 +15,22 @@
1615
import java.util.UUID;
1716

1817
import static com.somemore.user.domain.UserRole.CENTER;
19-
import static org.junit.jupiter.api.Assertions.*;
2018
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2120

2221
@Transactional
23-
class UpdateCenterProfileImgServiceTest extends IntegrationTestSupport {
22+
class UpdateProfileImgServiceTest extends IntegrationTestSupport {
2423

2524
@Autowired
26-
private UpdateCenterProfileImgService updateCenterProfileImgService;
27-
28-
@Autowired
29-
private ImageUploadUseCase imageUploadUseCase;
25+
private UpdateProfileImgUrlService updateCenterProfileImgService;
3026

3127
@Autowired
3228
private NEWCenterRepository centerRepository;
3329

3430
@Autowired
3531
private UserCommonAttributeRepository userCommonAttributeRepository;
3632

37-
@DisplayName("파일명을 받아 기관 프로필 이미지의 presignedUrl을 발급해준다.")
33+
@DisplayName("파일명을 받아 프로필 이미지의 presignedUrl을 발급해준다.")
3834
@Test
3935
void updateCenterProfileImg() {
4036

@@ -43,25 +39,19 @@ void updateCenterProfileImg() {
4339

4440
NEWCenter center = NEWCenter.createDefault(userId);
4541
centerRepository.save(center);
46-
UUID centerId = center.getId();
4742

4843
UserCommonAttribute userCommonAttribute = UserCommonAttribute.createDefault(userId, CENTER);
4944
userCommonAttributeRepository.save(userCommonAttribute);
5045

51-
CenterProfileImgUpdateRequestDto requestDto = new CenterProfileImgUpdateRequestDto("test.png");
52-
5346
//when
54-
String presignedUrl = updateCenterProfileImgService.updateCenterProfileImg(centerId, requestDto);
47+
String presignedUrl = updateCenterProfileImgService.update(userId, new ImgUrlRequestDto("test.png"));
5548

5649
//then
5750
assertThat(presignedUrl).isNotNull();
5851

5952
Optional<UserCommonAttribute> updatedUserCommonAttribute = userCommonAttributeRepository.findByUserId(userId);
6053
assertThat(updatedUserCommonAttribute)
6154
.isNotNull();
62-
assertTrue(updatedUserCommonAttribute.get().getImgUrl().contains(requestDto.fileName()));
63-
55+
assertTrue(updatedUserCommonAttribute.get().getImgUrl().contains("test.png"));
6456
}
65-
66-
6757
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.somemore.support.IntegrationTestSupport;
44
import com.somemore.user.domain.UserCommonAttribute;
5-
import com.somemore.user.dto.request.UpdateProfileImgUrlRequestDto;
5+
import com.somemore.user.dto.request.ImgUrlRequestDto;
66
import com.somemore.user.repository.usercommonattribute.UserCommonAttributeRepository;
77
import org.junit.jupiter.api.DisplayName;
88
import org.junit.jupiter.api.Test;
@@ -11,7 +11,8 @@
1111
import java.util.UUID;
1212

1313
import static com.somemore.user.domain.UserRole.CENTER;
14-
import static org.junit.jupiter.api.Assertions.*;
14+
import static org.assertj.core.api.Assertions.assertThat;
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
1516

1617
class UpdateProfileImgUrlServiceTest extends IntegrationTestSupport {
1718

@@ -26,25 +27,24 @@ class UpdateProfileImgUrlServiceTest extends IntegrationTestSupport {
2627

2728
@DisplayName("프로필 이미지 링크를 업데이트 할 수 있다.")
2829
@Test
29-
void updateProfileImgUrl() {
30+
void update() {
3031

3132
// given
3233
UUID userId = UUID.randomUUID();
3334

3435
UserCommonAttribute userCommonAttribute = UserCommonAttribute.createDefault(userId, CENTER);
3536
commonAttributeRepository.save(userCommonAttribute);
3637

37-
String profileImgUrl = "https://example.com/new_profile.jpg";
38-
39-
UpdateProfileImgUrlRequestDto requestDto = new UpdateProfileImgUrlRequestDto(userId, profileImgUrl);
38+
String fileName = "new_profile.jpg";
4039

4140
// when
42-
updateProfileImgUrlService.updateProfileImgUrl(requestDto);
41+
updateProfileImgUrlService.update(userId, new ImgUrlRequestDto(fileName));
4342

4443
// then
4544
UserCommonAttribute updatedUserCommonAttribute = userQueryService.getCommonAttributeByUserId(userId);
4645

47-
assertEquals(profileImgUrl, updatedUserCommonAttribute.getImgUrl());
46+
assertThat(updatedUserCommonAttribute.getImgUrl())
47+
.contains(fileName);
4848

4949
assertEquals(userCommonAttribute.getName(), updatedUserCommonAttribute.getName());
5050
assertEquals(userCommonAttribute.getContactNumber(), updatedUserCommonAttribute.getContactNumber());

0 commit comments

Comments
 (0)