From 6650784551d92897620816c2290d93929fac70de Mon Sep 17 00:00:00 2001 From: sangminnim Date: Tue, 19 Dec 2023 20:57:29 +0900 Subject: [PATCH 01/74] =?UTF-8?q?feat:=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EC=8B=9C=20=EC=9C=A0=EC=A0=80=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/matching/exception/MatchingErrorCode.java | 1 + .../server/matching/service/MatchingService.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/coffeemeet/server/matching/exception/MatchingErrorCode.java b/src/main/java/coffeemeet/server/matching/exception/MatchingErrorCode.java index ab83b74a..8ec2b15a 100644 --- a/src/main/java/coffeemeet/server/matching/exception/MatchingErrorCode.java +++ b/src/main/java/coffeemeet/server/matching/exception/MatchingErrorCode.java @@ -9,6 +9,7 @@ @RequiredArgsConstructor public enum MatchingErrorCode implements ErrorCode { NOT_CERTIFICATED_USER("M003", "인증되지 않은 사용자입니다."), + INVALID_USER_STATUS("M000", "올바르지 않은 유저 상태입니다."), ; private final String errorCode; diff --git a/src/main/java/coffeemeet/server/matching/service/MatchingService.java b/src/main/java/coffeemeet/server/matching/service/MatchingService.java index cec65618..f6fb053d 100644 --- a/src/main/java/coffeemeet/server/matching/service/MatchingService.java +++ b/src/main/java/coffeemeet/server/matching/service/MatchingService.java @@ -1,13 +1,19 @@ package coffeemeet.server.matching.service; +import static coffeemeet.server.matching.exception.MatchingErrorCode.INVALID_USER_STATUS; +import static coffeemeet.server.user.domain.UserStatus.MATCHING; + import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; +import coffeemeet.server.common.execption.BadRequestException; import coffeemeet.server.common.implement.FCMNotificationSender; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.matching.implement.MatchingQueueQuery; import coffeemeet.server.user.domain.NotificationInfo; +import coffeemeet.server.user.domain.User; +import coffeemeet.server.user.domain.UserStatus; import coffeemeet.server.user.implement.UserCommand; import coffeemeet.server.user.implement.UserQuery; import java.util.Set; @@ -57,6 +63,11 @@ private void processMatching(String companyName) { } public void cancelMatching(Long userId) { + User user = userQuery.getUserById(userId); + if (user.getUserStatus() != MATCHING) { + throw new BadRequestException(INVALID_USER_STATUS, + String.format("유저 상태가 %s이 아닙니다.", MATCHING)); + } String companyName = certificationQuery.getCompanyNameByUserId(userId); matchingQueueCommand.deleteUserByUserId(companyName, userId); userCommand.setToIdle(userId); From 55b9b832dc2a66a46123b2e1811b32132ccbb524 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Tue, 19 Dec 2023 22:27:33 +0900 Subject: [PATCH 02/74] =?UTF-8?q?style:=20=ED=8F=AC=EB=A7=B7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/coffeemeet/server/matching/service/MatchingService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/coffeemeet/server/matching/service/MatchingService.java b/src/main/java/coffeemeet/server/matching/service/MatchingService.java index f6fb053d..3e3fc23c 100644 --- a/src/main/java/coffeemeet/server/matching/service/MatchingService.java +++ b/src/main/java/coffeemeet/server/matching/service/MatchingService.java @@ -13,7 +13,6 @@ import coffeemeet.server.matching.implement.MatchingQueueQuery; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.domain.UserStatus; import coffeemeet.server.user.implement.UserCommand; import coffeemeet.server.user.implement.UserQuery; import java.util.Set; From 4490ac38af4198185240e5be0ebc601af03c5141 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Tue, 19 Dec 2023 22:28:28 +0900 Subject: [PATCH 03/74] =?UTF-8?q?test:=20=EB=A9=94=EC=9D=B8=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EC=8B=A4=ED=8C=A8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/fixture/entity/UserFixture.java | 10 +++++++ .../matching/service/MatchingServiceTest.java | 30 +++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java index 1e79d1cb..6a424686 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java @@ -33,6 +33,16 @@ public static User user(UserStatus userStatus) { .create(); } + public static User userExcludingStatus(UserStatus excludingStatus) { + return Instancio.of(User.class).set(field(User::getProfile), profile()) + .generate(field(User::getUserStatus), + gen -> gen.enumOf(UserStatus.class).excluding(excludingStatus)) + .ignore(field(User::isDeleted)) + .ignore(field(User::isBlacklisted)) + .ignore(field(User::getChattingRoom)) + .create(); + } + public static List users() { return Instancio.ofList(User.class) .generate(field(User::getId), gen -> gen.longSeq().start(1L)) diff --git a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java index 5dc80fa3..c18357ef 100644 --- a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java +++ b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java @@ -3,6 +3,10 @@ import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificatedCertifications; import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingRoom; import static coffeemeet.server.common.fixture.entity.UserFixture.fourUsers; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.entity.UserFixture.userExcludingStatus; +import static coffeemeet.server.user.domain.UserStatus.MATCHING; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willDoNothing; @@ -12,6 +16,7 @@ import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; +import coffeemeet.server.common.execption.BadRequestException; import coffeemeet.server.common.implement.FCMNotificationSender; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.matching.implement.MatchingQueueQuery; @@ -98,17 +103,32 @@ void startTest() { @DisplayName("매칭을 취소할 수 있다.") void cancelMatching() { // given - Long userId = 1L; + User user = user(MATCHING); String companyName = "회사명"; - given(certificationQuery.getCompanyNameByUserId(userId)).willReturn(companyName); - willDoNothing().given(matchingQueueCommand).deleteUserByUserId(companyName, userId); + given(userQuery.getUserById(user.getId())).willReturn(user); + given(certificationQuery.getCompanyNameByUserId(user.getId())).willReturn(companyName); + willDoNothing().given(matchingQueueCommand).deleteUserByUserId(companyName, user.getId()); // when - matchingService.cancelMatching(userId); + matchingService.cancelMatching(user.getId()); // then - then(userCommand).should(only()).setToIdle(userId); + then(userCommand).should(only()).setToIdle(user.getId()); + } + + @Test + @DisplayName("매칭을 취소할 수 있다.") + void cancelMatching_BadException() { + // given + User user = userExcludingStatus(MATCHING); + Long userId = user.getId(); + + given(userQuery.getUserById(userId)).willReturn(user); + + // when, then + assertThatThrownBy(() -> matchingService.cancelMatching(userId)) + .isInstanceOf(BadRequestException.class); } } From d3e3631c19e905362312469136b25dce61e69011 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:46:27 +0900 Subject: [PATCH 04/74] =?UTF-8?q?refactor:=20infra=20->=20domain=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Verification.java => VerificationInfo.java} | 12 ++++++------ .../repository}/CertificationRepository.java | 4 +++- .../repository/VerificationInfoRepository.java | 8 ++++++++ .../EmailVerificationRepository.java | 8 -------- .../server/common/domain/ObjectStorage.java | 17 +++++++++++++++++ .../domain/{KeyType.java => S3KeyPrefix.java} | 4 ++-- .../server/common/implement/MediaManager.java | 18 ------------------ .../EmailSender.java | 15 ++++++--------- .../FCMNotificationSender.java | 2 +- .../S3ObjectStorage.java} | 17 +++++++++-------- 10 files changed, 52 insertions(+), 53 deletions(-) rename src/main/java/coffeemeet/server/certification/domain/{EmailVerification.java => VerificationInfo.java} (60%) rename src/main/java/coffeemeet/server/certification/{infrastructure => domain/repository}/CertificationRepository.java (88%) create mode 100644 src/main/java/coffeemeet/server/certification/domain/repository/VerificationInfoRepository.java delete mode 100644 src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java create mode 100644 src/main/java/coffeemeet/server/common/domain/ObjectStorage.java rename src/main/java/coffeemeet/server/common/domain/{KeyType.java => S3KeyPrefix.java} (78%) delete mode 100644 src/main/java/coffeemeet/server/common/implement/MediaManager.java rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/EmailSender.java (57%) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/FCMNotificationSender.java (98%) rename src/main/java/coffeemeet/server/common/{implement/S3MediaManager.java => infrastructure/S3ObjectStorage.java} (72%) diff --git a/src/main/java/coffeemeet/server/certification/domain/EmailVerification.java b/src/main/java/coffeemeet/server/certification/domain/VerificationInfo.java similarity index 60% rename from src/main/java/coffeemeet/server/certification/domain/EmailVerification.java rename to src/main/java/coffeemeet/server/certification/domain/VerificationInfo.java index 25e6350f..0175de56 100644 --- a/src/main/java/coffeemeet/server/certification/domain/EmailVerification.java +++ b/src/main/java/coffeemeet/server/certification/domain/VerificationInfo.java @@ -7,20 +7,20 @@ import org.springframework.data.redis.core.RedisHash; @Getter -@RedisHash(value = "email_verification", timeToLive = 360) -public class EmailVerification { +@RedisHash(value = "email_verification", timeToLive = 300) +public class VerificationInfo { @Id private Long userId; private CompanyEmail companyEmail; - private String code; + private String verificationCode; private LocalDateTime createdAt; - public EmailVerification(@NonNull Long userId, @NonNull CompanyEmail companyEmail, - @NonNull String code) { + public VerificationInfo(@NonNull Long userId, @NonNull CompanyEmail companyEmail, + @NonNull String verificationCode) { this.userId = userId; this.companyEmail = companyEmail; - this.code = code; + this.verificationCode = verificationCode; this.createdAt = LocalDateTime.now(); } diff --git a/src/main/java/coffeemeet/server/certification/infrastructure/CertificationRepository.java b/src/main/java/coffeemeet/server/certification/domain/repository/CertificationRepository.java similarity index 88% rename from src/main/java/coffeemeet/server/certification/infrastructure/CertificationRepository.java rename to src/main/java/coffeemeet/server/certification/domain/repository/CertificationRepository.java index fc66d649..25fba069 100644 --- a/src/main/java/coffeemeet/server/certification/infrastructure/CertificationRepository.java +++ b/src/main/java/coffeemeet/server/certification/domain/repository/CertificationRepository.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.infrastructure; +package coffeemeet.server.certification.domain.repository; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; @@ -14,6 +14,8 @@ public interface CertificationRepository extends JpaRepository findPendingCertifications(Pageable pageable); diff --git a/src/main/java/coffeemeet/server/certification/domain/repository/VerificationInfoRepository.java b/src/main/java/coffeemeet/server/certification/domain/repository/VerificationInfoRepository.java new file mode 100644 index 00000000..88715223 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/domain/repository/VerificationInfoRepository.java @@ -0,0 +1,8 @@ +package coffeemeet.server.certification.domain.repository; + +import coffeemeet.server.certification.domain.VerificationInfo; +import org.springframework.data.repository.CrudRepository; + +public interface VerificationInfoRepository extends CrudRepository { + +} diff --git a/src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java b/src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java deleted file mode 100644 index b236bf43..00000000 --- a/src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package coffeemeet.server.certification.infrastructure; - -import coffeemeet.server.certification.domain.EmailVerification; -import org.springframework.data.repository.CrudRepository; - -public interface EmailVerificationRepository extends CrudRepository { - -} diff --git a/src/main/java/coffeemeet/server/common/domain/ObjectStorage.java b/src/main/java/coffeemeet/server/common/domain/ObjectStorage.java new file mode 100644 index 00000000..98b3681c --- /dev/null +++ b/src/main/java/coffeemeet/server/common/domain/ObjectStorage.java @@ -0,0 +1,17 @@ +package coffeemeet.server.common.domain; + +import java.io.File; + +public interface ObjectStorage { + + void upload(String key, File file); + + void delete(String key); + + String getUrl(String key); + + String generateKey(S3KeyPrefix s3KeyPrefix); + + String extractKey(String url, S3KeyPrefix s3KeyPrefix); + +} diff --git a/src/main/java/coffeemeet/server/common/domain/KeyType.java b/src/main/java/coffeemeet/server/common/domain/S3KeyPrefix.java similarity index 78% rename from src/main/java/coffeemeet/server/common/domain/KeyType.java rename to src/main/java/coffeemeet/server/common/domain/S3KeyPrefix.java index 686e0514..a1c8dfc2 100644 --- a/src/main/java/coffeemeet/server/common/domain/KeyType.java +++ b/src/main/java/coffeemeet/server/common/domain/S3KeyPrefix.java @@ -3,7 +3,7 @@ import lombok.Getter; @Getter -public enum KeyType { +public enum S3KeyPrefix { BUSINESS_CARD("business-card"), PROFILE_IMAGE("profile-image"), @@ -11,7 +11,7 @@ public enum KeyType { private final String value; - KeyType(String value) { + S3KeyPrefix(String value) { this.value = value; } diff --git a/src/main/java/coffeemeet/server/common/implement/MediaManager.java b/src/main/java/coffeemeet/server/common/implement/MediaManager.java deleted file mode 100644 index e189139a..00000000 --- a/src/main/java/coffeemeet/server/common/implement/MediaManager.java +++ /dev/null @@ -1,18 +0,0 @@ -package coffeemeet.server.common.implement; - -import coffeemeet.server.common.domain.KeyType; -import java.io.File; - -public interface MediaManager { - - void upload(String key, File file); - - void delete(String key); - - String getUrl(String key); - - String generateKey(KeyType keyType); - - String extractKey(String s3Url, KeyType keyType); - -} diff --git a/src/main/java/coffeemeet/server/common/implement/EmailSender.java b/src/main/java/coffeemeet/server/common/infrastructure/EmailSender.java similarity index 57% rename from src/main/java/coffeemeet/server/common/implement/EmailSender.java rename to src/main/java/coffeemeet/server/common/infrastructure/EmailSender.java index 17a308be..0aad34de 100644 --- a/src/main/java/coffeemeet/server/common/implement/EmailSender.java +++ b/src/main/java/coffeemeet/server/common/infrastructure/EmailSender.java @@ -1,6 +1,5 @@ -package coffeemeet.server.common.implement; +package coffeemeet.server.common.infrastructure; -import coffeemeet.server.certification.domain.CompanyEmail; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; @@ -18,18 +17,16 @@ public EmailSender(JavaMailSender javaMailSender, this.sender = sender; } - public void sendVerificationCode(CompanyEmail companyMail, String verificationCode) { + public void sendEmail(String email, String subject, String body) { SimpleMailMessage mailMessage = new SimpleMailMessage(); + mailMessage.setFrom(sender); - mailMessage.setTo(companyMail.getValue()); + mailMessage.setTo(email); - String subject = "[coffee-meet] 커피밋 사용을 위해 이메일 인증을 완료해주세요"; mailMessage.setSubject(subject); + mailMessage.setText(body); - String text = String.format("인증코드: %s", verificationCode); - mailMessage.setText(text); - - javaMailSender.send(mailMessage); + javaMailSender.send(mailMessage); // TODO: 2023/12/19 에러 핸들링 및 비동기처리 } } diff --git a/src/main/java/coffeemeet/server/common/implement/FCMNotificationSender.java b/src/main/java/coffeemeet/server/common/infrastructure/FCMNotificationSender.java similarity index 98% rename from src/main/java/coffeemeet/server/common/implement/FCMNotificationSender.java rename to src/main/java/coffeemeet/server/common/infrastructure/FCMNotificationSender.java index caba71b6..e28f70ac 100644 --- a/src/main/java/coffeemeet/server/common/implement/FCMNotificationSender.java +++ b/src/main/java/coffeemeet/server/common/infrastructure/FCMNotificationSender.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.implement; +package coffeemeet.server.common.infrastructure; import static coffeemeet.server.common.execption.GlobalErrorCode.INVALID_FCM_TOKEN; import static coffeemeet.server.common.execption.GlobalErrorCode.PUSH_NOTIFICATION_SEND_FAILURE; diff --git a/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java b/src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java similarity index 72% rename from src/main/java/coffeemeet/server/common/implement/S3MediaManager.java rename to src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java index 9bf8ecba..12b6adda 100644 --- a/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java +++ b/src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java @@ -1,6 +1,7 @@ -package coffeemeet.server.common.implement; +package coffeemeet.server.common.infrastructure; -import coffeemeet.server.common.domain.KeyType; +import coffeemeet.server.common.domain.S3KeyPrefix; +import coffeemeet.server.common.domain.ObjectStorage; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.s3.AmazonS3; import java.io.File; @@ -12,12 +13,12 @@ @Slf4j @Component -public class S3MediaManager implements MediaManager { +public class S3ObjectStorage implements ObjectStorage { private final AmazonS3 amazonS3; private final String bucketName; - public S3MediaManager( + public S3ObjectStorage( AmazonS3 amazonS3, @Value("${cloud.aws.s3.bucket}") String bucketName ) { @@ -49,14 +50,14 @@ public String getUrl(String key) { } @Override - public String generateKey(KeyType keyType) { - return String.format("%s-%s-%s", keyType.getValue(), LocalDateTime.now(), + public String generateKey(S3KeyPrefix s3KeyPrefix) { + return String.format("%s-%s-%s", s3KeyPrefix.getValue(), LocalDateTime.now(), UUID.randomUUID()); } @Override - public String extractKey(String s3Url, KeyType keyType) { - int startIndex = s3Url.indexOf(keyType.getValue()); + public String extractKey(String s3Url, S3KeyPrefix s3KeyPrefix) { + int startIndex = s3Url.indexOf(s3KeyPrefix.getValue()); if (startIndex == -1) { return ""; } From faed8c5c49fed48cd54efe26512ab35c0104990d Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:47:41 +0900 Subject: [PATCH 05/74] =?UTF-8?q?feat:=20ObjectStorage=20impl=20=EA=B3=84?= =?UTF-8?q?=EC=B8=B5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/implement/ImageDeleter.java | 19 +++++++++++++++ .../common/implement/ImageUploader.java | 23 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/coffeemeet/server/common/implement/ImageDeleter.java create mode 100644 src/main/java/coffeemeet/server/common/implement/ImageUploader.java diff --git a/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java b/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java new file mode 100644 index 00000000..e8e6fa4f --- /dev/null +++ b/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java @@ -0,0 +1,19 @@ +package coffeemeet.server.common.implement; + +import coffeemeet.server.common.domain.S3KeyPrefix; +import coffeemeet.server.common.domain.ObjectStorage; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class ImageDeleter { + + private final ObjectStorage objectStorage; + + public void deleteImage(String imageUrl, S3KeyPrefix s3KeyPrefix) { + String key = objectStorage.extractKey(imageUrl, s3KeyPrefix); + objectStorage.delete(key); + } + +} diff --git a/src/main/java/coffeemeet/server/common/implement/ImageUploader.java b/src/main/java/coffeemeet/server/common/implement/ImageUploader.java new file mode 100644 index 00000000..479049ec --- /dev/null +++ b/src/main/java/coffeemeet/server/common/implement/ImageUploader.java @@ -0,0 +1,23 @@ +package coffeemeet.server.common.implement; + +import coffeemeet.server.common.domain.S3KeyPrefix; +import coffeemeet.server.common.domain.ObjectStorage; +import coffeemeet.server.common.util.FileUtils; +import java.io.File; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class ImageUploader { + + private final ObjectStorage objectStorage; + + public String uploadImage(File image, S3KeyPrefix s3KeyPrefix) { + String key = objectStorage.generateKey(s3KeyPrefix); + objectStorage.upload(key, image); + FileUtils.deleteTempFile(image); + return objectStorage.getUrl(key); + } + +} From d8dbdad90a27bb985059a717ed98772b073a17f1 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:48:25 +0900 Subject: [PATCH 06/74] =?UTF-8?q?feat:=20update=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../certification/domain/Certification.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/domain/Certification.java b/src/main/java/coffeemeet/server/certification/domain/Certification.java index 7bd4b07e..a7cecd9d 100644 --- a/src/main/java/coffeemeet/server/certification/domain/Certification.java +++ b/src/main/java/coffeemeet/server/certification/domain/Certification.java @@ -34,17 +34,16 @@ public class Certification extends AdvancedBaseEntity { @Column(nullable = false) private String companyName; - @Embedded + @Enumerated(EnumType.STRING) @Column(nullable = false) + private Department department; + + @Embedded private CompanyEmail companyEmail; @Column(nullable = false) private String businessCardUrl; - @Enumerated(EnumType.STRING) - @Column(nullable = false) - private Department department; - @Column(nullable = false) private boolean isCertificated; @@ -64,4 +63,12 @@ public void qualify() { isCertificated = true; } + public void update(String companyName, CompanyEmail companyEmail, String businessCardUrl, + Department department) { + this.companyName = companyName; + this.companyEmail = companyEmail; + this.businessCardUrl = businessCardUrl; + this.department = department; + } + } From b7dd4e7a3ef131c64dc70ecd9db1f0d8089846f3 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:51:02 +0900 Subject: [PATCH 07/74] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/admin/service/AdminService.java | 6 +++--- .../current/service/ChattingMessageService.java | 2 +- .../current/service/ChattingRoomService.java | 2 +- .../server/matching/service/MatchingService.java | 2 +- .../server/user/service/UserService.java | 16 ++++++++-------- .../admin/presentation/AdminControllerTest.java | 4 ++-- .../ChattingMessageServiceConcurrencyTest.java | 2 +- .../service/ChattingMessageServiceTest.java | 2 +- .../current/service/ChattingRoomServiceTest.java | 2 +- .../implement/FCMNotificationSenderTest.java | 1 + .../matching/service/MatchingServiceTest.java | 2 +- .../server/user/service/UserServiceTest.java | 12 ++++++------ 12 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/main/java/coffeemeet/server/admin/service/AdminService.java b/src/main/java/coffeemeet/server/admin/service/AdminService.java index 3b8e8358..e97ebf76 100644 --- a/src/main/java/coffeemeet/server/admin/service/AdminService.java +++ b/src/main/java/coffeemeet/server/admin/service/AdminService.java @@ -5,7 +5,7 @@ import coffeemeet.server.admin.implement.AdminQuery; import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.inquiry.implement.InquiryCommand; import coffeemeet.server.inquiry.implement.InquiryQuery; @@ -38,7 +38,7 @@ public void login(String id, String password) { } public void approveCertification(Long certificationId) { - certificationCommand.certificated(certificationId); + certificationCommand.completeCertification(certificationId); Long userId = certificationQuery.getUserIdByCertificationId(certificationId); NotificationInfo notificationInfo = userQuery.getNotificationInfoByUserId(userId); @@ -48,7 +48,7 @@ public void approveCertification(Long certificationId) { } public void rejectCertification(Long certificationId) { - certificationCommand.deleteCertification(certificationId); + certificationCommand.deleteCertificationByUserId(certificationId); Long userId = certificationQuery.getUserIdByCertificationId(certificationId); NotificationInfo notificationInfo = userQuery.getNotificationInfoByUserId(userId); diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java index 057f3b3f..1967c4ca 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java @@ -7,7 +7,7 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.domain.UserStatus; diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java index 6e9add89..af7fc722 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java @@ -14,7 +14,7 @@ import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryCommand; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryCommand; import coffeemeet.server.chatting.history.implement.UserChattingHistoryCommand; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; diff --git a/src/main/java/coffeemeet/server/matching/service/MatchingService.java b/src/main/java/coffeemeet/server/matching/service/MatchingService.java index 3e3fc23c..df10a127 100644 --- a/src/main/java/coffeemeet/server/matching/service/MatchingService.java +++ b/src/main/java/coffeemeet/server/matching/service/MatchingService.java @@ -8,7 +8,7 @@ import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.common.execption.BadRequestException; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.matching.implement.MatchingQueueQuery; import coffeemeet.server.user.domain.NotificationInfo; diff --git a/src/main/java/coffeemeet/server/user/service/UserService.java b/src/main/java/coffeemeet/server/user/service/UserService.java index aba959e9..11cba705 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.service; -import static coffeemeet.server.common.domain.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.domain.S3KeyPrefix.PROFILE_IMAGE; import static coffeemeet.server.common.execption.GlobalErrorCode.BAD_REQUEST_ERROR; import static coffeemeet.server.oauth.utils.constant.OAuthConstant.DEFAULT_IMAGE_URL; @@ -8,8 +8,8 @@ import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.implement.CertificationQuery; +import coffeemeet.server.common.domain.ObjectStorage; import coffeemeet.server.common.execption.BadRequestException; -import coffeemeet.server.common.implement.MediaManager; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; @@ -41,7 +41,7 @@ public class UserService { private static final String INVALID_REQUEST_MESSAGE = "사용자 상태에 맞지 않는 요청입니다."; - private final MediaManager mediaManager; + private final ObjectStorage objectStorage; private final OAuthMemberClientComposite oAuthMemberClientComposite; private final CertificationQuery certificationQuery; @@ -99,9 +99,9 @@ public void updateProfileImage(Long userId, File file) { User user = userQuery.getUserById(userId); deleteCurrentProfileImage(user.getOauthInfo().getProfileImageUrl()); - String key = mediaManager.generateKey(PROFILE_IMAGE); - mediaManager.upload(key, file); - user.updateProfileImageUrl(mediaManager.getUrl(key)); + String key = objectStorage.generateKey(PROFILE_IMAGE); + objectStorage.upload(key, file); + user.updateProfileImageUrl(objectStorage.getUrl(key)); userCommand.updateUser(user); } @@ -172,12 +172,12 @@ private UserStatusDto handleReportedUser(User user) { private void deleteCurrentProfileImage(String profileImageUrl) { if (!profileImageUrl.equals(DEFAULT_IMAGE_URL)) { - String currentKey = mediaManager.extractKey(profileImageUrl, + String currentKey = objectStorage.extractKey(profileImageUrl, PROFILE_IMAGE); if (currentKey.isBlank()) { return; } - mediaManager.delete(currentKey); + objectStorage.delete(currentKey); } } diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index aad7dbfe..bbd39758 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -3,7 +3,7 @@ import static coffeemeet.server.common.fixture.entity.AdminFixture.adminLoginHTTPRequest; import static coffeemeet.server.common.fixture.entity.AdminFixture.reportApprovalHTTPRequest; import static coffeemeet.server.common.fixture.entity.AdminFixture.reportRejectionHTTPRequest; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPageDto; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; @@ -468,7 +468,7 @@ void viewInquiryTest() throws Exception { @DisplayName("회사 인증 대기중인 목록을 조회할 수 있다.") void getPendingCertificationsTest() throws Exception { // given - Pageable pageable = pageable(); + Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); Page page = pendingCertificationPageDto.page(); diff --git a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java index 145bc4bf..78d322cf 100644 --- a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java +++ b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java @@ -11,7 +11,7 @@ import coffeemeet.server.chatting.current.service.ChattingMessageService; import coffeemeet.server.common.fixture.entity.ChattingFixture; import coffeemeet.server.common.fixture.entity.UserFixture; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import java.util.List; diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index ae3f50da..9f6eade5 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -20,7 +20,7 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserCommand; import coffeemeet.server.user.implement.UserQuery; diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java index 7b49d2df..30056a42 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java @@ -21,7 +21,7 @@ import coffeemeet.server.chatting.history.implement.UserChattingHistoryCommand; import coffeemeet.server.common.fixture.entity.ChattingFixture; import coffeemeet.server.common.fixture.entity.UserFixture; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; import java.util.List; diff --git a/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java b/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java index 2dc327a9..5f93c06c 100644 --- a/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java @@ -8,6 +8,7 @@ import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.only; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import com.google.firebase.messaging.FirebaseMessaging; import com.google.firebase.messaging.FirebaseMessagingException; diff --git a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java index c18357ef..bf987355 100644 --- a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java +++ b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java @@ -17,7 +17,7 @@ import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.common.execption.BadRequestException; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.matching.implement.MatchingQueueQuery; import coffeemeet.server.user.domain.NotificationInfo; diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index 595b53e8..9b2a27a0 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.service; -import static coffeemeet.server.common.domain.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.domain.S3KeyPrefix.PROFILE_IMAGE; import static coffeemeet.server.common.fixture.dto.AuthTokensFixture.authTokens; import static coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture.response; import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; @@ -30,9 +30,9 @@ import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.implement.CertificationQuery; +import coffeemeet.server.common.domain.ObjectStorage; import coffeemeet.server.common.fixture.dto.SignupHTTPFixture; import coffeemeet.server.common.fixture.entity.UserFixture; -import coffeemeet.server.common.implement.MediaManager; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; @@ -68,7 +68,7 @@ class UserServiceTest { private UserService userService; @Mock - private MediaManager mediaManager; + private ObjectStorage objectStorage; @Mock private OAuthMemberClientComposite oAuthMemberClientComposite; @@ -227,9 +227,9 @@ void updateProfileImage() throws IOException { File file = File.createTempFile("temp", "png"); given(userQuery.getUserById(anyLong())).willReturn(user); - given(mediaManager.generateKey(PROFILE_IMAGE)).willReturn("key"); - given(mediaManager.getUrl(anyString())).willReturn("newImageUrl"); - given(mediaManager.extractKey(any(), eq(PROFILE_IMAGE))).willReturn(""); + given(objectStorage.generateKey(PROFILE_IMAGE)).willReturn("key"); + given(objectStorage.getUrl(anyString())).willReturn("newImageUrl"); + given(objectStorage.extractKey(any(), eq(PROFILE_IMAGE))).willReturn(""); // when userService.updateProfileImage(user.getId(), file); From c90bcfd3a3f3ee51b1029275e851f04ac89baeb5 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:51:37 +0900 Subject: [PATCH 08/74] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coffeemeet/server/admin/service/AdminServiceTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java b/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java index ae616882..3519df12 100644 --- a/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java +++ b/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java @@ -15,7 +15,7 @@ import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.common.fixture.entity.InquiryFixture; -import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.inquiry.implement.InquiryCommand; import coffeemeet.server.inquiry.implement.InquiryQuery; @@ -92,7 +92,7 @@ void approveCertificationTest() { adminService.approveCertification(certificationId); // then - then(certificationCommand).should(only()).certificated(certificationId); + then(certificationCommand).should(only()).completeCertification(certificationId); then(userQuery).should(only()).getNotificationInfoByUserId(userId); then(fcmNotificationSender).should(only()).sendNotification(any(), any()); } @@ -109,7 +109,7 @@ void rejectCertificationTest() { adminService.rejectCertification(certificationId); // then - then(certificationCommand).should(only()).deleteCertification(certificationId); + then(certificationCommand).should(only()).deleteCertificationByUserId(certificationId); then(certificationQuery).should(only()).getUserIdByCertificationId(certificationId); then(userQuery).should(only()).getNotificationInfoByUserId(certificationId); then(fcmNotificationSender).should(only()).sendNotification(any(), any()); From 67aac13a01bb6a2c720c1c625880cca96401ec8a Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:52:25 +0900 Subject: [PATCH 09/74] =?UTF-8?q?feat:=20BusinessCardImage=20impl=20?= =?UTF-8?q?=EA=B3=84=EC=B8=B5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implement/BusinessCardImageDeleter.java | 22 +++++++++++++++++++ .../implement/BusinessCardImageUploader.java | 20 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/coffeemeet/server/certification/implement/BusinessCardImageDeleter.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/BusinessCardImageUploader.java diff --git a/src/main/java/coffeemeet/server/certification/implement/BusinessCardImageDeleter.java b/src/main/java/coffeemeet/server/certification/implement/BusinessCardImageDeleter.java new file mode 100644 index 00000000..95b727d0 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/BusinessCardImageDeleter.java @@ -0,0 +1,22 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.domain.S3KeyPrefix.BUSINESS_CARD; + +import coffeemeet.server.certification.domain.Certification; +import coffeemeet.server.common.implement.ImageDeleter; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class BusinessCardImageDeleter { + + private final CertificationQuery certificationQuery; + private final ImageDeleter imageDeleter; + + public void deleteBusinessCardImageByUserId(Long userId) { + Certification certification = certificationQuery.getCertificationByUserId(userId); + imageDeleter.deleteImage(certification.getBusinessCardUrl(), BUSINESS_CARD); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/BusinessCardImageUploader.java b/src/main/java/coffeemeet/server/certification/implement/BusinessCardImageUploader.java new file mode 100644 index 00000000..fcd9bffc --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/BusinessCardImageUploader.java @@ -0,0 +1,20 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.domain.S3KeyPrefix.BUSINESS_CARD; + +import coffeemeet.server.common.implement.ImageUploader; +import java.io.File; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class BusinessCardImageUploader { + + private final ImageUploader imageUploader; + + public String uploadBusinessCardImage(File businessCardImage) { + return imageUploader.uploadImage(businessCardImage, BUSINESS_CARD); + } + +} From 22f3afa353805580bf55359a1187fe36d098ea51 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:52:47 +0900 Subject: [PATCH 10/74] =?UTF-8?q?feat:=20Email=20=EC=9D=B8=EC=A6=9D=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20impl=20=EA=B3=84=EC=B8=B5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implement/CompanyEmailValidator.java | 25 +++++++++++++++++++ .../implement/VerificationCodeGenerator.java | 15 +++++++++++ .../implement/VerificationCodeValidator.java | 20 +++++++++++++++ .../implement/VerificationMailSender.java | 22 ++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 src/main/java/coffeemeet/server/certification/implement/CompanyEmailValidator.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/VerificationCodeGenerator.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/VerificationCodeValidator.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/VerificationMailSender.java diff --git a/src/main/java/coffeemeet/server/certification/implement/CompanyEmailValidator.java b/src/main/java/coffeemeet/server/certification/implement/CompanyEmailValidator.java new file mode 100644 index 00000000..d0a353dd --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/CompanyEmailValidator.java @@ -0,0 +1,25 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.certification.exception.CertificationErrorCode.EXISTED_COMPANY_EMAIL; + +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.common.execption.InvalidInputException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class CompanyEmailValidator { + + private static final String EXISTED_COMPANY_EMAIL_MESSAGE = "이미 사용 중인 회사 이메일(%s) 입니다."; + + private final CertificationQuery certificationQuery; + + public void validateDuplicatedCompanyEmail(CompanyEmail companyEmail) { + if (certificationQuery.isExistedCompanyEmail(companyEmail)) { + throw new InvalidInputException(EXISTED_COMPANY_EMAIL, + String.format(EXISTED_COMPANY_EMAIL_MESSAGE, companyEmail.getValue())); + } + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/VerificationCodeGenerator.java b/src/main/java/coffeemeet/server/certification/implement/VerificationCodeGenerator.java new file mode 100644 index 00000000..596f58e6 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/VerificationCodeGenerator.java @@ -0,0 +1,15 @@ +package coffeemeet.server.certification.implement; + +import java.util.random.RandomGenerator; +import org.springframework.stereotype.Component; + +@Component +public class VerificationCodeGenerator { + + private static final RandomGenerator RANDOM_GENERATOR = RandomGenerator.getDefault(); + + public String generateVerificationCode() { + return String.format("%06d", RANDOM_GENERATOR.nextInt(1000000)); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/VerificationCodeValidator.java b/src/main/java/coffeemeet/server/certification/implement/VerificationCodeValidator.java new file mode 100644 index 00000000..bfefeca0 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/VerificationCodeValidator.java @@ -0,0 +1,20 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; + +import coffeemeet.server.common.execption.InvalidInputException; +import org.springframework.stereotype.Component; + +@Component +public class VerificationCodeValidator { + + private static final String WRONG_VERIFICATION_CODE_MESSAGE = "잘못된 인증코드(%s)를 입력했습니다."; + + public void validateVerificationCode(String verificationCode, String userInputCode) { + if (!userInputCode.equals(verificationCode)) { + throw new InvalidInputException(INVALID_VERIFICATION_CODE, + String.format(WRONG_VERIFICATION_CODE_MESSAGE, verificationCode)); + } + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/VerificationMailSender.java b/src/main/java/coffeemeet/server/certification/implement/VerificationMailSender.java new file mode 100644 index 00000000..a0e278fb --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/VerificationMailSender.java @@ -0,0 +1,22 @@ +package coffeemeet.server.certification.implement; + +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.common.infrastructure.EmailSender; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class VerificationMailSender { + + private static final String VERIFICATION_MAIL_SUBJECT = "[coffee-meet] 커피밋 사용을 위해 이메일 인증을 완료해주세요"; + private static final String VERIFICATION_MAIL_BODY = "인증코드: %s"; + + private final EmailSender emailSender; + + public void sendVerificationMail(CompanyEmail companyEmail, String verificationCode) { + emailSender.sendEmail(companyEmail.getValue(), VERIFICATION_MAIL_SUBJECT, + String.format(VERIFICATION_MAIL_BODY, verificationCode)); + } + +} From 3738ca16082769c22a1e3c50e2f256ebae9a0c4f Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:53:33 +0900 Subject: [PATCH 11/74] =?UTF-8?q?feat:=20=EA=B2=80=EC=A6=9D=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20Query,=20Command=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implement/VerificationInfoCommand.java | 20 +++++++++++++++++++ ...nQuery.java => VerificationInfoQuery.java} | 14 ++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 src/main/java/coffeemeet/server/certification/implement/VerificationInfoCommand.java rename src/main/java/coffeemeet/server/certification/implement/{EmailVerificationQuery.java => VerificationInfoQuery.java} (61%) diff --git a/src/main/java/coffeemeet/server/certification/implement/VerificationInfoCommand.java b/src/main/java/coffeemeet/server/certification/implement/VerificationInfoCommand.java new file mode 100644 index 00000000..bfd98091 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/VerificationInfoCommand.java @@ -0,0 +1,20 @@ +package coffeemeet.server.certification.implement; + +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.certification.domain.VerificationInfo; +import coffeemeet.server.certification.domain.repository.VerificationInfoRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class VerificationInfoCommand { + + private final VerificationInfoRepository verificationInfoRepository; + + public void createVerificationInfo(Long userId, CompanyEmail companyEmail, + String verificationCode) { + verificationInfoRepository.save(new VerificationInfo(userId, companyEmail, verificationCode)); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/VerificationInfoQuery.java similarity index 61% rename from src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java rename to src/main/java/coffeemeet/server/certification/implement/VerificationInfoQuery.java index e168395a..9ace1a63 100644 --- a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/implement/VerificationInfoQuery.java @@ -2,26 +2,26 @@ import static coffeemeet.server.certification.exception.CertificationErrorCode.VERIFICATION_CODE_NOT_FOUND; -import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; +import coffeemeet.server.certification.domain.VerificationInfo; +import coffeemeet.server.certification.domain.repository.VerificationInfoRepository; import coffeemeet.server.common.execption.InvalidInputException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor -public class EmailVerificationQuery { +public class VerificationInfoQuery { private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증코드를 요청한 기록이 없습니다."; - private final EmailVerificationRepository emailVerificationRepository; + private final VerificationInfoRepository verificationInfoRepository; - public String getCodeById(Long userId) { - EmailVerification emailVerification = emailVerificationRepository.findById(userId) + public String getVerificationCodeById(Long userId) { + VerificationInfo verificationInfo = verificationInfoRepository.findById(userId) .orElseThrow(() -> new InvalidInputException( VERIFICATION_CODE_NOT_FOUND, String.format(VERIFICATION_CODE_NOT_FOUND_MESSAGE, userId))); - return emailVerification.getCode(); + return verificationInfo.getVerificationCode(); } } From 4dd31dd1df86b9d6956e539a2582b063ed1d285e Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:54:13 +0900 Subject: [PATCH 12/74] =?UTF-8?q?refactor:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implement/EmailVerificationCommand.java | 20 --------- .../EmailVerificationCommandTest.java | 42 ------------------- 2 files changed, 62 deletions(-) delete mode 100644 src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java delete mode 100644 src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java diff --git a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java deleted file mode 100644 index 1b0361f1..00000000 --- a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java +++ /dev/null @@ -1,20 +0,0 @@ -package coffeemeet.server.certification.implement; - -import coffeemeet.server.certification.domain.CompanyEmail; -import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class EmailVerificationCommand { - - private final EmailVerificationRepository emailVerificationRepository; - - public void createEmailVerification(Long userId, CompanyEmail companyEmail, - String verificationCode) { - emailVerificationRepository.save(new EmailVerification(userId, companyEmail, verificationCode)); - } - -} diff --git a/src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java deleted file mode 100644 index 83dd89e8..00000000 --- a/src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package coffeemeet.server.certification.implement; - -import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailVerification; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.only; - -import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class EmailVerificationCommandTest { - - @InjectMocks - private EmailVerificationCommand emailVerificationCommand; - @Mock - private EmailVerificationRepository emailVerificationRepository; - - @Test - @DisplayName("새로운 EmailVerification 객체를 저장할 수 있다.") - void createEmailVerificationTest() { - // given - EmailVerification emailVerification = emailVerification(); - given(emailVerificationRepository.save(any(EmailVerification.class))).willReturn( - emailVerification); - - // when - emailVerificationCommand.createEmailVerification(emailVerification.getUserId(), - emailVerification.getCompanyEmail(), emailVerification.getCode()); - - // then - then(emailVerificationRepository).should(only()).save(any(EmailVerification.class)); - } - -} From 7d4c7a7b81746a84242130dbcfdb02b95994fb36 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:54:44 +0900 Subject: [PATCH 13/74] =?UTF-8?q?refactor:=20Certification=20Query,=20Comm?= =?UTF-8?q?and=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implement/CertificationCommand.java | 33 +++++++------------ .../implement/CertificationQuery.java | 7 +++- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java index 4b948a76..639cddfb 100644 --- a/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java @@ -1,14 +1,11 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.certification.exception.CertificationErrorCode.EXISTED_COMPANY_EMAIL; - import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.infrastructure.CertificationRepository; -import coffeemeet.server.common.execption.InvalidInputException; +import coffeemeet.server.certification.domain.repository.CertificationRepository; import coffeemeet.server.user.domain.User; -import java.util.function.Consumer; +import coffeemeet.server.user.implement.UserQuery; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -18,13 +15,13 @@ @RequiredArgsConstructor public class CertificationCommand { - private static final String EXISTED_COMPANY_EMAIL_MESSAGE = "이미 사용 중인 회사 이메일(%s) 입니다."; - private final CertificationRepository certificationRepository; private final CertificationQuery certificationQuery; + private final UserQuery userQuery; - public void createCertification(User user, String companyName, CompanyEmail companyEmail, + public void createCertification(Long userId, String companyName, CompanyEmail companyEmail, Department department, String businessCardUrl) { + User user = userQuery.getUserById(userId); certificationRepository.save( Certification.builder() .companyName(companyName) @@ -36,25 +33,19 @@ public void createCertification(User user, String companyName, CompanyEmail comp ); } - public void hasDuplicatedCompanyEmail(CompanyEmail companyEmail) { - if (certificationRepository.existsByCompanyEmail(companyEmail)) { - throw new InvalidInputException(EXISTED_COMPANY_EMAIL, - String.format(EXISTED_COMPANY_EMAIL_MESSAGE, companyEmail.getValue())); - } + public void updateCertification(Long userId, String companyName, CompanyEmail companyEmail, + Department department, String businessCardImageUrl) { + Certification certification = certificationQuery.getCertificationByUserId(userId); + certification.update(companyName, companyEmail, businessCardImageUrl, department); } - public void certificated(Long userId) { + public void completeCertification(Long userId) { Certification certification = certificationQuery.getCertificationByUserId(userId); certification.qualify(); } - @Transactional(readOnly = true) - public void applyIfCertifiedUser(Long userId, Consumer consumer) { - certificationRepository.findByUserId(userId).ifPresent(consumer); - } - - public void deleteCertification(Long userId) { - certificationRepository.deleteById(userId); + public void deleteCertificationByUserId(Long userId) { + certificationRepository.deleteByUserId(userId); } } diff --git a/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java index 91f1bdb7..16f1ee78 100644 --- a/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java @@ -3,7 +3,8 @@ import static coffeemeet.server.certification.exception.CertificationErrorCode.CERTIFICATION_NOT_FOUND; import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.infrastructure.CertificationRepository; +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.certification.domain.repository.CertificationRepository; import coffeemeet.server.common.execption.InvalidInputException; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -33,6 +34,10 @@ public String getCompanyNameByUserId(Long userId) { ).getCompanyName(); } + public boolean isExistedCompanyEmail(CompanyEmail companyEmail) { + return certificationRepository.existsByCompanyEmail(companyEmail); + } + public Long getUserIdByCertificationId(Long certificationId) { return certificationId; } From b448fff36c46187de02fcc7cabb8f3a6460ca42f Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:55:19 +0900 Subject: [PATCH 14/74] =?UTF-8?q?refactor:=20facade=20=ED=8C=A8=ED=84=B4?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20Service=20=EA=B3=84=EC=B8=B5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CertificationService.java | 102 +++++++----------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 433f9d18..5c83737e 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,25 +1,20 @@ package coffeemeet.server.certification.service; -import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; -import static coffeemeet.server.common.domain.KeyType.BUSINESS_CARD; - import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; +import coffeemeet.server.certification.implement.BusinessCardImageDeleter; +import coffeemeet.server.certification.implement.BusinessCardImageUploader; import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; -import coffeemeet.server.certification.implement.EmailVerificationCommand; -import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.implement.CompanyEmailValidator; +import coffeemeet.server.certification.implement.VerificationCodeGenerator; +import coffeemeet.server.certification.implement.VerificationCodeValidator; +import coffeemeet.server.certification.implement.VerificationInfoCommand; +import coffeemeet.server.certification.implement.VerificationInfoQuery; +import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; -import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.common.implement.EmailSender; -import coffeemeet.server.common.implement.MediaManager; -import coffeemeet.server.common.util.FileUtils; -import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.implement.UserQuery; import java.io.File; -import java.util.random.RandomGenerator; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -29,81 +24,60 @@ @RequiredArgsConstructor public class CertificationService { - private static final String WRONG_VERIFICATION_CODE_MESSAGE = "사용자(%s)가 잘못된 인증코드(%s)를 입력했습니다."; - private static final RandomGenerator RANDOM_GENERATOR = RandomGenerator.getDefault(); - - private final MediaManager mediaManager; - private final EmailSender emailSender; - private final UserQuery userQuery; + private final BusinessCardImageUploader businessCardImageUploader; + private final BusinessCardImageDeleter businessCardImageDeleter; private final CertificationCommand certificationCommand; private final CertificationQuery certificationQuery; - private final EmailVerificationCommand emailVerificationCommand; - private final EmailVerificationQuery emailVerificationQuery; + private final CompanyEmailValidator companyEmailValidator; + private final VerificationCodeGenerator verificationCodeGenerator; + private final VerificationCodeValidator verificationCodeValidator; + private final VerificationInfoQuery verificationInfoQuery; + private final VerificationInfoCommand verificationInfoCommand; + private final VerificationMailSender verificationMailSender; public void registerCertification(long userId, String companyName, String email, String departmentName, File businessCardImage) { - processCertification(userId, companyName, email, departmentName, businessCardImage, false); + CompanyEmail companyEmail = new CompanyEmail(email); + Department department = Department.valueOf(departmentName); + + String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage( + businessCardImage); + + certificationCommand.createCertification(userId, companyName, companyEmail, department, + businessCardImageUrl); } public void updateCertification(long userId, String companyName, String email, String departmentName, File businessCardImage) { - processCertification(userId, companyName, email, departmentName, businessCardImage, true); - } - - private void processCertification(long userId, String companyName, String email, - String departmentName, File businessCardImage, boolean isUpdate) { - String key = mediaManager.generateKey(BUSINESS_CARD); - uploadBusinessCard(userId, key, businessCardImage); - CompanyEmail companyEmail = new CompanyEmail(email); - String businessCardUrl = mediaManager.getUrl(key); Department department = Department.valueOf(departmentName); - User user = userQuery.getUserById(userId); - if (isUpdate) { - certificationCommand.deleteCertification(userId); - } - certificationCommand.createCertification(user, companyName, companyEmail, department, - businessCardUrl); - } - - private void uploadBusinessCard(long userId, String key, File businessCardUrl) { - certificationCommand.applyIfCertifiedUser(userId, certification -> { - String oldKey = mediaManager.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD); - mediaManager.delete(oldKey); - }); + businessCardImageDeleter.deleteBusinessCardImageByUserId(userId); + String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage( + businessCardImage); - mediaManager.upload(key, businessCardUrl); - FileUtils.delete(businessCardUrl); + certificationCommand.updateCertification(userId, companyName, companyEmail, department, + businessCardImageUrl); } public void sendVerificationMail(Long userId, String email) { CompanyEmail companyEmail = new CompanyEmail(email); - certificationCommand.hasDuplicatedCompanyEmail(companyEmail); + companyEmailValidator.validateDuplicatedCompanyEmail(companyEmail); - String verificationCode = generateVerificationCode(); - emailSender.sendVerificationCode(companyEmail, verificationCode); - emailVerificationCommand.createEmailVerification(userId, companyEmail, verificationCode); - } + String verificationCode = verificationCodeGenerator.generateVerificationCode(); + verificationMailSender.sendVerificationMail(companyEmail, verificationCode); - private String generateVerificationCode() { - return String.format("%06d", RANDOM_GENERATOR.nextInt(1000000)); + verificationInfoCommand.createVerificationInfo(userId, companyEmail, verificationCode); } - public void compareCode(Long userId, String verificationCode) { - String correctCode = emailVerificationQuery.getCodeById(userId); - if (!correctCode.equals(verificationCode)) { - throw new InvalidInputException(INVALID_VERIFICATION_CODE, - String.format(WRONG_VERIFICATION_CODE_MESSAGE, userId, verificationCode)); - } + public void compareCode(Long userId, String userInputCode) { + String verificationCode = verificationInfoQuery.getVerificationCodeById(userId); + verificationCodeValidator.validateVerificationCode(verificationCode, userInputCode); } public PendingCertificationPageDto getUncertifiedUserRequests(Pageable pageable) { - Page pendingCertification = - certificationQuery.getPendingCertification(pageable); - Page pendingCertificationPage = pendingCertification.map( - PendingCertification::from); - return new PendingCertificationPageDto(pendingCertificationPage); + Page pendingCertifications = certificationQuery.getPendingCertification(pageable); + return PendingCertificationPageDto.from(pendingCertifications); } } From d92f492efb874d0e57099ff76fa685aabfafcad2 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:55:53 +0900 Subject: [PATCH 15/74] =?UTF-8?q?feat:=20=EC=A0=95=EC=A0=81=20=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dto/PendingCertificationPageDto.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index e9bcbab1..5e50906c 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -1,9 +1,15 @@ package coffeemeet.server.certification.service.dto; +import coffeemeet.server.certification.domain.Certification; import org.springframework.data.domain.Page; public record PendingCertificationPageDto( Page page ) { + public static PendingCertificationPageDto from( + Page certificationPage + ) { + return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); + } } From 4570651f6df82e1c32209d5a2747e40049f0d507 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:56:14 +0900 Subject: [PATCH 16/74] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/coffeemeet/server/common/util/FileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/coffeemeet/server/common/util/FileUtils.java b/src/main/java/coffeemeet/server/common/util/FileUtils.java index c0753eea..1dba9324 100644 --- a/src/main/java/coffeemeet/server/common/util/FileUtils.java +++ b/src/main/java/coffeemeet/server/common/util/FileUtils.java @@ -23,7 +23,7 @@ public static File convertMultipartFileToFile(MultipartFile multipartFile) { } } - public static void delete(File file) { + public static void deleteTempFile(File file) { try { Files.delete(file.toPath()); } catch (IOException e) { From 5ed11920f2a5d4dc3297e5af066b84acbd761045 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:56:51 +0900 Subject: [PATCH 17/74] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/CertificationTest.java | 35 ++++ .../CertificationRepositoryTest.java | 28 +-- .../BusinessCardImageDeleterTest.java | 45 +++++ .../BusinessCardImageUploaderTest.java | 36 ++++ .../implement/CertificationCommandTest.java | 73 ++++---- .../implement/CertificationQueryTest.java | 2 +- .../implement/CompanyEmailValidatorTest.java | 46 +++++ .../implement/EmailVerificationQueryTest.java | 41 ----- .../VerificationCodeGeneratorTest.java | 22 +++ .../VerificationCodeValidatorTest.java | 40 +++++ .../VerificationInfoCommandTest.java | 42 +++++ .../implement/VerificationInfoQueryTest.java | 41 +++++ .../implement/VerificationMailSenderTest.java | 41 +++++ .../service/CertificationServiceTest.java | 169 +++++++----------- .../fixture/entity/CertificationFixture.java | 42 +++-- .../common/fixture/entity/UserFixture.java | 29 +++ .../common/implement/EmailSenderTest.java | 19 +- ...agerTest.java => S3ObjectStorageTest.java} | 23 +-- 18 files changed, 544 insertions(+), 230 deletions(-) create mode 100644 src/test/java/coffeemeet/server/certification/domain/CertificationTest.java rename src/test/java/coffeemeet/server/certification/{infrastructure => domain/repository}/CertificationRepositoryTest.java (82%) create mode 100644 src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/BusinessCardImageUploaderTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/CompanyEmailValidatorTest.java delete mode 100644 src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/VerificationCodeGeneratorTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/VerificationCodeValidatorTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java rename src/test/java/coffeemeet/server/common/implement/{S3MediaManagerTest.java => S3ObjectStorageTest.java} (76%) diff --git a/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java b/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java new file mode 100644 index 00000000..eac68f72 --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java @@ -0,0 +1,35 @@ +package coffeemeet.server.certification.domain; + +import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class CertificationTest { + + @Test + @DisplayName("Certification을 업데이트 할 수 있다.") + void updateTest() { + // given + Certification certification = certification(); + String newCompanyName = companyName(); + CompanyEmail newCompanyEmail = companyEmail(); + String newBusinessCardUrl = businessCardUrl(); + Department newDepartment = department(); + + // when + certification.update(newCompanyName, newCompanyEmail, newBusinessCardUrl, newDepartment); + + // then + assertThat(certification).extracting(Certification::getCompanyName, + Certification::getCompanyEmail, Certification::getBusinessCardUrl, + Certification::getDepartment) + .containsExactly(newCompanyName, newCompanyEmail, newBusinessCardUrl, newDepartment); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/infrastructure/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java similarity index 82% rename from src/test/java/coffeemeet/server/certification/infrastructure/CertificationRepositoryTest.java rename to src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index 5c45aead..44bfcf0e 100644 --- a/src/test/java/coffeemeet/server/certification/infrastructure/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,9 +1,10 @@ -package coffeemeet.server.certification.infrastructure; +package coffeemeet.server.certification.domain.repository; import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.entity.UserFixture.users; +import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static org.assertj.core.api.Assertions.assertThat; import coffeemeet.server.certification.domain.Certification; @@ -35,12 +36,6 @@ void setUp() { user = userRepository.save(user()); } - @AfterEach - void tearDown() { - certificationRepository.deleteAll(); - userRepository.deleteAll(); - } - @Test @DisplayName("유저 아이디로 회사 인증 정보를 조회할 수 있다.") void findByUserIdTest() { @@ -63,23 +58,32 @@ void existsByCompanyEmailTest() { certificationRepository.existsByCompanyEmail(certification.getCompanyEmail())).isTrue(); } + @Test + @DisplayName("유저 아이디로 인증정보를 삭제할 수 있다") + void deleteByUserIdTest() { + // given + Certification certification = certification(user); + certificationRepository.save(certification); + // when, then + certificationRepository.deleteByUserId(user.getId()); + } + @Test @DisplayName("아직 인증이 안된 회사 인증 요청을 페이지 조회할 수 있다.") - void findByIsCertificatedFalse() { + void findPendingCertificationsTest() { // given - List users = userRepository.saveAll(users()); + List users = userRepository.saveAll(usersWithNullId()); List certifications = certificationRepository.saveAll( users.stream() .map(CertificationFixture::certification) .toList() ); - long certificatedCount = certifications.stream() .filter(Certification::isCertificated) .count(); - Pageable pageable = pageable(); + Pageable pageable = certificationPageable(); // when Page foundCertification = certificationRepository.findPendingCertifications( diff --git a/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java b/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java new file mode 100644 index 00000000..18c813dd --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java @@ -0,0 +1,45 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.domain.S3KeyPrefix.BUSINESS_CARD; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.only; + +import coffeemeet.server.certification.domain.Certification; +import coffeemeet.server.common.implement.ImageDeleter; +import coffeemeet.server.user.domain.User; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class BusinessCardImageDeleterTest { + + @InjectMocks + private BusinessCardImageDeleter businessCardImageDeleter; + @Mock + private CertificationQuery certificationQuery; + @Mock + private ImageDeleter imageDeleter; + + @Test + void deleteBusinessCardImageByUserIdTest() { + // given + User user = user(); + Certification certification = certification(user); + Long userId = user.getId(); + + given(certificationQuery.getCertificationByUserId(userId)).willReturn(certification); + + // when + businessCardImageDeleter.deleteBusinessCardImageByUserId(userId); + + // then + then(imageDeleter).should(only()) + .deleteImage(certification.getBusinessCardUrl(), BUSINESS_CARD); + } +} diff --git a/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageUploaderTest.java b/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageUploaderTest.java new file mode 100644 index 00000000..471f6fcc --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageUploaderTest.java @@ -0,0 +1,36 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.domain.S3KeyPrefix.BUSINESS_CARD; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.only; + +import coffeemeet.server.common.implement.ImageUploader; +import java.io.File; +import org.instancio.Instancio; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class BusinessCardImageUploaderTest { + + @InjectMocks + private BusinessCardImageUploader businessCardImageUploader; + @Mock + private ImageUploader imageUploader; + + @Test + void uploadBusinessCardImage() { + // given + File businessCardImage = Instancio.create(File.class); + + // when + businessCardImageUploader.uploadBusinessCardImage(businessCardImage); + + // then + then(imageUploader).should(only()).uploadImage(businessCardImage, BUSINESS_CARD); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index 01afd472..f32e78d6 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -5,9 +5,9 @@ import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; @@ -16,11 +16,9 @@ import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.infrastructure.CertificationRepository; -import coffeemeet.server.common.execption.InvalidInputException; +import coffeemeet.server.certification.domain.repository.CertificationRepository; import coffeemeet.server.user.domain.User; -import java.util.Optional; -import java.util.function.Consumer; +import coffeemeet.server.user.implement.UserQuery; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -31,61 +29,34 @@ @ExtendWith(MockitoExtension.class) class CertificationCommandTest { - @Mock - private Consumer consumer; @InjectMocks private CertificationCommand certificationCommand; @Mock private CertificationRepository certificationRepository; @Mock private CertificationQuery certificationQuery; + @Mock + private UserQuery userQuery; @Test @DisplayName("새로운 Certification 객체를 저장할 수 있다.") void createCertificationTest() { // given + User user = user(); String companyName = companyName(); CompanyEmail companyEmail = companyEmail(); String businessCardUrl = businessCardUrl(); Department department = department(); - User user = user(); - - // when - certificationCommand.createCertification(user, companyName, companyEmail, department, - businessCardUrl); - - // then - then(certificationRepository).should(only()).save(any(Certification.class)); - } - - @Test - @DisplayName("중복된 회사 이메일이 있을 경우 예외가 발생한다.") - void checkDuplicatedCompanyEmailTest() { - // given - CompanyEmail companyEmail = companyEmail(); - given(certificationRepository.existsByCompanyEmail(companyEmail)).willReturn(true); - - // when, then - assertThatThrownBy( - () -> certificationCommand.hasDuplicatedCompanyEmail(companyEmail)).isInstanceOf( - InvalidInputException.class); - } - - @Test - @DisplayName("만약 인증이 완료된 사용자면 Consumer를 실행할 수 있다.") - void applyIfCertifiedUserTest() { - // given - User user = user(); Long userId = user.getId(); - Certification certification = certification(user()); - given(certificationRepository.findByUserId(userId)).willReturn(Optional.of(certification)); + given(userQuery.getUserById(userId)).willReturn(user); // when - certificationCommand.applyIfCertifiedUser(userId, consumer); + certificationCommand.createCertification(userId, companyName, companyEmail, department, + businessCardUrl); // then - then(consumer).should(only()).accept(certification); + then(certificationRepository).should(only()).save(any(Certification.class)); } @Test @@ -94,10 +65,11 @@ void certificatedTest() { // given Certification certification = certification(); Long userId = certification.getUser().getId(); + given(certificationQuery.getCertificationByUserId(userId)).willReturn(certification); // when - certificationCommand.certificated(userId); + certificationCommand.completeCertification(userId); // then assertThat(certification.isCertificated()).isTrue(); @@ -110,10 +82,27 @@ void deleteUserCertification() { Long userId = 1L; // when - certificationCommand.deleteCertification(userId); + certificationCommand.deleteCertificationByUserId(userId); + + // then + then(certificationRepository).should(only()).deleteByUserId(userId); + } + + @Test + @DisplayName("인증 완료 시킬 수 있다.") + void completeCertificationTest() { + // given + User user = user(); + Long userId = user.getId(); + Certification certification = pendingCertification(user); + + given(certificationQuery.getCertificationByUserId(userId)).willReturn(certification); + + // when + certificationCommand.completeCertification(certification.getId()); // then - then(certificationRepository).should(only()).deleteById(userId); + assertThat(certification.isCertificated()).isTrue(); } } diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java index a0b7e638..f0527488 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java @@ -6,7 +6,7 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.infrastructure.CertificationRepository; +import coffeemeet.server.certification.domain.repository.CertificationRepository; import coffeemeet.server.user.domain.User; import java.util.Collections; import java.util.Optional; diff --git a/src/test/java/coffeemeet/server/certification/implement/CompanyEmailValidatorTest.java b/src/test/java/coffeemeet/server/certification/implement/CompanyEmailValidatorTest.java new file mode 100644 index 00000000..a6b4cf0d --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/CompanyEmailValidatorTest.java @@ -0,0 +1,46 @@ +package coffeemeet.server.certification.implement; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.when; + +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.common.execption.InvalidInputException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CompanyEmailValidatorTest { + + @InjectMocks + private CompanyEmailValidator companyEmailValidator; + @Mock + private CertificationQuery certificationQuery; + + @Test + @DisplayName("회사 이메일이 중복되면 예외가 발생한다.") + void validateDuplicatedCompanyEmailTest_InvalidInputException() { + // given + CompanyEmail companyEmail = new CompanyEmail("test@example.com"); + when(certificationQuery.isExistedCompanyEmail(companyEmail)).thenReturn(true); + + // when, then + assertThrows(InvalidInputException.class, () -> + companyEmailValidator.validateDuplicatedCompanyEmail(companyEmail)); + } + + @Test + @DisplayName("회사 이메일이 중복되지 않으면 예외가 발생하지 않는다.") + void validateDuplicatedCompanyEmailTest() { + // given + CompanyEmail companyEmail = new CompanyEmail("unique@example.com"); + when(certificationQuery.isExistedCompanyEmail(companyEmail)).thenReturn(false); + + // when, then + companyEmailValidator.validateDuplicatedCompanyEmail(companyEmail); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java b/src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java deleted file mode 100644 index 7b2295a5..00000000 --- a/src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package coffeemeet.server.certification.implement; - -import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailVerification; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; - -import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; -import java.util.Optional; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class EmailVerificationQueryTest { - - @InjectMocks - private EmailVerificationQuery emailVerificationQuery; - @Mock - private EmailVerificationRepository emailVerificationRepository; - - @Test - @DisplayName("유저 아이디로 EmailVerification를 조회할 수 있다.") - void getCodeByIdTest() { - // given - EmailVerification emailVerification = emailVerification(); - - given(emailVerificationRepository.findById(emailVerification.getUserId())).willReturn( - Optional.of(emailVerification)); - - // when - String code = emailVerificationQuery.getCodeById(emailVerification.getUserId()); - - // then - assertThat(code).isEqualTo(emailVerification.getCode()); - } - -} diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationCodeGeneratorTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationCodeGeneratorTest.java new file mode 100644 index 00000000..692b9486 --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationCodeGeneratorTest.java @@ -0,0 +1,22 @@ +package coffeemeet.server.certification.implement; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VerificationCodeGeneratorTest { + + private final VerificationCodeGenerator verificationCodeGenerator = new VerificationCodeGenerator(); + + @Test + @DisplayName("6자리의 랜덤 인증 코드를 생성할 수 있다.") + void generateVerificationCodeTest() { + // when + String code = verificationCodeGenerator.generateVerificationCode(); + + // then + assertThat(code).matches("[0-9]{6}"); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationCodeValidatorTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationCodeValidatorTest.java new file mode 100644 index 00000000..d3754513 --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationCodeValidatorTest.java @@ -0,0 +1,40 @@ +package coffeemeet.server.certification.implement; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import coffeemeet.server.common.execption.InvalidInputException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class VerificationCodeValidatorTest { + + private final VerificationCodeValidator verificationCodeValidator = new VerificationCodeValidator(); + + @Test + @DisplayName("일치하는 인증 코드가 입력되면 예외가 발생하지 않는다") + void validateVerificationCodeTest() { + // given + String verificationCode = "123456"; + String userInputCode = "123456"; + + // when, then + assertThatCode( + () -> verificationCodeValidator.validateVerificationCode(verificationCode, userInputCode) + ).doesNotThrowAnyException(); + } + + @Test + @DisplayName("일치하지 않는 인증 코드가 입력되면 예외가 발생한다") + void validateVerificationCode_WithIncorrectCode_ShouldThrowException() { + // given + String verificationCode = "123456"; + String userInputCode = "654321"; + + // when, then + assertThatThrownBy( + () -> verificationCodeValidator.validateVerificationCode(verificationCode, userInputCode)) + .isInstanceOf(InvalidInputException.class); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java new file mode 100644 index 00000000..2bf0b8f0 --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java @@ -0,0 +1,42 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailVerification; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.only; + +import coffeemeet.server.certification.domain.VerificationInfo; +import coffeemeet.server.certification.domain.repository.VerificationInfoRepository; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class VerificationInfoCommandTest { + + @InjectMocks + private VerificationInfoCommand verificationInfoCommand; + @Mock + private VerificationInfoRepository verificationInfoRepository; + + @Test + @DisplayName("새로운 VerificationInfo 객체를 저장할 수 있다.") + void createEmailVerificationTest() { + // given + VerificationInfo verificationInfo = emailVerification(); + given(verificationInfoRepository.save(any(VerificationInfo.class))).willReturn( + verificationInfo); + + // when + verificationInfoCommand.createVerificationInfo(verificationInfo.getUserId(), + verificationInfo.getCompanyEmail(), verificationInfo.getVerificationCode()); + + // then + then(verificationInfoRepository).should(only()).save(any(VerificationInfo.class)); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java new file mode 100644 index 00000000..d834b1c3 --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java @@ -0,0 +1,41 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailVerification; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; + +import coffeemeet.server.certification.domain.VerificationInfo; +import coffeemeet.server.certification.domain.repository.VerificationInfoRepository; +import java.util.Optional; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class VerificationInfoQueryTest { + + @InjectMocks + private VerificationInfoQuery verificationInfoQuery; + @Mock + private VerificationInfoRepository verificationInfoRepository; + + @Test + @DisplayName("유저 아이디로 VerificationInfo를 조회할 수 있다.") + void getCodeByIdTest() { + // given + VerificationInfo verificationInfo = emailVerification(); + + given(verificationInfoRepository.findById(verificationInfo.getUserId())).willReturn( + Optional.of(verificationInfo)); + + // when + String code = verificationInfoQuery.getVerificationCodeById(verificationInfo.getUserId()); + + // then + assertThat(code).isEqualTo(verificationInfo.getVerificationCode()); + } + +} diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java new file mode 100644 index 00000000..69732711 --- /dev/null +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java @@ -0,0 +1,41 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.only; + +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.common.infrastructure.EmailSender; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class VerificationMailSenderTest { + + @InjectMocks + private VerificationMailSender verificationMailSender; + + @Mock + private EmailSender emailSender; + + + @Test + @DisplayName("인증 이메일 전송할 수 있다.") + void sendVerificationMailTest() { + // given + CompanyEmail companyEmail = companyEmail(); + String verificationCode = verificationCode(); + + // when + verificationMailSender.sendVerificationMail(companyEmail, verificationCode); + + // then + then(emailSender).should(only()).sendEmail(anyString(), anyString(), anyString()); + } +} diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index 33b5e195..bb797a1d 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,36 +1,34 @@ package coffeemeet.server.certification.service; import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certifications; import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPage; import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.only; import coffeemeet.server.certification.domain.Certification; +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.certification.domain.Department; +import coffeemeet.server.certification.implement.BusinessCardImageDeleter; +import coffeemeet.server.certification.implement.BusinessCardImageUploader; import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; -import coffeemeet.server.certification.implement.EmailVerificationCommand; -import coffeemeet.server.certification.implement.EmailVerificationQuery; +import coffeemeet.server.certification.implement.CompanyEmailValidator; +import coffeemeet.server.certification.implement.VerificationCodeGenerator; +import coffeemeet.server.certification.implement.VerificationCodeValidator; +import coffeemeet.server.certification.implement.VerificationInfoCommand; +import coffeemeet.server.certification.implement.VerificationInfoQuery; +import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; -import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.common.implement.EmailSender; -import coffeemeet.server.common.implement.MediaManager; -import coffeemeet.server.common.util.FileUtils; -import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.implement.UserQuery; import java.io.File; import java.util.List; import org.instancio.Instancio; @@ -39,10 +37,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.MockedStatic; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @ExtendWith(MockitoExtension.class) @@ -50,152 +46,123 @@ class CertificationServiceTest { @InjectMocks private CertificationService certificationService; - @Mock - private MediaManager mediaManager; - + private BusinessCardImageUploader businessCardImageUploader; @Mock - private EmailSender emailSender; - - @Mock - private UserQuery userQuery; - + private BusinessCardImageDeleter businessCardImageDeleter; @Mock private CertificationCommand certificationCommand; - @Mock private CertificationQuery certificationQuery; - @Mock - private EmailVerificationCommand emailVerificationCommand; - + private CompanyEmailValidator companyEmailValidator; + @Mock + private VerificationCodeGenerator verificationCodeGenerator; + @Mock + private VerificationCodeValidator verificationCodeValidator; + @Mock + private VerificationInfoQuery verificationInfoQuery; @Mock - private EmailVerificationQuery emailVerificationQuery; + private VerificationInfoCommand verificationInfoCommand; + @Mock + private VerificationMailSender verificationMailSender; @Test - @DisplayName("회사 정보를 등록할 수 있다.") + @DisplayName("인증 정보를 등록할 수 있다.") void registerCertificationTest() { // given - User user = user(); - Long userId = user.getId(); + long userId = 1L; String companyName = companyName(); String email = email(); String departmentName = department().name(); - File file = mock(); - String businessCardUrl = businessCardUrl(); - - MockedStatic fileUtils = mockStatic(FileUtils.class); - fileUtils.when(() -> FileUtils.delete(file)).then(invocation -> null); + File businessCardImage = Instancio.create(File.class); + String expectedImageUrl = businessCardUrl(); - given(mediaManager.generateKey(any())).willReturn("someKey"); - given(mediaManager.getUrl(any())).willReturn(businessCardUrl); - given(userQuery.getUserById(userId)).willReturn(user); + given(businessCardImageUploader.uploadBusinessCardImage(any(File.class))) + .willReturn(expectedImageUrl); // when - certificationService.registerCertification(userId, companyName, email, departmentName, file); + certificationService.registerCertification(userId, companyName, email, departmentName, + businessCardImage); // then - then(mediaManager).should().generateKey(any()); - then(mediaManager).should().upload(any(), any()); - then(certificationCommand).should().createCertification(any(), any(), any(), any(), any()); - - fileUtils.close(); + then(certificationCommand).should(only()).createCertification(eq(userId), eq(companyName), + any(CompanyEmail.class), any(Department.class), eq(expectedImageUrl)); } @Test - @DisplayName("회사 정보를 수정할 수 있다.") + @DisplayName("인증 정보를 수정할 수 있다.") void updateCertificationTest() { // given - User user = user(); - Long userId = user.getId(); + long userId = 1L; String companyName = companyName(); String email = email(); String departmentName = department().name(); - File file = mock(); - String businessCardUrl = businessCardUrl(); + File businessCardImage = Instancio.create(File.class); + String expectedImageUrl = businessCardUrl(); - MockedStatic fileUtils = mockStatic(FileUtils.class); - fileUtils.when(() -> FileUtils.delete(file)).then(invocation -> null); - - given(mediaManager.generateKey(any())).willReturn("someKey"); - given(mediaManager.getUrl(any())).willReturn(businessCardUrl); - given(userQuery.getUserById(userId)).willReturn(user); + given(businessCardImageUploader.uploadBusinessCardImage(any(File.class))).willReturn( + expectedImageUrl); // when - certificationService.updateCertification(userId, companyName, email, departmentName, file); - - // then - - then(mediaManager).should().upload(any(), any()); - then(certificationCommand).should().deleteCertification(any()); - then(certificationCommand).should() - .createCertification(any(), any(), any(), any(), any()); + certificationService.updateCertification(userId, companyName, email, departmentName, + businessCardImage); - fileUtils.close(); + //then + then(businessCardImageDeleter).should(only()).deleteBusinessCardImageByUserId(userId); + then(certificationCommand).should(only()).updateCertification(eq(userId), eq(companyName), + any(CompanyEmail.class), any(Department.class), eq(expectedImageUrl)); } @Test - @DisplayName("회사 인증 메일을 전송할 수 있다.") void sendVerificationMailTest() { // given + Long userId = 1L; String email = email(); - User user = user(); - Long userId = user.getId(); + String verificationCode = verificationCode(); + + given(verificationCodeGenerator.generateVerificationCode()).willReturn(verificationCode); // when certificationService.sendVerificationMail(userId, email); // then - then(certificationCommand).should(only()).hasDuplicatedCompanyEmail(any()); - then(emailSender).should(only()).sendVerificationCode(any(), anyString()); - then(emailVerificationCommand).should(only()) - .createEmailVerification(anyLong(), any(), anyString()); + then(companyEmailValidator).should(only()).validateDuplicatedCompanyEmail(any(CompanyEmail.class)); + then(verificationMailSender).should(only()).sendVerificationMail(any(CompanyEmail.class), eq(verificationCode)); + then(verificationInfoCommand).should(only()).createVerificationInfo(eq(userId), any(CompanyEmail.class), eq(verificationCode)); } @Test - @DisplayName("인증 코드를 비교할 수 있다.") void compareCodeTest() { // given - Long userId = Instancio.create(Long.class); - String verificationCode = verificationCode(); - given(emailVerificationQuery.getCodeById(userId)).willReturn(verificationCode); + Long userId = 1L; + String userInputCode = "123456"; + String actualVerificationCode = "123456"; - // when, then - assertThatCode(() -> certificationService.compareCode(userId, verificationCode)) - .doesNotThrowAnyException(); - } + given(verificationInfoQuery.getVerificationCodeById(userId)).willReturn(actualVerificationCode); - @Test - @DisplayName("인증 코드가 일치하지 않다면 예외를 던진다.") - void compareCodeFailTest() { - // given - Long userId = Instancio.create(Long.class); - String correctCode = "correctCode"; - String verificationCode = verificationCode(); - given(emailVerificationQuery.getCodeById(userId)).willReturn(correctCode); + // when + certificationService.compareCode(userId, userInputCode); - // when, then - assertThatThrownBy(() -> certificationService.compareCode(userId, verificationCode)) - .isInstanceOf(InvalidInputException.class); + // then + then(verificationCodeValidator).should(only()).validateVerificationCode(eq(actualVerificationCode), eq(userInputCode)); } @Test - @DisplayName("미인증 사용자 요청을 페이지로 가져올 수 있다.") void getUncertifiedUserRequestsTest() { // given - Pageable pageable = mock(Pageable.class); - List certificationList = certifications(); - Page pendingCertificationPage = new PageImpl<>(certificationList); + Pageable pageable = certificationPageable(); + Page certificationPage = pendingCertificationPage( + pageable.getPageSize()); - given(certificationQuery.getPendingCertification(pageable)).willReturn( - pendingCertificationPage); + given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn(certificationPage); // when PendingCertificationPageDto result = certificationService.getUncertifiedUserRequests(pageable); // then assertThat(result).isNotNull(); - assertThat(result.page().getContent()).hasSize(certificationList.size()); + assertThat(result.page()).hasSize(certificationPage.getSize()); } } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java index dc441224..3f9863d5 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java @@ -6,7 +6,7 @@ import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.domain.EmailVerification; +import coffeemeet.server.certification.domain.VerificationInfo; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; import coffeemeet.server.certification.service.dto.PendingCertification; @@ -17,6 +17,7 @@ import org.instancio.internal.generator.domain.internet.EmailGenerator; import org.instancio.internal.generator.lang.IntegerGenerator; import org.instancio.internal.generator.net.URLGenerator; +import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -43,7 +44,7 @@ public static Certification certification(User user) { public static Certification certificatedCertification(User user, String companyName) { return Instancio.of(Certification.class) .generate(field(Certification::getBusinessCardUrl), gen -> gen.net().url().asString()) - .set(field(Certification::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())) + .set(field(Certification::getCompanyEmail), new CompanyEmail(email())) .set(field(Certification::getCompanyName), companyName) .set(field(Certification::getId), user.getId()) .set(field(Certification::getUser), user) @@ -51,6 +52,16 @@ public static Certification certificatedCertification(User user, String companyN .create(); } + public static Certification pendingCertification(User user) { + return Instancio.of(Certification.class) + .generate(field(Certification::getBusinessCardUrl), gen -> gen.net().url().asString()) + .set(field(Certification::getCompanyEmail), new CompanyEmail(email())) + .set(field(Certification::getId), user.getId()) + .set(field(Certification::getUser), user) + .set(field(Certification::isCertificated), false) + .create(); + } + public static List certificatedCertifications(List users, String companyName) { return users.stream() @@ -58,18 +69,14 @@ public static List certificatedCertifications(List users, .toList(); } - public static List certifications() { - return users().stream().map(CertificationFixture::certification).toList(); - } - - public static EmailVerification emailVerification() { - return Instancio.of(EmailVerification.class).set(field(EmailVerification::getCompanyEmail), + public static VerificationInfo emailVerification() { + return Instancio.of(VerificationInfo.class).set(field(VerificationInfo::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())).create(); } - public static EmailVerification emailVerification(Long userId) { - return Instancio.of(EmailVerification.class).set(field(EmailVerification::getUserId), userId) - .set(field(EmailVerification::getCompanyEmail), + public static VerificationInfo emailVerification(Long userId) { + return Instancio.of(VerificationInfo.class).set(field(VerificationInfo::getUserId), userId) + .set(field(VerificationInfo::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())).create(); } @@ -113,12 +120,23 @@ public static VerificationCodeHTTP.Request verificationCodeDtoRequest() { String.format("%06d", new IntegerGenerator().range(0, 999999).get())).create(); } - public static Pageable pageable() { + public static Pageable certificationPageable() { int page = 0; int size = new IntegerGenerator().range(1, 100).get(); return PageRequest.of(page, size, Sort.by("updatedAt").ascending()); } + public static Page pendingCertificationPage(int size) { + return new PageImpl<>(certificationsNotCertificated(size)); + } + + private static List certificationsNotCertificated(int size) { + List users = users(size); + return users.stream() + .map(CertificationFixture::pendingCertification) + .toList(); + } + public static PendingCertificationPageDto pendingCertificationPageDto(int size) { return new PendingCertificationPageDto(new PageImpl<>(pendingCertifications(size))); } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java index 6a424686..5ed23e9f 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java @@ -24,6 +24,16 @@ public static User user() { .create(); } + public static User user(Long userId) { + return Instancio.of(User.class).set(field(User::getProfile), profile()) + .set(field(User::isRegistered), true) + .set(field(User::getId), userId) + .ignore(field(User::isDeleted)) + .ignore(field(User::isBlacklisted)) + .ignore(field(User::getChattingRoom)) + .create(); + } + public static User user(UserStatus userStatus) { return Instancio.of(User.class).set(field(User::getProfile), profile()) .set(field(User::getUserStatus), userStatus) @@ -52,6 +62,25 @@ public static List users() { .create(); } + public static List usersWithNullId() { + return Instancio.ofList(User.class) + .set(field(User::getId), null) + .ignore(field(User::isDeleted)) + .ignore(field(User::isBlacklisted)) + .ignore(field(User::getChattingRoom)) + .create(); + } + + public static List users(int size) { + return Instancio.ofList(User.class) + .size(size) + .generate(field(User::getId), gen -> gen.longSeq().start(1L)) + .ignore(field(User::isDeleted)) + .ignore(field(User::isBlacklisted)) + .ignore(field(User::getChattingRoom)) + .create(); + } + public static List fourUsers() { return Instancio.ofList(User.class).size(4) .generate(field(User::getId), gen -> gen.longSeq().start(1L)) diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index a120eb41..7b2a3ba7 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,15 +1,14 @@ package coffeemeet.server.common.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.only; -import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.common.infrastructure.EmailSender; import java.util.Objects; +import org.instancio.Instancio; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -41,14 +40,15 @@ void setUp() { } @Test - @DisplayName("인증코드가 포함된 메일을 보낼 수 있다.") + @DisplayName("메일을 보낼 수 있다.") void sendVerificationCodeTest() { // given - CompanyEmail companyEmail = companyEmail(); - String verificationCode = verificationCode(); + String email = email(); + String subject = Instancio.create(String.class); + String body = Instancio.create(String.class); // when - emailSender.sendVerificationCode(companyEmail, verificationCode); + emailSender.sendEmail(email, subject, body); // then then(javaMailSender).should(only()).send(simpleMailMessage.capture()); @@ -56,9 +56,8 @@ void sendVerificationCodeTest() { SimpleMailMessage sentMailMessage = simpleMailMessage.getValue(); assertAll( () -> assertThat(sentMailMessage.getFrom()).isEqualTo(sender), - () -> assertThat(Objects.requireNonNull(sentMailMessage.getTo())[0]).isEqualTo( - companyEmail.getValue()), - () -> assertThat(sentMailMessage.getText()).contains(verificationCode) + () -> assertThat(Objects.requireNonNull(sentMailMessage.getTo())[0]).isEqualTo(email), + () -> assertThat(sentMailMessage.getText()).contains(body) ); } } diff --git a/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java b/src/test/java/coffeemeet/server/common/implement/S3ObjectStorageTest.java similarity index 76% rename from src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java rename to src/test/java/coffeemeet/server/common/implement/S3ObjectStorageTest.java index 2f6dee27..958188a7 100644 --- a/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java +++ b/src/test/java/coffeemeet/server/common/implement/S3ObjectStorageTest.java @@ -7,7 +7,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; -import coffeemeet.server.common.domain.KeyType; +import coffeemeet.server.common.domain.S3KeyPrefix; +import coffeemeet.server.common.infrastructure.S3ObjectStorage; import com.amazonaws.services.s3.AmazonS3; import java.io.File; import java.net.URL; @@ -21,9 +22,9 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class S3MediaManagerTest { +class S3ObjectStorageTest { - private S3MediaManager s3MediaManager; + private S3ObjectStorage s3MediaManager; @Mock private AmazonS3 amazonS3; @@ -32,13 +33,13 @@ class S3MediaManagerTest { private String validKey; - private KeyType keyType; + private S3KeyPrefix s3KeyPrefix; @BeforeEach void setUp() { - keyType = Instancio.create(KeyType.class); - validKey = keyType.getValue() + "-" + Instancio.create(String.class); - s3MediaManager = new S3MediaManager(amazonS3, bucketName); + s3KeyPrefix = Instancio.create(S3KeyPrefix.class); + validKey = s3KeyPrefix.getValue() + "-" + Instancio.create(String.class); + s3MediaManager = new S3ObjectStorage(amazonS3, bucketName); } @Test @@ -86,13 +87,13 @@ void getUrlTest() { @DisplayName("s3 키를 생성할 수 있다") void generateKey() { // given - KeyType keyType = Instancio.create(KeyType.class); + S3KeyPrefix s3KeyPrefix = Instancio.create(S3KeyPrefix.class); // when - String key = s3MediaManager.generateKey(keyType); + String key = s3MediaManager.generateKey(s3KeyPrefix); // then - assertThat(key).contains(keyType.getValue()); + assertThat(key).contains(s3KeyPrefix.getValue()); } @Test @@ -100,7 +101,7 @@ void generateKey() { void extractKey() { // given, when String extractedKey = s3MediaManager.extractKey( - new URLGenerator().get().toExternalForm() + validKey, keyType); + new URLGenerator().get().toExternalForm() + validKey, s3KeyPrefix); // then assertThat(extractedKey).isEqualTo(validKey); From 50800dc29fe279637bf8a8726fecabfc737b731c Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 15:33:42 +0900 Subject: [PATCH 18/74] =?UTF-8?q?refactor:=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔티티의 필드 타입에 맞게 Id 값의 타입은 Reference Type 사용 - 시간 또는 카운트 숫자의 데이터 경우 성능을 고려해서 Primitive Type 사용 --- .../server/auth/domain/AuthTokensGenerator.java | 2 +- .../service/CertificationService.java | 4 ++-- .../matching/implement/MatchingQueueQuery.java | 2 +- .../server/report/implement/ReportQuery.java | 6 +++--- .../infrastructure/ReportQueryRepository.java | 4 ++-- .../report/infrastructure/ReportRepository.java | 4 ++-- .../server/report/service/ReportService.java | 8 ++++---- .../server/user/domain/ReportInfo.java | 2 +- .../server/user/implement/InterestQuery.java | 2 +- .../server/user/presentation/UserController.java | 2 +- .../server/user/service/UserService.java | 2 +- .../admin/presentation/AdminControllerTest.java | 2 +- .../auth/domain/AuthTokensGeneratorTest.java | 10 ++++++---- .../server/auth/domain/JwtTokenProviderTest.java | 2 +- .../server/auth/service/AuthServiceTest.java | 6 ++++-- .../ChattingMessageServiceConcurrencyTest.java | 10 +++++----- .../common/fixture/entity/ReportFixture.java | 2 +- .../presentation/MatchingControllerTest.java | 4 ++-- .../server/report/implement/ReportQueryTest.java | 16 ++++++++-------- .../ReportQueryRepositoryTest.java | 4 ++-- .../server/report/service/ReportServiceTest.java | 6 +++--- 21 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java b/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java index 5446d4cc..9998d86b 100644 --- a/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java +++ b/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java @@ -10,9 +10,9 @@ public class AuthTokensGenerator { private static final String BEARER_TYPE = "Bearer "; - private final JwtTokenProvider jwtTokenProvider; private final Long accessTokenExpireTime; private final Long refreshTokenExpireTime; + private final JwtTokenProvider jwtTokenProvider; private final RefreshTokenCommand refreshTokenCommand; public AuthTokensGenerator(JwtTokenProvider jwtTokenProvider, diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 5c83737e..59489431 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -35,7 +35,7 @@ public class CertificationService { private final VerificationInfoCommand verificationInfoCommand; private final VerificationMailSender verificationMailSender; - public void registerCertification(long userId, String companyName, String email, + public void registerCertification(Long userId, String companyName, String email, String departmentName, File businessCardImage) { CompanyEmail companyEmail = new CompanyEmail(email); Department department = Department.valueOf(departmentName); @@ -47,7 +47,7 @@ public void registerCertification(long userId, String companyName, String email, businessCardImageUrl); } - public void updateCertification(long userId, String companyName, String email, + public void updateCertification(Long userId, String companyName, String email, String departmentName, File businessCardImage) { CompanyEmail companyEmail = new CompanyEmail(email); Department department = Department.valueOf(departmentName); diff --git a/src/main/java/coffeemeet/server/matching/implement/MatchingQueueQuery.java b/src/main/java/coffeemeet/server/matching/implement/MatchingQueueQuery.java index 8a55035f..6047f4cf 100644 --- a/src/main/java/coffeemeet/server/matching/implement/MatchingQueueQuery.java +++ b/src/main/java/coffeemeet/server/matching/implement/MatchingQueueQuery.java @@ -11,7 +11,7 @@ @RequiredArgsConstructor public class MatchingQueueQuery { - private static final long REDIS_IN_PIPELINE_OR_TRANSACTION = 0; + private static final int REDIS_IN_PIPELINE_OR_TRANSACTION = 0; private final RedisTemplate redisTemplate; diff --git a/src/main/java/coffeemeet/server/report/implement/ReportQuery.java b/src/main/java/coffeemeet/server/report/implement/ReportQuery.java index 8694b9ae..10be0822 100644 --- a/src/main/java/coffeemeet/server/report/implement/ReportQuery.java +++ b/src/main/java/coffeemeet/server/report/implement/ReportQuery.java @@ -25,7 +25,7 @@ public class ReportQuery { private final ReportRepository reportRepository; private final ReportQueryRepository reportQueryRepository; - public void hasDuplicatedReport(long reporterId, long chattingRoomId, long targetId) { + public void hasDuplicatedReport(Long reporterId, Long chattingRoomId, Long targetId) { if (reportRepository.existsByReporterIdAndChattingRoomIdAndTargetedId(reporterId, chattingRoomId, targetId)) { @@ -37,7 +37,7 @@ public void hasDuplicatedReport(long reporterId, long chattingRoomId, long targe } } - public Report getReportById(long reportId) { + public Report getReportById(Long reportId) { return reportQueryRepository.findById(reportId) .orElseThrow(() -> new NotFoundException( REPORT_NOT_FOUND, @@ -49,7 +49,7 @@ public List getReportsByIdSet(Set reportIds) { return reportRepository.findByIdIn(reportIds); } - public List getReportsByTargetIdAndChattingRoomId(long targetId, long chattingRoomId) { + public List getReportsByTargetIdAndChattingRoomId(Long targetId, Long chattingRoomId) { List reports = reportQueryRepository.findByTargetIdAndChattingRoomId(targetId, chattingRoomId); if (reports.isEmpty()) { diff --git a/src/main/java/coffeemeet/server/report/infrastructure/ReportQueryRepository.java b/src/main/java/coffeemeet/server/report/infrastructure/ReportQueryRepository.java index 1a38dbff..6d17361b 100644 --- a/src/main/java/coffeemeet/server/report/infrastructure/ReportQueryRepository.java +++ b/src/main/java/coffeemeet/server/report/infrastructure/ReportQueryRepository.java @@ -20,7 +20,7 @@ public class ReportQueryRepository { private final JPAQueryFactory jpaQueryFactory; - public Optional findById(long reportId) { + public Optional findById(Long reportId) { QReport report = QReport.report; Report foundReport = jpaQueryFactory .selectFrom(report) @@ -55,7 +55,7 @@ public List findAll(Long lastReportId, int pageSize) { .fetch(); } - public List findByTargetIdAndChattingRoomId(long targetId, long chattingRoomId) { + public List findByTargetIdAndChattingRoomId(Long targetId, Long chattingRoomId) { QReport report = QReport.report; return jpaQueryFactory .selectFrom(report) diff --git a/src/main/java/coffeemeet/server/report/infrastructure/ReportRepository.java b/src/main/java/coffeemeet/server/report/infrastructure/ReportRepository.java index 2aefad75..4f0f492c 100644 --- a/src/main/java/coffeemeet/server/report/infrastructure/ReportRepository.java +++ b/src/main/java/coffeemeet/server/report/infrastructure/ReportRepository.java @@ -7,8 +7,8 @@ public interface ReportRepository extends JpaRepository { - boolean existsByReporterIdAndChattingRoomIdAndTargetedId(long reporterId, long chattingRoomId, - long targetedId); + boolean existsByReporterIdAndChattingRoomIdAndTargetedId(Long reporterId, Long chattingRoomId, + Long targetedId); List findByIdIn(Collection ids); diff --git a/src/main/java/coffeemeet/server/report/service/ReportService.java b/src/main/java/coffeemeet/server/report/service/ReportService.java index 42421346..78d15e5f 100644 --- a/src/main/java/coffeemeet/server/report/service/ReportService.java +++ b/src/main/java/coffeemeet/server/report/service/ReportService.java @@ -37,7 +37,7 @@ public class ReportService { private final UserChattingHistoryQuery userChattingHistoryQuery; @Transactional - public void reportUser(long reporterId, long chattingRoomId, long targetId, String reason, + public void reportUser(Long reporterId, Long chattingRoomId, Long targetId, String reason, String reasonDetail) { reportQuery.hasDuplicatedReport(reporterId, chattingRoomId, targetId); @@ -77,8 +77,8 @@ public ReportListDto findAllReports(Long lastReportId, int pageSize) { return ReportListDto.of(responses, hasNext); } - public List findReportByTargetIdAndChattingRoomId(long targetId, - long chattingRoomId) { + public List findReportByTargetIdAndChattingRoomId(Long targetId, + Long chattingRoomId) { List reports = reportQuery.getReportsByTargetIdAndChattingRoomId(targetId, chattingRoomId); return reports.stream() @@ -86,7 +86,7 @@ public List findReportByTargetIdAndChattingRoomId(long targetId, .toList(); } - private void checkChattingRoomExists(long reporterId, long chattingRoomId) { + private void checkChattingRoomExists(Long reporterId, Long chattingRoomId) { boolean isChattingRoomExists = false; boolean isChattingHistoryExists = false; diff --git a/src/main/java/coffeemeet/server/user/domain/ReportInfo.java b/src/main/java/coffeemeet/server/user/domain/ReportInfo.java index e81e3443..09adca19 100644 --- a/src/main/java/coffeemeet/server/user/domain/ReportInfo.java +++ b/src/main/java/coffeemeet/server/user/domain/ReportInfo.java @@ -16,7 +16,7 @@ public class ReportInfo { private static final int REPORT_MIN_COUNT = 0; private static final int REPORT_MAX_COUNT = 5; - private Integer reportedCount; + private int reportedCount; private LocalDateTime penaltyExpiration; public ReportInfo() { diff --git a/src/main/java/coffeemeet/server/user/implement/InterestQuery.java b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java index 87d8365f..59e64817 100644 --- a/src/main/java/coffeemeet/server/user/implement/InterestQuery.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java @@ -21,7 +21,7 @@ public List getKeywordsByUserId(Long userId) { .toList(); } - public List findAllByUserId(long userId) { + public List findAllByUserId(Long userId) { return interestRepository.findAllByUserId(userId); } diff --git a/src/main/java/coffeemeet/server/user/presentation/UserController.java b/src/main/java/coffeemeet/server/user/presentation/UserController.java index bbf0a77f..f43c6a16 100644 --- a/src/main/java/coffeemeet/server/user/presentation/UserController.java +++ b/src/main/java/coffeemeet/server/user/presentation/UserController.java @@ -58,7 +58,7 @@ public ResponseEntity login(@PathVariable OAuthProvid } @GetMapping("/{userId}") - public ResponseEntity getUserProfile(@PathVariable long userId) { + public ResponseEntity getUserProfile(@PathVariable Long userId) { UserProfileDto response = userService.findUserProfile(userId); return ResponseEntity.ok(UserProfileHTTP.Response.of(response)); } diff --git a/src/main/java/coffeemeet/server/user/service/UserService.java b/src/main/java/coffeemeet/server/user/service/UserService.java index 11cba705..c9338caf 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -81,7 +81,7 @@ public LoginDetailsDto login(OAuthProvider oAuthProvider, String authCode) { return LoginDetailsDto.of(user, Collections.emptyList(), null, null); } - public UserProfileDto findUserProfile(long userId) { + public UserProfileDto findUserProfile(Long userId) { User user = userQuery.getUserById(userId); List keywords = interestQuery.getKeywordsByUserId(userId); Certification certification = certificationQuery.getCertificationByUserId(userId); diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index bbd39758..faf7d9e6 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -240,7 +240,7 @@ void dismissReport() throws Exception { @DisplayName("신고 내역을 전체 조회할 수 있다.") void findAllReportsTest() throws Exception { // given - long lastReportId = 0L; + Long lastReportId = 0L; int pageSize = 10; ReportDto response1 = ReportDtoFixture.reportDto(); ReportDto response2 = ReportDtoFixture.reportDto(); diff --git a/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java b/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java index 5537d4dd..a7f2c8b1 100644 --- a/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java +++ b/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java @@ -7,6 +7,7 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.auth.implement.RefreshTokenCommand; +import com.github.javafaker.Faker; import java.util.Date; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -19,8 +20,8 @@ @ExtendWith(MockitoExtension.class) class AuthTokensGeneratorTest { - private static final Long accessTokenExpireTime = 1800L; - private static final Long refreshTokenExpireTime = 3600L; + private static final long accessTokenExpireTime = 1800; + private static final long refreshTokenExpireTime = 3600; private static final String BEARER_TYPE = "Bearer "; private static final String ACCESS_TOKEN = "accessToken"; private static final String REFRESH_TOKEN = "refreshToken"; @@ -48,7 +49,7 @@ void generateTest() { REFRESH_TOKEN); // when - AuthTokens authTokens = authTokensGenerator.generate((long) Math.random()); + AuthTokens authTokens = authTokensGenerator.generate(Faker.instance().random().nextLong()); // then assertAll( @@ -65,7 +66,8 @@ void reissueAccessTokenTest() { REFRESH_TOKEN); // when - AuthTokens authTokens = authTokensGenerator.reissueAccessToken((long) Math.random(), + AuthTokens authTokens = authTokensGenerator.reissueAccessToken( + Faker.instance().random().nextLong(), REFRESH_TOKEN); // then diff --git a/src/test/java/coffeemeet/server/auth/domain/JwtTokenProviderTest.java b/src/test/java/coffeemeet/server/auth/domain/JwtTokenProviderTest.java index aae466cb..0aa96e8d 100644 --- a/src/test/java/coffeemeet/server/auth/domain/JwtTokenProviderTest.java +++ b/src/test/java/coffeemeet/server/auth/domain/JwtTokenProviderTest.java @@ -15,7 +15,7 @@ class JwtTokenProviderTest { private static final String SUBJECT = "123"; - private static final int ACCESS_TOKEN_EXPIRE_TIME = 3600000; + private static final long ACCESS_TOKEN_EXPIRE_TIME = 3600000; private final String secretKey = Base64.getEncoder() .encodeToString(Keys.secretKeyFor(SignatureAlgorithm.HS512).getEncoded()); diff --git a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java index 2c7db5b7..e2ad3afa 100644 --- a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java +++ b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java @@ -16,6 +16,7 @@ import coffeemeet.server.common.execption.InvalidAuthException; import coffeemeet.server.common.fixture.dto.AuthTokensFixture; import coffeemeet.server.user.service.UserService; +import com.github.javafaker.Faker; import org.instancio.Instancio; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -56,7 +57,8 @@ void renewTest() { newAuthTokens); // when - AuthTokens renewedAuthTokens = authService.renew((long) Math.random(), REFRESH_TOKEN); + AuthTokens renewedAuthTokens = authService.renew(Faker.instance().random().nextLong(), + REFRESH_TOKEN); // then assertAll( @@ -72,7 +74,7 @@ void renewFailTest() { given(jwtTokenProvider.isExpiredRefreshToken(REFRESH_TOKEN)).willReturn(true); // when, then - assertThatThrownBy(() -> authService.renew((long) Math.random(), REFRESH_TOKEN)) + assertThatThrownBy(() -> authService.renew(Faker.instance().random().nextLong(), REFRESH_TOKEN)) .isInstanceOf(InvalidAuthException.class); } diff --git a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java index 78d322cf..4cc6453b 100644 --- a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java +++ b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java @@ -63,15 +63,15 @@ void chattingConcurrencyTest() throws InterruptedException { String sessionId = "sessionId"; chattingMessageService.storeSocketSession(sessionId, String.valueOf(user.getId())); - int count = 100; - ExecutorService executorService = Executors.newFixedThreadPool(count); - CountDownLatch countDownLatch = new CountDownLatch(count); + int userSize = 4; + ExecutorService executorService = Executors.newFixedThreadPool(userSize); + CountDownLatch countDownLatch = new CountDownLatch(userSize); willDoNothing().given(fcmNotificationSender) .sendNotification(user.getNotificationInfo(), "test"); // when - for (int i = 0; i < count; i++) { + for (int i = 0; i < userSize; i++) { executorService.submit(() -> { try { chattingMessageService.chatting(sessionId, room.getId(), "test"); @@ -86,7 +86,7 @@ void chattingConcurrencyTest() throws InterruptedException { // then List messages = chattingMessageRepository.findAll(); - assertThat(messages).hasSize(count); + assertThat(messages).hasSize(userSize); } } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java index 4d8d1402..1918a192 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java @@ -12,7 +12,7 @@ public static Report report() { .generate(field(Report::getReasonDetail), gen -> gen.string().maxLength(200)).create(); } - public static Report report(long targetId, long chattingRoomId) { + public static Report report(Long targetId, Long chattingRoomId) { return Instancio.of(Report.class) .set(field(Report::getTargetedId), targetId) .set(field(Report::getChattingRoomId), chattingRoomId) diff --git a/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java b/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java index a5e0d721..dc17f20c 100644 --- a/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java +++ b/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java @@ -37,7 +37,7 @@ void setUp() { @DisplayName("매칭 시작 요청을 처리할 수 있다.") void startTest() throws Exception { // given - long userId = 1; + Long userId = 1L; willDoNothing().given(matchingService).startMatching(userId); // when, then @@ -59,7 +59,7 @@ void startTest() throws Exception { @DisplayName("매칭 취소 요청을 처리할 수 있다.") void cancelTest() throws Exception { // given - long userId = 1; + Long userId = 1L; willDoNothing().given(matchingService).cancelMatching(userId); // when, then diff --git a/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java b/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java index 3d8c7d0f..f8166a7e 100644 --- a/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java +++ b/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java @@ -41,9 +41,9 @@ class ReportQueryTest { @Test void hasDuplicatedReportTest() { // given - long reporterId = 1L; - long chattingRoomId = 1L; - long targetId = 1L; + Long reporterId = 1L; + Long chattingRoomId = 1L; + Long targetId = 1L; given(reportRepository.existsByReporterIdAndChattingRoomIdAndTargetedId(anyLong(), anyLong(), anyLong())).willReturn(Boolean.FALSE); @@ -57,9 +57,9 @@ void hasDuplicatedReportTest() { @Test void hasNotDuplicatedReportTest() { // given - long reporterId = 1L; - long chattingRoomId = 1L; - long targetId = 1L; + Long reporterId = 1L; + Long chattingRoomId = 1L; + Long targetId = 1L; given(reportRepository.existsByReporterIdAndChattingRoomIdAndTargetedId(anyLong(), anyLong(), anyLong())).willReturn(Boolean.TRUE); @@ -138,8 +138,8 @@ void getReportsByTargetIdAndChattingRoomIdTest() { @Test void getReportsByTargetIdAndChattingRoomIdFailTest() { // given - long targetedId = 1; - long chattingRoomId = 1; + Long targetedId = 1L; + Long chattingRoomId = 1L; List reports = new ArrayList<>(); given(reportQueryRepository.findByTargetIdAndChattingRoomId(anyLong(), anyLong())).willReturn( diff --git a/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java b/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java index 42247890..0c0a3326 100644 --- a/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java +++ b/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java @@ -38,7 +38,7 @@ void findAllTest() { List reports = List.of(report, report1, report2, sameReport1, sameReport2); reportRepository.saveAll(reports); - long lastReportId = 0L; + Long lastReportId = 0L; int pageSize = 10; // when @@ -108,7 +108,7 @@ void findByIdTest() { @Test void findByIdFailTest() { // when - Optional foundReport = reportQueryRepository.findById(1); + Optional foundReport = reportQueryRepository.findById(1L); // then assertThat(foundReport).isEmpty(); diff --git a/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java b/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java index 5bc20004..2d94c767 100644 --- a/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java +++ b/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java @@ -121,12 +121,12 @@ void findReportTest() { @Test void findAllReportsTest() { // given - long lastReportId = 0L; + Long lastReportId = 0L; int pageSize = 10; User targetUser = user(); ChattingRoom chattingRoom = ChattingFixture.chattingRoom(); - long targetedId = targetUser.getId(); - long chattingRoomId = chattingRoom.getId(); + Long targetedId = targetUser.getId(); + Long chattingRoomId = chattingRoom.getId(); Report report1 = Report.builder() .reporterId(1L).chattingRoomId(chattingRoomId).targetedId(targetedId).reason("잠수") From a74bcc422cf1f9af1a98c4ebee48ee7e311a21d0 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:43:07 +0900 Subject: [PATCH 19/74] =?UTF-8?q?refactor:=20report=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/presentation/AdminController.java | 21 +++++----- .../dto/FindGroupReportsParam.java} | 4 +- .../presentation/dto/GroupReportHTTP.java | 19 ++++++++++ .../presentation/dto/ReportDetailHTTP.java | 2 +- .../presentation/dto/GroupReportHTTP.java | 38 ------------------- .../presentation/dto/ReportListHTTP.java | 17 --------- .../report/service/dto/GroupReportDto.java | 2 + .../server/report/service/dto/ReportDto.java | 2 + .../presentation/AdminControllerTest.java | 29 +++++--------- .../fixture/dto/ReportDetailHTTPFixture.java | 2 +- .../common/fixture/dto/ReportDtoFixture.java | 6 +++ 11 files changed, 51 insertions(+), 91 deletions(-) rename src/main/java/coffeemeet/server/{report/presentation/dto/FindGroupReports.java => admin/presentation/dto/FindGroupReportsParam.java} (59%) create mode 100644 src/main/java/coffeemeet/server/admin/presentation/dto/GroupReportHTTP.java rename src/main/java/coffeemeet/server/{report => admin}/presentation/dto/ReportDetailHTTP.java (95%) delete mode 100644 src/main/java/coffeemeet/server/report/presentation/dto/GroupReportHTTP.java delete mode 100644 src/main/java/coffeemeet/server/report/presentation/dto/ReportListHTTP.java diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index d45122be..d1640b5f 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -3,7 +3,10 @@ import coffeemeet.server.admin.presentation.dto.AdminCustomPage; import coffeemeet.server.admin.presentation.dto.AdminCustomSlice; import coffeemeet.server.admin.presentation.dto.AdminLoginHTTP; +import coffeemeet.server.admin.presentation.dto.FindGroupReportsParam; +import coffeemeet.server.admin.presentation.dto.GroupReportHTTP; import coffeemeet.server.admin.presentation.dto.ReportDeletionHTTP; +import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; @@ -15,14 +18,10 @@ import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary; -import coffeemeet.server.report.presentation.dto.FindGroupReports; -import coffeemeet.server.report.presentation.dto.GroupReportHTTP; -import coffeemeet.server.report.presentation.dto.ReportDetailHTTP; -import coffeemeet.server.report.presentation.dto.ReportListHTTP; -import coffeemeet.server.report.presentation.dto.ReportListHTTP.Response; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; import coffeemeet.server.report.service.dto.ReportDetailDto; +import coffeemeet.server.report.service.dto.ReportDto; import coffeemeet.server.report.service.dto.ReportListDto; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; @@ -128,7 +127,7 @@ public ResponseEntity dismissReport( } @GetMapping("/reports") - public ResponseEntity> findAllReports( + public ResponseEntity> findAllReports( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") Long lastReportId, @RequestParam(defaultValue = "10") int pageSize @@ -137,22 +136,20 @@ public ResponseEntity> findAllReports( // throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE); // } ReportListDto reportListDto = reportService.findAllReports(lastReportId, pageSize); - List responses = reportListDto.contents().stream() - .map(Response::from) - .toList(); - return ResponseEntity.ok(AdminCustomSlice.of(responses, reportListDto.hasNext())); + return ResponseEntity.ok( + AdminCustomSlice.of(reportListDto.contents(), reportListDto.hasNext())); } @GetMapping("/reports/group") public ResponseEntity findReportByTargetIdAndChattingRoomId( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, - @ModelAttribute FindGroupReports findGroupReports + @ModelAttribute FindGroupReportsParam findGroupReportsParam ) { // if (adminId == null) { // throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE); // } List responses = reportService.findReportByTargetIdAndChattingRoomId( - findGroupReports.targetedId(), findGroupReports.chattingRoomId()); + findGroupReportsParam.targetedId(), findGroupReportsParam.chattingRoomId()); return ResponseEntity.ok(GroupReportHTTP.Response.from(responses)); } diff --git a/src/main/java/coffeemeet/server/report/presentation/dto/FindGroupReports.java b/src/main/java/coffeemeet/server/admin/presentation/dto/FindGroupReportsParam.java similarity index 59% rename from src/main/java/coffeemeet/server/report/presentation/dto/FindGroupReports.java rename to src/main/java/coffeemeet/server/admin/presentation/dto/FindGroupReportsParam.java index ee82944f..833c4420 100644 --- a/src/main/java/coffeemeet/server/report/presentation/dto/FindGroupReports.java +++ b/src/main/java/coffeemeet/server/admin/presentation/dto/FindGroupReportsParam.java @@ -1,8 +1,8 @@ -package coffeemeet.server.report.presentation.dto; +package coffeemeet.server.admin.presentation.dto; import jakarta.validation.constraints.NotNull; -public record FindGroupReports( +public record FindGroupReportsParam( @NotNull Long chattingRoomId, @NotNull diff --git a/src/main/java/coffeemeet/server/admin/presentation/dto/GroupReportHTTP.java b/src/main/java/coffeemeet/server/admin/presentation/dto/GroupReportHTTP.java new file mode 100644 index 00000000..5d951e2b --- /dev/null +++ b/src/main/java/coffeemeet/server/admin/presentation/dto/GroupReportHTTP.java @@ -0,0 +1,19 @@ +package coffeemeet.server.admin.presentation.dto; + +import static lombok.AccessLevel.PRIVATE; + +import coffeemeet.server.report.service.dto.GroupReportDto; +import java.util.List; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = PRIVATE) +public final class GroupReportHTTP { + + public record Response(List groupReports) { + + public static Response from(List responses) { + return new Response(responses); + } + } + +} diff --git a/src/main/java/coffeemeet/server/report/presentation/dto/ReportDetailHTTP.java b/src/main/java/coffeemeet/server/admin/presentation/dto/ReportDetailHTTP.java similarity index 95% rename from src/main/java/coffeemeet/server/report/presentation/dto/ReportDetailHTTP.java rename to src/main/java/coffeemeet/server/admin/presentation/dto/ReportDetailHTTP.java index b20c0f02..811a34ab 100644 --- a/src/main/java/coffeemeet/server/report/presentation/dto/ReportDetailHTTP.java +++ b/src/main/java/coffeemeet/server/admin/presentation/dto/ReportDetailHTTP.java @@ -1,4 +1,4 @@ -package coffeemeet.server.report.presentation.dto; +package coffeemeet.server.admin.presentation.dto; import static lombok.AccessLevel.PRIVATE; diff --git a/src/main/java/coffeemeet/server/report/presentation/dto/GroupReportHTTP.java b/src/main/java/coffeemeet/server/report/presentation/dto/GroupReportHTTP.java deleted file mode 100644 index ead3537f..00000000 --- a/src/main/java/coffeemeet/server/report/presentation/dto/GroupReportHTTP.java +++ /dev/null @@ -1,38 +0,0 @@ -package coffeemeet.server.report.presentation.dto; - -import static lombok.AccessLevel.PRIVATE; - -import coffeemeet.server.report.service.dto.GroupReportDto; -import java.time.LocalDateTime; -import java.util.List; -import lombok.NoArgsConstructor; - -@NoArgsConstructor(access = PRIVATE) -public final class GroupReportHTTP { - - public record GroupReport( - String reporterNickname, - Long reportId, - LocalDateTime createdAt - ) { - - public static GroupReport from(GroupReportDto response) { - return new GroupReport( - response.reporterNickname(), - response.reportId(), - response.createdAt() - ); - } - } - - public record Response(List groupReports) { - - public static Response from(List responses) { - List groupReportList = responses.stream() - .map(GroupReport::from) - .toList(); - return new Response(groupReportList); - } - } - -} diff --git a/src/main/java/coffeemeet/server/report/presentation/dto/ReportListHTTP.java b/src/main/java/coffeemeet/server/report/presentation/dto/ReportListHTTP.java deleted file mode 100644 index 11a43d7e..00000000 --- a/src/main/java/coffeemeet/server/report/presentation/dto/ReportListHTTP.java +++ /dev/null @@ -1,17 +0,0 @@ -package coffeemeet.server.report.presentation.dto; - -import coffeemeet.server.report.service.dto.ReportDto; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class ReportListHTTP { - - public record Response(ReportDto content) { - - public static Response from(ReportDto content) { - return new Response(content); - } - } - -} diff --git a/src/main/java/coffeemeet/server/report/service/dto/GroupReportDto.java b/src/main/java/coffeemeet/server/report/service/dto/GroupReportDto.java index ba337d81..37bcc95f 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/GroupReportDto.java +++ b/src/main/java/coffeemeet/server/report/service/dto/GroupReportDto.java @@ -1,10 +1,12 @@ package coffeemeet.server.report.service.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; public record GroupReportDto( String reporterNickname, Long reportId, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt ) { diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportDto.java b/src/main/java/coffeemeet/server/report/service/dto/ReportDto.java index 56697b4f..5ab7a6f5 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportDto.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportDto.java @@ -2,6 +2,7 @@ import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; public record ReportDto( @@ -9,6 +10,7 @@ public record ReportDto( String chattingRoomName, Long targetedId, Long chattingRoomId, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt ) { diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index faf7d9e6..4cf0bf61 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -31,6 +31,8 @@ import coffeemeet.server.admin.presentation.dto.AdminCustomPage; import coffeemeet.server.admin.presentation.dto.AdminCustomSlice; +import coffeemeet.server.admin.presentation.dto.GroupReportHTTP; +import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; import coffeemeet.server.certification.service.dto.PendingCertification; @@ -47,10 +49,6 @@ import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary; -import coffeemeet.server.report.presentation.dto.GroupReportHTTP; -import coffeemeet.server.report.presentation.dto.ReportDetailHTTP; -import coffeemeet.server.report.presentation.dto.ReportListHTTP; -import coffeemeet.server.report.presentation.dto.ReportListHTTP.Response; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; import coffeemeet.server.report.service.dto.ReportDetailDto; @@ -242,17 +240,8 @@ void findAllReportsTest() throws Exception { // given Long lastReportId = 0L; int pageSize = 10; - ReportDto response1 = ReportDtoFixture.reportDto(); - ReportDto response2 = ReportDtoFixture.reportDto(); - - List reportResponses = List.of(response1, response2); - boolean hasNext = true; - - ReportListDto reportListDto = ReportListDto.of(reportResponses, hasNext); - List responses = reportListDto.contents().stream() - .map(Response::from) - .toList(); - AdminCustomPage result = new AdminCustomPage<>(responses, + ReportListDto reportListDto = ReportDtoFixture.reportListDto(); + AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), reportListDto.hasNext()); given(reportService.findAllReports(lastReportId, pageSize)).willReturn(reportListDto); @@ -274,15 +263,15 @@ void findAllReportsTest() throws Exception { responseFields( fieldWithPath("contents").description("신고 조회 내역 리스트"), fieldWithPath("hasNext").type(JsonFieldType.BOOLEAN).description("다음 페이지 존재 여부"), - fieldWithPath("contents.[].content.targetedNickname").type(JsonFieldType.STRING) + fieldWithPath("contents[].targetedNickname").type(JsonFieldType.STRING) .description("신고 대상 닉네임"), - fieldWithPath("contents.[].content.chattingRoomName").type(JsonFieldType.STRING) + fieldWithPath("contents[].chattingRoomName").type(JsonFieldType.STRING) .description("신고 대상 채팅방 이름"), - fieldWithPath("contents.[].content.targetedId").type(JsonFieldType.NUMBER) + fieldWithPath("contents[].targetedId").type(JsonFieldType.NUMBER) .description("신고 대상 아이디"), - fieldWithPath("contents.[].content.chattingRoomId").type(JsonFieldType.NUMBER) + fieldWithPath("contents[].chattingRoomId").type(JsonFieldType.NUMBER) .description("신고 대상 채팅방 이름"), - fieldWithPath("contents.[].content.createdAt").type(JsonFieldType.STRING) + fieldWithPath("contents[].createdAt").type(JsonFieldType.STRING) .description("신고 생성 날짜") ) )) diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java index f00b3cd8..bf67139a 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java @@ -1,6 +1,6 @@ package coffeemeet.server.common.fixture.dto; -import coffeemeet.server.report.presentation.dto.ReportDetailHTTP; +import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.report.service.dto.ReportDetailDto; public class ReportDetailHTTPFixture { diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java index 8ceba086..7eef970b 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java @@ -1,6 +1,7 @@ package coffeemeet.server.common.fixture.dto; import coffeemeet.server.report.service.dto.ReportDto; +import coffeemeet.server.report.service.dto.ReportListDto; import org.instancio.Instancio; public class ReportDtoFixture { @@ -10,4 +11,9 @@ public static ReportDto reportDto() { .create(); } + public static ReportListDto reportListDto() { + return Instancio.of(ReportListDto.class) + .create(); + } + } From c57e23639f87b4665e02f953231512d2f37b7c86 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:59:05 +0900 Subject: [PATCH 20/74] =?UTF-8?q?refactor:=20certification=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/admin/presentation/AdminController.java | 6 +++--- .../certification/service/CertificationService.java | 3 +++ ...tification.java => PendingCertificationDto.java} | 6 +++--- .../admin/presentation/AdminControllerTest.java | 6 +++--- .../common/fixture/entity/CertificationFixture.java | 13 +++++++------ 5 files changed, 19 insertions(+), 15 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertification.java => PendingCertificationDto.java} (78%) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index d1640b5f..2125df13 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -10,7 +10,7 @@ import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; @@ -203,7 +203,7 @@ public ResponseEntity checkInquiry( // TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요 @PerformanceMeasurement @GetMapping("/certifications/pending") - public ResponseEntity> getPendingCertifications( + public ResponseEntity> getPendingCertifications( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int size @@ -217,7 +217,7 @@ public ResponseEntity> getPendingCertifica PendingCertificationPageDto uncertifiedUserRequests = certificationService.getUncertifiedUserRequests( pageable); - Page page = uncertifiedUserRequests.page(); + Page page = uncertifiedUserRequests.page(); return ResponseEntity.ok( AdminCustomPage.of(page.getContent(), page.hasNext()) ); diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 59489431..98d5b951 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -13,6 +13,9 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java index 7b59a245..1ff1650a 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertification( +public record PendingCertificationDto( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertification( String department ) { - public static PendingCertification from(Certification certification) { - return new PendingCertification( + public static PendingCertificationDto from(Certification certification) { + return new PendingCertificationDto( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 4cf0bf61..bc1c5078 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -35,7 +35,7 @@ import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.dto.GroupReportDtoFixture; @@ -460,8 +460,8 @@ void getPendingCertificationsTest() throws Exception { Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); - Page page = pendingCertificationPageDto.page(); - AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( + Page page = pendingCertificationPageDto.page(); + AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( page.getContent(), page.hasNext()); given(certificationService.getUncertifiedUserRequests(any())).willReturn( diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java index 3f9863d5..c4334d63 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java @@ -9,7 +9,7 @@ import coffeemeet.server.certification.domain.VerificationInfo; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -138,13 +138,14 @@ private static List certificationsNotCertificated(int size) { } public static PendingCertificationPageDto pendingCertificationPageDto(int size) { - return new PendingCertificationPageDto(new PageImpl<>(pendingCertifications(size))); + return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); } - private static List pendingCertifications(int size) { - return Instancio.ofList(PendingCertification.class).size(size) - .generate(field(PendingCertification::businessCardUrl), gen -> gen.net().url().asString()) - .generate(field(PendingCertification::companyEmail), gen -> gen.net().email()).create(); + private static List pendingCertifications(int size) { + return Instancio.ofList(PendingCertificationDto.class).size(size) + .generate(field(PendingCertificationDto::businessCardUrl), + gen -> gen.net().url().asString()) + .generate(field(PendingCertificationDto::companyEmail), gen -> gen.net().email()).create(); } } From ea1ad6980a4f2c7f788e086439db6b7c15cc2804 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 17:33:03 +0900 Subject: [PATCH 21/74] =?UTF-8?q?refactor:=20chatting=20current=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChattingMessageController.java | 2 +- .../presentation/ChattingRoomController.java | 6 +-- .../current/presentation/dto/ChatStomp.java | 2 +- .../current/presentation/dto/ChatsHTTP.java | 36 +++------------ .../service/ChattingMessageService.java | 4 +- .../current/service/ChattingRoomService.java | 13 ++++-- .../current/service/dto/ChattingDto.java | 44 ++++++++----------- .../current/service/dto/ChattingListDto.java | 14 ++++++ .../dto/ChattingMessageHistoryDto.java | 2 + .../service/dto/ChattingRoomHistoryDto.java | 2 + .../inquiry/service/dto/InquiryDetailDto.java | 2 + .../report/service/dto/ReportDetailDto.java | 2 + .../ChattingRoomControllerTest.java | 12 +++-- .../service/ChattingMessageServiceTest.java | 15 +++---- .../service/ChattingRoomServiceTest.java | 6 +-- .../fixture/entity/ChattingFixture.java | 12 ++--- 16 files changed, 83 insertions(+), 91 deletions(-) create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java index 522d9e6a..eda15e1e 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java @@ -42,7 +42,7 @@ public void onDisconnect(SessionDisconnectEvent event) { @MessageMapping("/chatting/messages") public void message(@Valid ChatStomp.Request request, SimpMessageHeaderAccessor accessor) { - ChattingDto.Response response = chattingMessageService.chatting( + ChattingDto response = chattingMessageService.chatting( accessor.getSessionId(), request.roomId(), request.content() diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java index 49970e3a..43b955a4 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java @@ -4,8 +4,7 @@ import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; import coffeemeet.server.chatting.current.service.ChattingRoomService; import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; -import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; -import java.util.List; +import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -27,7 +26,8 @@ public ResponseEntity viewChattingRoomMessages( @PathVariable Long roomId, @RequestParam(defaultValue = "0") Long firstMessageId, @RequestParam(defaultValue = "50") int pageSize) { - List responses = chattingRoomService.searchMessages(roomId, firstMessageId, pageSize); + ChattingListDto responses = chattingRoomService.searchMessages(roomId, firstMessageId, + pageSize); return ResponseEntity.ok(ChatsHTTP.Response.from(responses)); } diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java index 62ad356f..9945b963 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java @@ -31,7 +31,7 @@ public record Response( LocalDateTime createdAt ) { - public static ChatStomp.Response from(ChattingDto.Response response) { + public static ChatStomp.Response from(ChattingDto response) { return new ChatStomp.Response( response.userId(), response.messageId(), diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java index 0ca1593f..c4a712b4 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java @@ -3,46 +3,20 @@ import static lombok.AccessLevel.PRIVATE; import coffeemeet.server.chatting.current.service.dto.ChattingDto; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; +import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import java.util.List; import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) public final class ChatsHTTP { - public record Chat( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt - ) { - - public static Chat from(ChattingDto.Response response) { - return new Chat( - response.userId(), - response.messageId(), - response.nickname(), - response.content(), - response.profileImageUrl(), - response.createdAt() - ); - } - - } - public record Response( - List chats + List chats, + boolean hasNext ) { - public static Response from(List responses) { - List chatList = responses.stream() - .map(Chat::from) - .toList(); - return new Response(chatList); + public static Response from(ChattingListDto chattingListDto) { + return new Response(chattingListDto.contents(), chattingListDto.hasNext()); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java index 1967c4ca..f1183170 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java @@ -31,7 +31,7 @@ public class ChattingMessageService { private final UserCommand userCommand; private final FCMNotificationSender fcmNotificationSender; - public ChattingDto.Response chatting(String sessionId, Long roomId, String content) { + public ChattingDto chatting(String sessionId, Long roomId, String content) { Long userId = chattingSessionQuery.getUserIdById(sessionId); ChattingRoom room = chattingRoomQuery.getChattingRoomById(roomId); List users = userQuery.getUsersByRoom(room); @@ -39,7 +39,7 @@ public ChattingDto.Response chatting(String sessionId, Long roomId, String conte sendChattingAlarm(user.getProfile().getNickname(), content, users); ChattingMessage chattingMessage = chattingMessageCommand.createChattingMessage(content, room, user); - return ChattingDto.Response.of(user, chattingMessage); + return ChattingDto.of(user, chattingMessage); } private void sendChattingAlarm(String chattingUserNickname, String content, List users) { diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java index af7fc722..48c12520 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java @@ -7,7 +7,7 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingDto; -import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; +import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; @@ -45,10 +45,15 @@ public Long createChattingRoom() { } @Transactional - public List searchMessages(Long roomId, Long firstMessageId, int pageSize) { + public ChattingListDto searchMessages(Long roomId, Long firstMessageId, int pageSize) { ChattingRoom chattingRoom = chattingRoomQuery.getChattingRoomById(roomId); - return chattingMessageQuery.findMessages(chattingRoom, firstMessageId, pageSize).stream() - .map(message -> ChattingDto.Response.of(message.getUser(), message)).toList(); + List chattingMessages = chattingMessageQuery.findMessages(chattingRoom, + firstMessageId, + pageSize); + boolean hasNext = chattingMessages.size() >= pageSize; + List chattingDtoList = chattingMessages.stream() + .map(message -> ChattingDto.of(message.getUser(), message)).toList(); + return ChattingListDto.of(chattingDtoList, hasNext); } @Transactional diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java index caa21456..965a05a8 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java @@ -1,35 +1,29 @@ package coffeemeet.server.chatting.current.service.dto; -import static lombok.AccessLevel.PRIVATE; - import coffeemeet.server.chatting.current.domain.ChattingMessage; import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -import lombok.NoArgsConstructor; - -@NoArgsConstructor(access = PRIVATE) -public final class ChattingDto { - - public record Response( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - LocalDateTime createdAt - ) { - public static Response of(User user, ChattingMessage chattingMessage) { - return new Response( - user.getId(), - chattingMessage.getId(), - user.getProfile().getNickname(), - chattingMessage.getMessage(), - user.getOauthInfo().getProfileImageUrl(), - chattingMessage.getCreatedAt() - ); - } +public record ChattingDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + public static ChattingDto of(User user, ChattingMessage chattingMessage) { + return new ChattingDto( + user.getId(), + chattingMessage.getId(), + user.getProfile().getNickname(), + chattingMessage.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessage.getCreatedAt() + ); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java new file mode 100644 index 00000000..15aa6ff1 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java @@ -0,0 +1,14 @@ +package coffeemeet.server.chatting.current.service.dto; + +import java.util.List; + +public record ChattingListDto( + List contents, + boolean hasNext +) { + + public static ChattingListDto of(List contents, boolean hasNext) { + return new ChattingListDto(contents, hasNext); + } + +} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java index c8d4564a..bd73070c 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java @@ -2,6 +2,7 @@ import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; public sealed interface ChattingMessageHistoryDto permits ChattingMessageHistoryDto.Response { @@ -12,6 +13,7 @@ record Response( String nickname, String content, String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt ) implements ChattingMessageHistoryDto { diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java index 7d909400..e1f3dbc1 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java @@ -2,6 +2,7 @@ import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; import java.util.List; @@ -11,6 +12,7 @@ record Response( Long roomId, String roomName, List users, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt ) implements ChattingRoomHistoryDto { diff --git a/src/main/java/coffeemeet/server/inquiry/service/dto/InquiryDetailDto.java b/src/main/java/coffeemeet/server/inquiry/service/dto/InquiryDetailDto.java index e42de126..bbf934a8 100644 --- a/src/main/java/coffeemeet/server/inquiry/service/dto/InquiryDetailDto.java +++ b/src/main/java/coffeemeet/server/inquiry/service/dto/InquiryDetailDto.java @@ -2,6 +2,7 @@ import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; public record InquiryDetailDto( @@ -10,6 +11,7 @@ public record InquiryDetailDto( String inquirerEmail, String title, String content, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt ) { diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportDetailDto.java b/src/main/java/coffeemeet/server/report/service/dto/ReportDetailDto.java index f5aa122f..b8252990 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportDetailDto.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportDetailDto.java @@ -3,6 +3,7 @@ import coffeemeet.server.report.domain.Report; import coffeemeet.server.report.domain.ReportReason; import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; public record ReportDetailDto( @@ -12,6 +13,7 @@ public record ReportDetailDto( ReportReason reason, String reasonDetail, int reportedCount, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt ) { diff --git a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java index 9fdb3d02..b4379215 100644 --- a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java @@ -20,14 +20,12 @@ import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; -import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP.Chat; import coffeemeet.server.chatting.current.service.ChattingRoomService; import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; -import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; +import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.entity.ChattingFixture; import com.epages.restdocs.apispec.Schema; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -48,9 +46,8 @@ void viewChattingRoomMessagesTest() throws Exception { Long roomId = 1L; Long firstMessageId = 51L; int pageSize = 50; - List responses = ChattingFixture.chattingDtoResponse(pageSize); - List chats = responses.stream().map(Chat::from).toList(); - ChatsHTTP.Response chatsHTTPResponse = ChattingFixture.chatsHTTPResponse(chats); + ChattingListDto responses = ChattingFixture.chattingListDto(); + ChatsHTTP.Response chatsHTTPResponse = ChattingFixture.chatsHTTPResponse(responses); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); given(chattingRoomService.searchMessages(roomId, firstMessageId, pageSize)).willReturn( @@ -81,7 +78,8 @@ void viewChattingRoomMessagesTest() throws Exception { fieldWithPath("chats[].nickname").type(JsonFieldType.STRING).description("닉네임"), fieldWithPath("chats[].content").type(JsonFieldType.STRING) .description("내용"), - fieldWithPath("chats[].createdAt").type(JsonFieldType.STRING).description("생성 기간") + fieldWithPath("chats[].createdAt").type(JsonFieldType.STRING).description("생성 기간"), + fieldWithPath("hasNext").type(JsonFieldType.BOOLEAN).description("다음 페이지 존재 여부") ) ) ) diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index 9f6eade5..2f8fae3d 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -1,9 +1,9 @@ package coffeemeet.server.chatting.current.service; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingMessage; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingRoom; -import static coffeemeet.server.common.fixture.entity.UserFixture.fourUsers; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingMessage; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; +import static coffeemeet.server.common.fixture.UserFixture.fourUsers; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; @@ -19,7 +19,7 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; -import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; +import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserCommand; @@ -76,13 +76,12 @@ void chattingTest() { given(chattingRoomQuery.getChattingRoomById(chattingRoom.getId())).willReturn(chattingRoom); given(userQuery.getUsersByRoom(chattingRoom)).willReturn(users); given(userQuery.getUserById(user.getId())).willReturn(user); - willDoNothing().given(fcmNotificationSender) - .sendMultiNotifications(anySet(), any()); + willDoNothing().given(fcmNotificationSender).sendMultiNotifications(anySet(), any()); given(chattingMessageCommand.createChattingMessage(content, chattingRoom, user)).willReturn( chattingMessage); // when - Response response = chattingMessageService.chatting(chattingSession.sessionId(), + ChattingDto response = chattingMessageService.chatting(chattingSession.sessionId(), chattingRoom.getId(), content); // then diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java index 30056a42..36c6db27 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java @@ -14,7 +14,7 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; -import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; +import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryCommand; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryCommand; @@ -93,11 +93,11 @@ void searchMessagesTest(Long firstMessageId, int pageSize) { chattingMessages); // when - List responses = chattingRoomService.searchMessages(chattingRoomId, firstMessageId, + ChattingListDto responses = chattingRoomService.searchMessages(chattingRoomId, firstMessageId, pageSize); // then - assertThat(responses).hasSize(pageSize); + assertThat(responses.contents()).hasSize(pageSize); } @DisplayName("현재 채팅방 백업 및 삭제 후, 유저의 상태 변경 및 알람 전송을 할 수 있다.") diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java index 1b6b4879..7d6a023d 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java @@ -7,9 +7,8 @@ import coffeemeet.server.chatting.current.domain.ChattingSession; import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; -import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP.Chat; import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; @@ -51,8 +50,8 @@ public static ChattingRoom chattingRoom() { .create(); } - public static List chattingDtoResponse(int size) { - return Instancio.ofList(ChattingDto.Response.class).size(size) + public static ChattingListDto chattingListDto() { + return Instancio.of(ChattingListDto.class) .create(); } @@ -67,9 +66,10 @@ public static List chattingMessageHistoryDto .create(); } - public static ChatsHTTP.Response chatsHTTPResponse(List chats) { + public static ChatsHTTP.Response chatsHTTPResponse(ChattingListDto chats) { return Instancio.of(ChatsHTTP.Response.class) - .set(field(ChatsHTTP.Response::chats), chats) + .set(field(ChatsHTTP.Response::chats), chats.contents()) + .set(field(ChatsHTTP.Response::hasNext), chats.hasNext()) .create(); } From d82c9644851b59c9d67d845d08048f11ee9b378a Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 18:06:02 +0900 Subject: [PATCH 22/74] =?UTF-8?q?refactor:=20chatting=20history=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChattingRoomHistoryController.java | 13 +++--- .../dto/ChattingMessageHistoriesHTTP.java | 44 +++++-------------- .../dto/ChattingRoomHistoriesHTTP.java | 36 ++++----------- .../service/ChattingRoomHistoryService.java | 18 +++++--- .../dto/ChattingMessageHistoryDto.java | 41 ++++++++--------- .../dto/ChattingMessageHistoryListDto.java | 15 +++++++ .../service/dto/ChattingRoomHistoryDto.java | 38 ++++++++-------- .../ChattingRoomHistoryControllerTest.java | 25 +++++------ .../ChattingRoomHistoryServiceTest.java | 6 +-- .../fixture/entity/ChattingFixture.java | 38 ++++++++-------- 10 files changed, 123 insertions(+), 151 deletions(-) create mode 100644 src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java b/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java index a0e4a933..6f7f6ec8 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java @@ -3,8 +3,8 @@ import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; import coffeemeet.server.chatting.history.service.ChattingRoomHistoryService; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto; -import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto.Response; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.domain.AuthInfo; import java.util.List; @@ -27,9 +27,9 @@ public class ChattingRoomHistoryController { public ResponseEntity viewChattingRoomHistories( @Login AuthInfo authInfo ) { - List responses = chattingRoomHistoryService.searchChattingRoomHistories( + List chattingRoomHistories = chattingRoomHistoryService.searchChattingRoomHistories( authInfo.userId()); - return ResponseEntity.ok(ChattingRoomHistoriesHTTP.Response.from(responses)); + return ResponseEntity.ok(ChattingRoomHistoriesHTTP.Response.from(chattingRoomHistories)); } @GetMapping("/{roomHistoryId}") @@ -37,9 +37,10 @@ public ResponseEntity viewChattingRoomMes @PathVariable Long roomHistoryId, @RequestParam(defaultValue = "0") Long firstMessageId, @RequestParam(defaultValue = "50") int pageSize) { - List responses = chattingRoomHistoryService.searchChattingMessageHistories( + ChattingMessageHistoryListDto chattingMessageHistoryListDto = chattingRoomHistoryService.searchChattingMessageHistories( roomHistoryId, firstMessageId, pageSize); - return ResponseEntity.ok(ChattingMessageHistoriesHTTP.Response.from(responses)); + return ResponseEntity.ok( + ChattingMessageHistoriesHTTP.Response.from(chattingMessageHistoryListDto)); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java index 5a78ab5d..43201573 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java @@ -1,42 +1,22 @@ package coffeemeet.server.chatting.history.presentation.dto; +import static lombok.AccessLevel.PRIVATE; + import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import java.util.List; +import lombok.NoArgsConstructor; -public sealed interface ChattingMessageHistoriesHTTP permits ChattingMessageHistoriesHTTP.Response { - - record ChatHistory( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt - ) { - - public static ChatHistory from(ChattingMessageHistoryDto.Response response) { - return new ChatHistory( - response.userId(), - response.messageId(), - response.nickname(), - response.content(), - response.profileImageUrl(), - response.createdAt() - ); - } - - } +@NoArgsConstructor(access = PRIVATE) +public final class ChattingMessageHistoriesHTTP { - record Response(List chatHistories) implements ChattingMessageHistoriesHTTP { + public record Response( + List chatHistories, + boolean hasNext) { - public static Response from(List responses) { - List chatHistoryList = responses.stream() - .map(ChatHistory::from) - .toList(); - return new Response(chatHistoryList); + public static Response from(ChattingMessageHistoryListDto chattingMessageHistoryListDto) { + return new Response(chattingMessageHistoryListDto.contents(), + chattingMessageHistoryListDto.hasNext()); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingRoomHistoriesHTTP.java b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingRoomHistoriesHTTP.java index 379041db..4aff76d1 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingRoomHistoriesHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingRoomHistoriesHTTP.java @@ -1,38 +1,18 @@ package coffeemeet.server.chatting.history.presentation.dto; +import static lombok.AccessLevel.PRIVATE; + import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; import java.util.List; +import lombok.NoArgsConstructor; -public sealed interface ChattingRoomHistoriesHTTP permits ChattingRoomHistoriesHTTP.Response { - - record ChatRoomHistory( - Long roomId, - String roomName, - List users, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt - ) { - - public static ChatRoomHistory from(ChattingRoomHistoryDto.Response response) { - return new ChatRoomHistory( - response.roomId(), - response.roomName(), - response.users(), - response.createdAt() - ); - } - - } +@NoArgsConstructor(access = PRIVATE) +public final class ChattingRoomHistoriesHTTP { - record Response(List chatRoomHistories) implements ChattingRoomHistoriesHTTP { + public record Response(List chatRoomHistories) { - public static Response from(List responses) { - List roomHistories = responses.stream() - .map(ChatRoomHistory::from) - .toList(); - return new Response(roomHistories); + public static Response from(List responses) { + return new Response(responses); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java index ca2d3e96..b784e6f7 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java @@ -1,11 +1,13 @@ package coffeemeet.server.chatting.history.service; +import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryQuery; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; @@ -23,7 +25,7 @@ public class ChattingRoomHistoryService { private final UserQuery userQuery; // TODO: 11/20/23 쿼리 로직 수정 - public List searchChattingRoomHistories(Long userId) { + public List searchChattingRoomHistories(Long userId) { User user = userQuery.getUserById(userId); List userChattingHistories = userChattingHistoryQuery.getUserChattingHistoriesBy( user); @@ -37,22 +39,26 @@ public List searchChattingRoomHistories(Long us .stream() .map(UserChattingHistory::getUser) .toList(); - return ChattingRoomHistoryDto.Response.of(users, chattingRoomHistory); + return ChattingRoomHistoryDto.of(users, chattingRoomHistory); }) .toList(); } // TODO: 11/20/23 캐쉬 로직 적용 - public List searchChattingMessageHistories(Long roomHistoryId, + public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHistoryId, Long firstMessageId, int pageSize) { ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy( roomHistoryId); - return chattingMessageHistoryQuery.getMessageHistories(chattingRoomHistory, firstMessageId, - pageSize) + List messageHistories = chattingMessageHistoryQuery.getMessageHistories( + chattingRoomHistory, firstMessageId, + pageSize); + boolean hasNext = messageHistories.size() >= pageSize; + List historyDtoList = messageHistories .stream() - .map(chattingMessageHistory -> ChattingMessageHistoryDto.Response.of( + .map(chattingMessageHistory -> ChattingMessageHistoryDto.of( chattingMessageHistory.getUser(), chattingMessageHistory)) .toList(); + return ChattingMessageHistoryListDto.of(historyDtoList, hasNext); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java index bd73070c..35f75769 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java @@ -5,29 +5,26 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public sealed interface ChattingMessageHistoryDto permits ChattingMessageHistoryDto.Response { - - record Response( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt - ) implements ChattingMessageHistoryDto { - - public static Response of(User user, ChattingMessageHistory chattingMessageHistory) { - return new Response( - user.getId(), - chattingMessageHistory.getId(), - user.getProfile().getNickname(), - chattingMessageHistory.getMessage(), - user.getOauthInfo().getProfileImageUrl(), - chattingMessageHistory.getCreatedAt() - ); - } +public record ChattingMessageHistoryDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + public static ChattingMessageHistoryDto of(User user, + ChattingMessageHistory chattingMessageHistory) { + return new ChattingMessageHistoryDto( + user.getId(), + chattingMessageHistory.getId(), + user.getProfile().getNickname(), + chattingMessageHistory.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessageHistory.getCreatedAt() + ); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java new file mode 100644 index 00000000..30eeacb9 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java @@ -0,0 +1,15 @@ +package coffeemeet.server.chatting.history.service.dto; + +import java.util.List; + +public record ChattingMessageHistoryListDto( + List contents, + boolean hasNext +) { + + public static ChattingMessageHistoryListDto of(List contents, + boolean hasNext) { + return new ChattingMessageHistoryListDto(contents, hasNext); + } + +} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java index e1f3dbc1..4a6b3934 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingRoomHistoryDto.java @@ -6,27 +6,25 @@ import java.time.LocalDateTime; import java.util.List; -public sealed interface ChattingRoomHistoryDto permits ChattingRoomHistoryDto.Response { +public record ChattingRoomHistoryDto( + Long roomId, + String roomName, + List users, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { - record Response( - Long roomId, - String roomName, - List users, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt - ) implements ChattingRoomHistoryDto { - - public static Response of(List users, ChattingRoomHistory chattingRoomHistory) { - List userNicknames = users.stream() - .map(user -> user.getProfile().getNickname()) - .toList(); - return new Response( - chattingRoomHistory.getId(), - chattingRoomHistory.getName(), - userNicknames, - chattingRoomHistory.getCreatedAt() - ); - } + public static ChattingRoomHistoryDto of(List users, + ChattingRoomHistory chattingRoomHistory) { + List userNicknames = users.stream() + .map(user -> user.getProfile().getNickname()) + .toList(); + return new ChattingRoomHistoryDto( + chattingRoomHistory.getId(), + chattingRoomHistory.getName(), + userNicknames, + chattingRoomHistory.getCreatedAt() + ); } } diff --git a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java index 94e1c908..a341c7e2 100644 --- a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java @@ -17,12 +17,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP.ChatHistory; +import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP.Response; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; -import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP.ChatRoomHistory; import coffeemeet.server.chatting.history.service.ChattingRoomHistoryService; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto.Response; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; @@ -49,12 +47,10 @@ void viewChattingRoomHistoriesTest() throws Exception { int pageSize = 50; RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); - List responses = ChattingFixture.chattingRoomHistoryDtoResponses( + List responses = ChattingFixture.chattingRoomHistoryDtoResponses( pageSize); - List chatRoomHistories = responses.stream().map(ChatRoomHistory::from) - .toList(); ChattingRoomHistoriesHTTP.Response response = ChattingFixture.chattingRoomHistoriesHTTP( - chatRoomHistories); + responses); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); @@ -99,16 +95,14 @@ void viewChattingRoomMessageHistoriesTest() throws Exception { Long firstMessageId = 51L; int pageSize = 50; - List responses = ChattingFixture.chattingMessageHistoryDtoResponse(pageSize); - List chatHistories = responses.stream() - .map(ChatHistory::from).toList(); - ChattingMessageHistoriesHTTP.Response response = ChattingFixture.chattingMessageHistoriesHTTP( - chatHistories); + ChattingMessageHistoryListDto chattingMessageHistoryListDto = ChattingFixture.chattingMessageHistoryListDto(); + Response response = ChattingFixture.chattingMessageHistoriesHTTPResponse( + chattingMessageHistoryListDto); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); given(chattingRoomHistoryService.searchChattingMessageHistories(roomHistoryId, firstMessageId, pageSize)).willReturn( - responses); + chattingMessageHistoryListDto); // when, then mockMvc.perform(get("/api/v1/chatting/room/histories/{roomHistoryId}", roomHistoryId) @@ -139,7 +133,8 @@ void viewChattingRoomMessageHistoriesTest() throws Exception { fieldWithPath("chatHistories[].content").type(JsonFieldType.STRING) .description("내용"), fieldWithPath("chatHistories[].createdAt").type(JsonFieldType.STRING) - .description("생성 시간") + .description("생성 시간"), + fieldWithPath("hasNext").type(JsonFieldType.BOOLEAN).description("다음 페이지 존재 여부") ) ) ) diff --git a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java index c554b7e7..254b9912 100644 --- a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java @@ -8,7 +8,7 @@ import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryQuery; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto.Response; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.common.fixture.entity.ChattingFixture; import coffeemeet.server.user.implement.UserQuery; import java.util.List; @@ -67,12 +67,12 @@ void searchChattingMessageHistoriesTest(Long firstMessageId, int pageSize) { chattingMessageHistories); // when - List responses = chattingRoomHistoryService.searchChattingMessageHistories( + ChattingMessageHistoryListDto responses = chattingRoomHistoryService.searchChattingMessageHistories( roomHistoryId, firstMessageId, pageSize); // then - assertThat(responses).hasSize(pageSize); + assertThat(responses.contents()).hasSize(pageSize); } } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java index 7d6a023d..13d39384 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java @@ -13,10 +13,8 @@ import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP.ChatHistory; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; -import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP.ChatRoomHistory; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -55,14 +53,8 @@ public static ChattingListDto chattingListDto() { .create(); } - public static List chattingRoomHistoryDtoResponses(int size) { - return Instancio.ofList(ChattingRoomHistoryDto.Response.class).size(size) - .create(); - } - - public static List chattingMessageHistoryDtoResponse( - int size) { - return Instancio.ofList(ChattingMessageHistoryDto.Response.class).size(size) + public static List chattingRoomHistoryDtoResponses(int size) { + return Instancio.ofList(ChattingRoomHistoryDto.class).size(size) .create(); } @@ -74,19 +66,12 @@ public static ChatsHTTP.Response chatsHTTPResponse(ChattingListDto chats) { } public static ChattingRoomHistoriesHTTP.Response chattingRoomHistoriesHTTP( - List chatRoomHistories) { + List chatRoomHistories) { return Instancio.of(ChattingRoomHistoriesHTTP.Response.class) .set(field(ChattingRoomHistoriesHTTP.Response::chatRoomHistories), chatRoomHistories) .create(); } - public static ChattingMessageHistoriesHTTP.Response chattingMessageHistoriesHTTP( - List chatHistories) { - return Instancio.of(ChattingMessageHistoriesHTTP.Response.class) - .set(field(ChattingMessageHistoriesHTTP.Response::chatHistories), chatHistories) - .create(); - } - public static List chattingMessageHistories(int size) { return Instancio.ofList(ChattingMessageHistory.class).size(size) .generate(field(ChattingMessageHistory::getId), gen -> gen.longSeq().start(1L)) @@ -140,4 +125,19 @@ public static ChatRoomStatusHTTP.Response chatRoomStatusHTTPResponse( return ChatRoomStatusHTTP.Response.from(chatRoomStatusDto); } + public static ChattingMessageHistoryListDto chattingMessageHistoryListDto() { + return Instancio.of(ChattingMessageHistoryListDto.class) + .create(); + } + + public static ChattingMessageHistoriesHTTP.Response chattingMessageHistoriesHTTPResponse( + ChattingMessageHistoryListDto chattingMessageHistoryListDto) { + return Instancio.of(ChattingMessageHistoriesHTTP.Response.class) + .set(field(ChattingMessageHistoriesHTTP.Response::chatHistories), + chattingMessageHistoryListDto.contents()) + .set(field(ChattingMessageHistoriesHTTP.Response::hasNext), + chattingMessageHistoryListDto.hasNext()) + .create(); + } + } From d2f3b521e97ec6349334c213c6505939fd3398be Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 18:25:18 +0900 Subject: [PATCH 23/74] =?UTF-8?q?refactor:=20Inquiry=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/presentation/AdminController.java | 8 ++-- .../inquiry/service/InquiryService.java | 12 +++--- .../inquiry/service/dto/InquirySearchDto.java | 16 ++++++++ .../service/dto/InquirySearchResponse.java | 40 ------------------- .../service/dto/InquirySummaryDto.java | 25 ++++++++++++ .../presentation/AdminControllerTest.java | 12 +++--- .../common/fixture/entity/AdminFixture.java | 14 +++---- .../common/fixture/entity/InquiryFixture.java | 6 +-- .../inquiry/service/InquiryServiceTest.java | 8 ++-- 9 files changed, 71 insertions(+), 70 deletions(-) create mode 100644 src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java delete mode 100644 src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchResponse.java create mode 100644 src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 2125df13..fa72fc87 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -16,8 +16,8 @@ import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary; +import coffeemeet.server.inquiry.service.dto.InquirySearchDto; +import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; import coffeemeet.server.report.service.dto.ReportDetailDto; @@ -166,14 +166,14 @@ public ResponseEntity findReport( } @GetMapping("/inquiries") - public ResponseEntity> searchInquiries( + public ResponseEntity> searchInquiries( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") Long lastInquiryId, @RequestParam(defaultValue = "10") int pageSize) { // if (adminId == null) { // throw new InvalidAuthException(NOT_AUTHORIZED, REQUEST_WITHOUT_SESSION_MESSAGE); // } - InquirySearchResponse inquiries = inquiryService.searchInquiries(lastInquiryId, pageSize); + InquirySearchDto inquiries = inquiryService.searchInquiries(lastInquiryId, pageSize); return ResponseEntity.ok(AdminCustomSlice.of(inquiries.contents(), inquiries.hasNext())); } diff --git a/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java b/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java index 8c13f52e..a28fc012 100644 --- a/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java +++ b/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java @@ -4,8 +4,8 @@ import coffeemeet.server.inquiry.implement.InquiryCommand; import coffeemeet.server.inquiry.implement.InquiryQuery; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary; +import coffeemeet.server.inquiry.service.dto.InquirySearchDto; +import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; import coffeemeet.server.user.domain.Profile; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; @@ -28,17 +28,17 @@ public void registerInquiry(Long inquirerId, String title, String content) { inquiryCommand.createReport(new Inquiry(inquirerId, title, content)); } - public InquirySearchResponse searchInquiries(Long lastInquiryId, int pageSize) { + public InquirySearchDto searchInquiries(Long lastInquiryId, int pageSize) { List inquiries = inquiryQuery.getInquiriesBy(lastInquiryId, pageSize); Map userMap = getUserProfiles(inquiries); - List inquirySummaries = inquiries.stream() - .map(inquiry -> InquirySummary.of(inquiry, userMap.get(inquiry.getInquirerId()))) + List inquirySummaries = inquiries.stream() + .map(inquiry -> InquirySummaryDto.of(inquiry, userMap.get(inquiry.getInquirerId()))) .toList(); boolean hasNext = true; if (inquiries.size() < pageSize) { hasNext = false; } - return InquirySearchResponse.of(inquirySummaries, hasNext); + return InquirySearchDto.of(inquirySummaries, hasNext); } private Map getUserProfiles(List inquiries) { diff --git a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java new file mode 100644 index 00000000..b03b833a --- /dev/null +++ b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java @@ -0,0 +1,16 @@ +package coffeemeet.server.inquiry.service.dto; + +import java.util.List; + +public record InquirySearchDto( + List contents, + boolean hasNext) { + + public static InquirySearchDto of(List inquiries, boolean hasNext) { + return new InquirySearchDto( + inquiries, + hasNext + ); + } + +} diff --git a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchResponse.java b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchResponse.java deleted file mode 100644 index 1ce96093..00000000 --- a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -package coffeemeet.server.inquiry.service.dto; - -import coffeemeet.server.inquiry.domain.Inquiry; -import coffeemeet.server.user.domain.Profile; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; -import java.util.List; - -public record InquirySearchResponse( - List contents, - boolean hasNext) { - - public static InquirySearchResponse of(List inquiries, boolean hasNext) { - return new InquirySearchResponse( - inquiries, - hasNext - ); - - } - - public record InquirySummary( - Long inquiryId, - String inquirer, - String title, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt - ) { - - public static InquirySearchResponse.InquirySummary of(Inquiry inquiry, Profile profile) { - return new InquirySearchResponse.InquirySummary( - inquiry.getId(), - profile.getNickname(), - inquiry.getTitle(), - inquiry.getCreatedAt() - ); - } - - } - -} diff --git a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java new file mode 100644 index 00000000..8e5c4652 --- /dev/null +++ b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java @@ -0,0 +1,25 @@ +package coffeemeet.server.inquiry.service.dto; + +import coffeemeet.server.inquiry.domain.Inquiry; +import coffeemeet.server.user.domain.Profile; +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; + +public record InquirySummaryDto( + Long inquiryId, + String inquirer, + String title, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + + public static InquirySummaryDto of(Inquiry inquiry, Profile profile) { + return new InquirySummaryDto( + inquiry.getId(), + profile.getNickname(), + inquiry.getTitle(), + inquiry.getCreatedAt() + ); + } + +} diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index bc1c5078..1f15f8c4 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -47,8 +47,8 @@ import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary; +import coffeemeet.server.inquiry.service.dto.InquirySearchDto; +import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; import coffeemeet.server.report.service.dto.ReportDetailDto; @@ -372,11 +372,11 @@ void searchInquiriesTest() throws Exception { Long lastInquiryId = 10L; int pageSize = 10; - InquirySearchResponse inquirySearchResponse = InquiryFixture.inquirySearchResponse(); - AdminCustomSlice adminCustomSlice = AdminFixture.adminCustomPageByInquiry( - inquirySearchResponse.contents(), inquirySearchResponse.hasNext()); + InquirySearchDto inquirySearchDto = InquiryFixture.inquirySearchResponse(); + AdminCustomSlice adminCustomSlice = AdminFixture.adminCustomPageByInquiry( + inquirySearchDto.contents(), inquirySearchDto.hasNext()); given(inquiryService.searchInquiries(lastInquiryId, pageSize)).willReturn( - inquirySearchResponse); + inquirySearchDto); // when, then mockMvc.perform(get(baseUrl + "/inquiries") diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java index 618c9fc1..ecaa8c6e 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java @@ -6,8 +6,7 @@ import coffeemeet.server.admin.presentation.dto.AdminLoginHTTP; import coffeemeet.server.admin.presentation.dto.ReportDeletionHTTP; import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse.InquirySummary; +import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; import java.util.List; import org.instancio.Instancio; @@ -26,12 +25,13 @@ public static ReportDeletionHTTP.Request reportRejectionHTTPRequest() { return Instancio.of(ReportDeletionHTTP.Request.class).create(); } - public static AdminCustomSlice adminCustomPageByInquiry( - List contents, boolean hasNext) { + @SuppressWarnings("unchecked") + public static AdminCustomSlice adminCustomPageByInquiry( + List contents, boolean hasNext) { return Instancio.of(AdminCustomSlice.class) - .withTypeParameters(InquirySearchResponse.InquirySummary.class) - .set(field(AdminCustomSlice::contents), contents) - .set(field(AdminCustomSlice::hasNext), hasNext) + .withTypeParameters(InquirySummaryDto.class) + .set(field(AdminCustomSlice::contents), contents) + .set(field(AdminCustomSlice::hasNext), hasNext) .create(); } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java index caadb4c2..a6d144a8 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java @@ -6,7 +6,7 @@ import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.presentation.dto.InquiryHTTP; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; +import coffeemeet.server.inquiry.service.dto.InquirySearchDto; import java.util.List; import org.instancio.Instancio; @@ -42,8 +42,8 @@ public static List inquiriesWithFixedId(int size, Long id) { .generate(field(Inquiry::getContent), gen -> gen.string().maxLength(200)).create(); } - public static InquirySearchResponse inquirySearchResponse() { - return Instancio.of(InquirySearchResponse.class) + public static InquirySearchDto inquirySearchResponse() { + return Instancio.of(InquirySearchDto.class) .create(); } diff --git a/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java b/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java index 54466b5f..ed40713d 100644 --- a/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java +++ b/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java @@ -14,7 +14,7 @@ import coffeemeet.server.inquiry.implement.InquiryCommand; import coffeemeet.server.inquiry.implement.InquiryQuery; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; -import coffeemeet.server.inquiry.service.dto.InquirySearchResponse; +import coffeemeet.server.inquiry.service.dto.InquirySearchDto; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; import java.util.HashSet; @@ -72,13 +72,13 @@ void searchInquiriesTest() { given(userQuery.getUsersByIdSet(anySet())).willReturn(userSet); // when - InquirySearchResponse inquirySearchResponse = inquiryService.searchInquiries(lastInquiryId, + InquirySearchDto inquirySearchDto = inquiryService.searchInquiries(lastInquiryId, pageSize); // then assertAll( - () -> assertThat(inquirySearchResponse.contents()).hasSize(size), - () -> assertThat(inquirySearchResponse.hasNext()).isTrue() + () -> assertThat(inquirySearchDto.contents()).hasSize(size), + () -> assertThat(inquirySearchDto.hasNext()).isTrue() ); } From 0548e72968dd107551ff2a077e00374a0895df31 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 18:54:01 +0900 Subject: [PATCH 24/74] =?UTF-8?q?test:=20Fixture=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 도메인별로 픽스처 구분 --- .../presentation/AdminControllerTest.java | 28 ++--- .../admin/service/AdminServiceTest.java | 2 + .../implement/RefreshTokenCommandTest.java | 4 +- .../auth/implement/RefreshTokenQueryTest.java | 4 +- .../auth/presentation/AuthControllerTest.java | 11 +- .../server/auth/service/AuthServiceTest.java | 6 +- .../CertificationRepositoryTest.java | 11 +- .../implement/CertificationCommandTest.java | 13 +-- .../implement/CertificationQueryTest.java | 4 +- .../EmailVerificationCommandTest.java | 0 .../implement/EmailVerificationQueryTest.java | 0 .../CertificationControllerTest.java | 14 +-- .../service/CertificationServiceTest.java | 32 +++--- ...ChattingMessageServiceConcurrencyTest.java | 4 +- .../implement/ChattingMessageCommandTest.java | 4 +- .../implement/ChattingMessageQueryTest.java | 2 +- .../implement/ChattingRoomCommandTest.java | 4 +- .../implement/ChattingRoomQueryTest.java | 2 +- .../implement/ChattingSessionCommandTest.java | 2 +- .../implement/ChattingSessionQueryTest.java | 2 +- .../ChattingMessageQueryRepositoryTest.java | 4 +- .../MemoryChattingSessionRepositoryTest.java | 2 +- .../ChattingRoomControllerTest.java | 2 +- .../service/ChattingMessageServiceTest.java | 1 - .../service/ChattingRoomServiceTest.java | 4 +- .../ChattingMessageHistoryCommandTest.java | 2 +- .../ChattingMessageHistoryQueryTest.java | 2 +- .../ChattingRoomHistoryCommandTest.java | 2 +- .../UserChattingHistoryCommandTest.java | 2 +- .../UserChattingHistoryQueryTest.java | 4 +- ...tingMessageHistoryQueryRepositoryTest.java | 4 +- .../UserChattingHistoryRepositoryTest.java | 4 +- .../ChattingRoomHistoryControllerTest.java | 6 +- .../ChattingRoomHistoryServiceTest.java | 2 +- .../fixture/{entity => }/AdminFixture.java | 2 +- ...uthTokensFixture.java => AuthFixture.java} | 10 +- .../{entity => }/CertificationFixture.java | 4 +- .../fixture/{entity => }/ChattingFixture.java | 2 +- .../fixture/{entity => }/InquiryFixture.java | 2 +- .../server/common/fixture/OauthFixture.java | 40 +++++++ .../server/common/fixture/ReportFixture.java | 54 +++++++++ .../fixture/{entity => }/UserFixture.java | 103 +++++++++++++++++- .../common/fixture/UserStatusDtoFixture.java | 13 --- .../fixture/dto/GroupReportDtoFixture.java | 13 --- .../dto/KakaoMemberResponseFixture.java | 13 --- .../fixture/dto/KakaoTokensFixture.java | 13 --- .../fixture/dto/LoginDetailsDtoFixture.java | 13 --- .../fixture/dto/LoginDetailsHTTPFixture.java | 24 ---- .../fixture/dto/MyProfileDtoFixture.java | 13 --- .../fixture/dto/MyProfileHTTPFixture.java | 19 ---- .../dto/NaverMemberResponseFixture.java | 12 -- .../common/fixture/dto/NaverTokenFixture.java | 13 --- .../fixture/dto/OAuthUserInfoDtoFixture.java | 16 --- .../fixture/dto/RefreshTokenFixture.java | 13 --- .../fixture/dto/ReportDetailDtoFixture.java | 13 --- .../fixture/dto/ReportDetailHTTPFixture.java | 21 ---- .../common/fixture/dto/ReportDtoFixture.java | 19 ---- .../common/fixture/dto/SignupHTTPFixture.java | 25 ----- .../fixture/dto/UpdateProfileHTTPFixture.java | 24 ---- .../fixture/dto/UserProfileDtoFixture.java | 13 --- .../fixture/dto/UserProfileHTTPFixture.java | 17 --- .../fixture/dto/UserStatusHTTPFixture.java | 19 ---- .../common/fixture/entity/ReportFixture.java | 22 ---- .../common/implement/EmailSenderTest.java | 8 +- .../implement/FCMNotificationSenderTest.java | 6 +- .../inquiry/implement/InquiryCommandTest.java | 2 +- .../inquiry/implement/InquiryQueryTest.java | 2 +- .../InquiryQueryRepositoryTest.java | 4 +- .../presentation/InquiryControllerTest.java | 6 +- .../inquiry/service/InquiryServiceTest.java | 4 +- .../presentation/MatchingControllerTest.java | 4 +- .../matching/service/MatchingServiceTest.java | 12 +- .../OAuthMemberClientCompositeTest.java | 4 +- .../client/kakao/KakaoMemberClientTest.java | 7 +- .../client/naver/NaverMemberClientTest.java | 7 +- .../infrastructure/kakao/KakaoClientTest.java | 7 +- .../infrastructure/naver/NaverClientTest.java | 7 +- .../report/implement/ReportCommandTest.java | 2 +- .../report/implement/ReportQueryTest.java | 2 +- .../ReportQueryRepositoryTest.java | 2 +- .../infrastructure/ReportRepositoryTest.java | 2 +- .../presentation/ReportControllerTest.java | 4 +- .../report/service/ReportServiceTest.java | 6 +- .../server/user/domain/InterestTest.java | 4 +- .../user/implement/InterestCommandTest.java | 2 +- .../user/implement/InterestQueryTest.java | 2 +- .../user/implement/UserCommandTest.java | 4 +- .../server/user/implement/UserQueryTest.java | 2 +- .../infrastructure/UserRepositoryTest.java | 4 +- .../user/presentation/UserControllerTest.java | 39 +++---- .../server/user/service/UserServiceTest.java | 29 +++-- 91 files changed, 382 insertions(+), 557 deletions(-) create mode 100644 src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java create mode 100644 src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java rename src/test/java/coffeemeet/server/common/fixture/{entity => }/AdminFixture.java (96%) rename src/test/java/coffeemeet/server/common/fixture/{dto/AuthTokensFixture.java => AuthFixture.java} (64%) rename src/test/java/coffeemeet/server/common/fixture/{entity => }/CertificationFixture.java (98%) rename src/test/java/coffeemeet/server/common/fixture/{entity => }/ChattingFixture.java (99%) rename src/test/java/coffeemeet/server/common/fixture/{entity => }/InquiryFixture.java (97%) create mode 100644 src/test/java/coffeemeet/server/common/fixture/OauthFixture.java create mode 100644 src/test/java/coffeemeet/server/common/fixture/ReportFixture.java rename src/test/java/coffeemeet/server/common/fixture/{entity => }/UserFixture.java (60%) delete mode 100644 src/test/java/coffeemeet/server/common/fixture/UserStatusDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/GroupReportDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/KakaoTokensFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/MyProfileHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/NaverMemberResponseFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/NaverTokenFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/RefreshTokenFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/SignupHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/UserProfileDtoFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/UserProfileHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/dto/UserStatusHTTPFixture.java delete mode 100644 src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 1f15f8c4..88a8c081 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -1,10 +1,9 @@ package coffeemeet.server.admin.presentation; -import static coffeemeet.server.common.fixture.entity.AdminFixture.adminLoginHTTPRequest; -import static coffeemeet.server.common.fixture.entity.AdminFixture.reportApprovalHTTPRequest; -import static coffeemeet.server.common.fixture.entity.AdminFixture.reportRejectionHTTPRequest; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPageDto; +import static coffeemeet.server.common.fixture.AdminFixture.adminLoginHTTPRequest; +import static coffeemeet.server.common.fixture.AdminFixture.reportApprovalHTTPRequest; +import static coffeemeet.server.common.fixture.AdminFixture.reportRejectionHTTPRequest; +import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertificationPageDto; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; import static org.mockito.ArgumentMatchers.any; @@ -38,12 +37,9 @@ import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.dto.GroupReportDtoFixture; -import coffeemeet.server.common.fixture.dto.ReportDetailDtoFixture; -import coffeemeet.server.common.fixture.dto.ReportDetailHTTPFixture; -import coffeemeet.server.common.fixture.dto.ReportDtoFixture; -import coffeemeet.server.common.fixture.entity.AdminFixture; -import coffeemeet.server.common.fixture.entity.InquiryFixture; +import coffeemeet.server.common.fixture.AdminFixture; +import coffeemeet.server.common.fixture.InquiryFixture; +import coffeemeet.server.common.fixture.ReportFixture; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; @@ -240,7 +236,7 @@ void findAllReportsTest() throws Exception { // given Long lastReportId = 0L; int pageSize = 10; - ReportListDto reportListDto = ReportDtoFixture.reportListDto(); + ReportListDto reportListDto = ReportFixture.reportListDto(); AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), reportListDto.hasNext()); @@ -283,8 +279,8 @@ void findAllReportsTest() throws Exception { @DisplayName("동일 채팅방 내의 신고 대상에 대한 신고 내역을 조회할 수 있다.") void findReportByTargetIdAndChattingRoomIdTest() throws Exception { // given - List response = List.of(GroupReportDtoFixture.targetReportDto(), - GroupReportDtoFixture.targetReportDto()); + List response = List.of(ReportFixture.targetReportDto(), + ReportFixture.targetReportDto()); GroupReportHTTP.Response result = GroupReportHTTP.Response.from(response); given(reportService.findReportByTargetIdAndChattingRoomId(anyLong(), anyLong())).willReturn( @@ -327,8 +323,8 @@ void findReportByTargetIdAndChattingRoomIdTest() throws Exception { void findReportTest() throws Exception { // given Long reportId = 1L; - ReportDetailDto response = ReportDetailDtoFixture.reportDetailDto(); - ReportDetailHTTP.Response expectedResponse = ReportDetailHTTPFixture.reportDetailHTTPResponse( + ReportDetailDto response = ReportFixture.reportDetailDto(); + ReportDetailHTTP.Response expectedResponse = ReportFixture.reportDetailHTTPResponse( response); given(reportService.findReportById(anyLong())).willReturn(response); diff --git a/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java b/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java index 3519df12..88034293 100644 --- a/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java +++ b/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java @@ -14,6 +14,8 @@ import coffeemeet.server.admin.implement.AdminQuery; import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; +import coffeemeet.server.common.fixture.InquiryFixture; +import coffeemeet.server.common.implement.FCMNotificationSender; import coffeemeet.server.common.fixture.entity.InquiryFixture; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.inquiry.domain.Inquiry; diff --git a/src/test/java/coffeemeet/server/auth/implement/RefreshTokenCommandTest.java b/src/test/java/coffeemeet/server/auth/implement/RefreshTokenCommandTest.java index a6bcca98..7480be24 100644 --- a/src/test/java/coffeemeet/server/auth/implement/RefreshTokenCommandTest.java +++ b/src/test/java/coffeemeet/server/auth/implement/RefreshTokenCommandTest.java @@ -7,7 +7,7 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; +import coffeemeet.server.common.fixture.AuthFixture; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -28,7 +28,7 @@ class RefreshTokenCommandTest { @Test void createRefreshTokenTest() { // given - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); // when refreshTokenCommand.createRefreshToken(refreshToken); diff --git a/src/test/java/coffeemeet/server/auth/implement/RefreshTokenQueryTest.java b/src/test/java/coffeemeet/server/auth/implement/RefreshTokenQueryTest.java index 4874008d..043ff462 100644 --- a/src/test/java/coffeemeet/server/auth/implement/RefreshTokenQueryTest.java +++ b/src/test/java/coffeemeet/server/auth/implement/RefreshTokenQueryTest.java @@ -5,7 +5,7 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; +import coffeemeet.server.common.fixture.AuthFixture; import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -28,7 +28,7 @@ class RefreshTokenQueryTest { void getRefreshTokenTest() { // given Long userId = 1L; - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); given(refreshTokenRepository.findById(userId)).willReturn(Optional.of(refreshToken)); // when diff --git a/src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java b/src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java index 068636c4..1f7e531c 100644 --- a/src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java +++ b/src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java @@ -21,8 +21,7 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.service.AuthService; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.dto.AuthTokensFixture; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; +import coffeemeet.server.common.fixture.AuthFixture; import com.epages.restdocs.apispec.Schema; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -41,8 +40,8 @@ class AuthControllerTest extends ControllerTestConfig { @Test void renewTest() throws Exception { // given - AuthTokens authTokens = AuthTokensFixture.authTokens(); - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + AuthTokens authTokens = AuthFixture.authTokens(); + RefreshToken refreshToken = AuthFixture.refreshToken(); given(authService.renew(anyLong(), any())).willReturn(authTokens); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); @@ -74,7 +73,7 @@ void renewTest() throws Exception { @Test void logoutTest() throws Exception { // given - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); willDoNothing().given(authService).logout(anyLong()); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); @@ -99,7 +98,7 @@ void logoutTest() throws Exception { @Test void deleteTest() throws Exception { // given - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); willDoNothing().given(authService).delete(anyLong()); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); diff --git a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java index e2ad3afa..06561b6e 100644 --- a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java +++ b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java @@ -14,7 +14,7 @@ import coffeemeet.server.auth.domain.JwtTokenProvider; import coffeemeet.server.auth.implement.RefreshTokenCommand; import coffeemeet.server.common.execption.InvalidAuthException; -import coffeemeet.server.common.fixture.dto.AuthTokensFixture; +import coffeemeet.server.common.fixture.AuthFixture; import coffeemeet.server.user.service.UserService; import com.github.javafaker.Faker; import org.instancio.Instancio; @@ -49,8 +49,8 @@ class AuthServiceTest { @Test void renewTest() { // given - AuthTokens authTokens = AuthTokensFixture.authTokens(); - AuthTokens newAuthTokens = AuthTokensFixture.authTokens(REFRESH_TOKEN); + AuthTokens authTokens = AuthFixture.authTokens(); + AuthTokens newAuthTokens = AuthFixture.authTokens(REFRESH_TOKEN); given(jwtTokenProvider.isExpiredRefreshToken(REFRESH_TOKEN)).willReturn(false); given(authTokensGenerator.reissueAccessToken(anyLong(), any(String.class))).willReturn( diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index 44bfcf0e..6391ad22 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,15 +1,14 @@ package coffeemeet.server.certification.domain.repository; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.fixture.entity.UserFixture.users; -import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; +import static coffeemeet.server.common.fixture.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.users; import static org.assertj.core.api.Assertions.assertThat; import coffeemeet.server.certification.domain.Certification; +import coffeemeet.server.certification.domain.repository.CertificationRepository; import coffeemeet.server.common.config.RepositoryTestConfig; -import coffeemeet.server.common.fixture.entity.CertificationFixture; +import coffeemeet.server.common.fixture.CertificationFixture; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import java.util.List; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index f32e78d6..072f6da1 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,12 +1,11 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.CertificationFixture.department; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java index f0527488..d2902580 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationQueryTest.java @@ -1,7 +1,7 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/EmailVerificationCommandTest.java new file mode 100644 index 00000000..e69de29b diff --git a/src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java b/src/test/java/coffeemeet/server/certification/implement/EmailVerificationQueryTest.java new file mode 100644 index 00000000..e69de29b diff --git a/src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java b/src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java index 3368405d..cdeea496 100644 --- a/src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java +++ b/src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java @@ -1,12 +1,12 @@ package coffeemeet.server.certification.presentation; -import static coffeemeet.server.common.fixture.dto.RefreshTokenFixture.refreshToken; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailDtoRequest; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.userId; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCodeDtoRequest; +import static coffeemeet.server.common.fixture.AuthFixture.refreshToken; +import static coffeemeet.server.common.fixture.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.CertificationFixture.department; +import static coffeemeet.server.common.fixture.CertificationFixture.email; +import static coffeemeet.server.common.fixture.CertificationFixture.emailDtoRequest; +import static coffeemeet.server.common.fixture.CertificationFixture.userId; +import static coffeemeet.server.common.fixture.CertificationFixture.verificationCodeDtoRequest; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; import static org.mockito.ArgumentMatchers.anyLong; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index bb797a1d..049f50c0 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,12 +1,10 @@ package coffeemeet.server.certification.service; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPage; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; +import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.CertificationFixture.department; +import static coffeemeet.server.common.fixture.CertificationFixture.email; +import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -27,10 +25,8 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; -import java.util.List; import org.instancio.Instancio; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -115,6 +111,7 @@ void updateCertificationTest() { } @Test + @DisplayName("회사 인증 메일을 전송할 수 있다.") void sendVerificationMailTest() { // given Long userId = 1L; @@ -127,12 +124,16 @@ void sendVerificationMailTest() { certificationService.sendVerificationMail(userId, email); // then - then(companyEmailValidator).should(only()).validateDuplicatedCompanyEmail(any(CompanyEmail.class)); - then(verificationMailSender).should(only()).sendVerificationMail(any(CompanyEmail.class), eq(verificationCode)); - then(verificationInfoCommand).should(only()).createVerificationInfo(eq(userId), any(CompanyEmail.class), eq(verificationCode)); + then(companyEmailValidator).should(only()) + .validateDuplicatedCompanyEmail(any(CompanyEmail.class)); + then(verificationMailSender).should(only()) + .sendVerificationMail(any(CompanyEmail.class), eq(verificationCode)); + then(verificationInfoCommand).should(only()) + .createVerificationInfo(eq(userId), any(CompanyEmail.class), eq(verificationCode)); } @Test + @DisplayName("인증 코드를 비교할 수 있다.") void compareCodeTest() { // given Long userId = 1L; @@ -145,17 +146,20 @@ void compareCodeTest() { certificationService.compareCode(userId, userInputCode); // then - then(verificationCodeValidator).should(only()).validateVerificationCode(eq(actualVerificationCode), eq(userInputCode)); + then(verificationCodeValidator).should(only()) + .validateVerificationCode(eq(actualVerificationCode), eq(userInputCode)); } @Test + @DisplayName("미인증 사용자 요청을 페이지로 가져올 수 있다.") void getUncertifiedUserRequestsTest() { // given Pageable pageable = certificationPageable(); Page certificationPage = pendingCertificationPage( pageable.getPageSize()); - given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn(certificationPage); + given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn( + certificationPage); // when PendingCertificationPageDto result = certificationService.getUncertifiedUserRequests(pageable); diff --git a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java index 4cc6453b..54c1120d 100644 --- a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java +++ b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java @@ -9,8 +9,8 @@ import coffeemeet.server.chatting.current.infrastructure.ChattingMessageRepository; import coffeemeet.server.chatting.current.infrastructure.ChattingRoomRepository; import coffeemeet.server.chatting.current.service.ChattingMessageService; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; diff --git a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageCommandTest.java b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageCommandTest.java index 71d81d96..4de4fc11 100644 --- a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageCommandTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageCommandTest.java @@ -9,8 +9,8 @@ import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.infrastructure.ChattingMessageQueryRepository; import coffeemeet.server.chatting.current.infrastructure.ChattingMessageRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.User; import java.util.List; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageQueryTest.java b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageQueryTest.java index 57069d9e..0a32af43 100644 --- a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageQueryTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingMessageQueryTest.java @@ -6,7 +6,7 @@ import coffeemeet.server.chatting.current.domain.ChattingMessage; import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.infrastructure.ChattingMessageQueryRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import java.util.List; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomCommandTest.java b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomCommandTest.java index e10ac494..ec0ef74e 100644 --- a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomCommandTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomCommandTest.java @@ -9,8 +9,8 @@ import coffeemeet.server.chatting.current.domain.ChattingMessage; import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.infrastructure.ChattingRoomRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; import java.util.List; diff --git a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomQueryTest.java b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomQueryTest.java index 36f163bf..8c7aca82 100644 --- a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomQueryTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingRoomQueryTest.java @@ -11,7 +11,7 @@ import coffeemeet.server.chatting.current.infrastructure.ChattingRoomRepository; import coffeemeet.server.common.execption.InvalidInputException; import coffeemeet.server.common.execption.NotFoundException; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionCommandTest.java b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionCommandTest.java index ef8f9a95..6f743bbc 100644 --- a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionCommandTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionCommandTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.current.implement; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingSession; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingSession; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.only; diff --git a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionQueryTest.java b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionQueryTest.java index 01f23ef4..4865cc4b 100644 --- a/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionQueryTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/implement/ChattingSessionQueryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.current.implement; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingSession; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingSession; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/chatting/current/infrastructure/ChattingMessageQueryRepositoryTest.java b/src/test/java/coffeemeet/server/chatting/current/infrastructure/ChattingMessageQueryRepositoryTest.java index 92b43084..ba392384 100644 --- a/src/test/java/coffeemeet/server/chatting/current/infrastructure/ChattingMessageQueryRepositoryTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/infrastructure/ChattingMessageQueryRepositoryTest.java @@ -6,8 +6,8 @@ import coffeemeet.server.chatting.current.domain.ChattingMessage; import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.common.config.RepositoryTestConfig; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import java.util.List; diff --git a/src/test/java/coffeemeet/server/chatting/current/infrastructure/MemoryChattingSessionRepositoryTest.java b/src/test/java/coffeemeet/server/chatting/current/infrastructure/MemoryChattingSessionRepositoryTest.java index 9f2d3a43..b10dbbd1 100644 --- a/src/test/java/coffeemeet/server/chatting/current/infrastructure/MemoryChattingSessionRepositoryTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/infrastructure/MemoryChattingSessionRepositoryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.current.infrastructure; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingSession; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingSession; import static org.assertj.core.api.Assertions.assertThat; import coffeemeet.server.chatting.current.domain.ChattingSession; diff --git a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java index b4379215..ae9f158a 100644 --- a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java @@ -24,7 +24,7 @@ import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import com.epages.restdocs.apispec.Schema; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index 2f8fae3d..20b0aae2 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -4,7 +4,6 @@ import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; import static coffeemeet.server.common.fixture.UserFixture.fourUsers; import static coffeemeet.server.common.fixture.UserFixture.user; -import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java index 36c6db27..275f291d 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java @@ -19,8 +19,8 @@ import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryCommand; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryCommand; import coffeemeet.server.chatting.history.implement.UserChattingHistoryCommand; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; diff --git a/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryCommandTest.java b/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryCommandTest.java index caf80895..1202ee4c 100644 --- a/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryCommandTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryCommandTest.java @@ -6,7 +6,7 @@ import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.infrastructure.ChattingMessageHistoryRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryQueryTest.java b/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryQueryTest.java index a852caa8..80fa972f 100644 --- a/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryQueryTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/implement/ChattingMessageHistoryQueryTest.java @@ -6,7 +6,7 @@ import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.infrastructure.ChattingMessageHistoryQueryRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/chatting/history/implement/ChattingRoomHistoryCommandTest.java b/src/test/java/coffeemeet/server/chatting/history/implement/ChattingRoomHistoryCommandTest.java index 9b04b07e..f728decb 100644 --- a/src/test/java/coffeemeet/server/chatting/history/implement/ChattingRoomHistoryCommandTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/implement/ChattingRoomHistoryCommandTest.java @@ -7,7 +7,7 @@ import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.infrastructure.ChattingRoomHistoryRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryCommandTest.java b/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryCommandTest.java index e484dcbd..528d7065 100644 --- a/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryCommandTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryCommandTest.java @@ -6,7 +6,7 @@ import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.chatting.history.infrastructure.UserChattingHistoryRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryQueryTest.java b/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryQueryTest.java index 4cacaa16..15d51e26 100644 --- a/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryQueryTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/implement/UserChattingHistoryQueryTest.java @@ -6,8 +6,8 @@ import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.chatting.history.infrastructure.UserChattingHistoryRepository; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.User; import java.util.List; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/chatting/history/infrastructure/ChattingMessageHistoryQueryRepositoryTest.java b/src/test/java/coffeemeet/server/chatting/history/infrastructure/ChattingMessageHistoryQueryRepositoryTest.java index 077f13c1..7c7a0ee5 100644 --- a/src/test/java/coffeemeet/server/chatting/history/infrastructure/ChattingMessageHistoryQueryRepositoryTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/infrastructure/ChattingMessageHistoryQueryRepositoryTest.java @@ -6,8 +6,8 @@ import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.common.config.RepositoryTestConfig; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import java.util.List; diff --git a/src/test/java/coffeemeet/server/chatting/history/infrastructure/UserChattingHistoryRepositoryTest.java b/src/test/java/coffeemeet/server/chatting/history/infrastructure/UserChattingHistoryRepositoryTest.java index ac4c28d9..601b02cb 100644 --- a/src/test/java/coffeemeet/server/chatting/history/infrastructure/UserChattingHistoryRepositoryTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/infrastructure/UserChattingHistoryRepositoryTest.java @@ -5,8 +5,8 @@ import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.common.config.RepositoryTestConfig; -import coffeemeet.server.common.fixture.entity.ChattingFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.ChattingFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import java.util.List; diff --git a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java index a341c7e2..9aa0278a 100644 --- a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java @@ -23,8 +23,8 @@ import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.AuthFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import com.epages.restdocs.apispec.Schema; import java.util.List; import org.junit.jupiter.api.DisplayName; @@ -46,7 +46,7 @@ void viewChattingRoomHistoriesTest() throws Exception { Long userId = 1L; int pageSize = 50; - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); List responses = ChattingFixture.chattingRoomHistoryDtoResponses( pageSize); ChattingRoomHistoriesHTTP.Response response = ChattingFixture.chattingRoomHistoriesHTTP( diff --git a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java index 254b9912..a3a376d8 100644 --- a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java @@ -9,7 +9,7 @@ import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import coffeemeet.server.user.implement.UserQuery; import java.util.List; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java b/src/test/java/coffeemeet/server/common/fixture/AdminFixture.java similarity index 96% rename from src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java rename to src/test/java/coffeemeet/server/common/fixture/AdminFixture.java index ecaa8c6e..bd31bc69 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/AdminFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/AdminFixture.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.fixture.entity; +package coffeemeet.server.common.fixture; import static org.instancio.Select.field; diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/AuthTokensFixture.java b/src/test/java/coffeemeet/server/common/fixture/AuthFixture.java similarity index 64% rename from src/test/java/coffeemeet/server/common/fixture/dto/AuthTokensFixture.java rename to src/test/java/coffeemeet/server/common/fixture/AuthFixture.java index 3d657555..f5fb1c17 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/AuthTokensFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/AuthFixture.java @@ -1,11 +1,12 @@ -package coffeemeet.server.common.fixture.dto; +package coffeemeet.server.common.fixture; import static org.instancio.Select.field; import coffeemeet.server.auth.domain.AuthTokens; +import coffeemeet.server.auth.domain.RefreshToken; import org.instancio.Instancio; -public class AuthTokensFixture { +public class AuthFixture { public static AuthTokens authTokens() { return Instancio.of(AuthTokens.class) @@ -18,4 +19,9 @@ public static AuthTokens authTokens(String refreshToken) { .create(); } + public static RefreshToken refreshToken() { + return Instancio.of(RefreshToken.class) + .create(); + } + } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java similarity index 98% rename from src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java rename to src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index c4334d63..cac12b53 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -1,6 +1,6 @@ -package coffeemeet.server.common.fixture.entity; +package coffeemeet.server.common.fixture; -import static coffeemeet.server.common.fixture.entity.UserFixture.users; +import static coffeemeet.server.common.fixture.UserFixture.users; import static org.instancio.Select.field; import coffeemeet.server.certification.domain.Certification; diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java similarity index 99% rename from src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java rename to src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java index 13d39384..1e89208f 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.fixture.entity; +package coffeemeet.server.common.fixture; import static org.instancio.Select.field; diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java b/src/test/java/coffeemeet/server/common/fixture/InquiryFixture.java similarity index 97% rename from src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java rename to src/test/java/coffeemeet/server/common/fixture/InquiryFixture.java index a6d144a8..2b4d7544 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/InquiryFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/InquiryFixture.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.fixture.entity; +package coffeemeet.server.common.fixture; import static org.instancio.Select.field; diff --git a/src/test/java/coffeemeet/server/common/fixture/OauthFixture.java b/src/test/java/coffeemeet/server/common/fixture/OauthFixture.java new file mode 100644 index 00000000..6b966919 --- /dev/null +++ b/src/test/java/coffeemeet/server/common/fixture/OauthFixture.java @@ -0,0 +1,40 @@ +package coffeemeet.server.common.fixture; + +import static org.instancio.Select.field; + +import coffeemeet.server.oauth.domain.OAuthMemberDetail; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; +import coffeemeet.server.oauth.infrastructure.naver.dto.NaverMemberDetail; +import coffeemeet.server.oauth.infrastructure.naver.dto.NaverTokens; +import org.instancio.Instancio; + +public class OauthFixture { + + public static KakaoMemberDetail kakaoMemberResponse() { + return Instancio.of(KakaoMemberDetail.class) + .create(); + } + + public static KakaoTokens kakaoTokens() { + return Instancio.of(KakaoTokens.class) + .create(); + } + + public static NaverMemberDetail naverMemberResponse() { + return Instancio.of(NaverMemberDetail.class) + .create(); + } + + public static NaverTokens naverTokens() { + return Instancio.of(NaverTokens.class) + .create(); + } + + public static OAuthMemberDetail response() { + return Instancio.of(OAuthMemberDetail.class) + .set(field("email"), "test123@gmail.com") + .create(); + } + +} diff --git a/src/test/java/coffeemeet/server/common/fixture/ReportFixture.java b/src/test/java/coffeemeet/server/common/fixture/ReportFixture.java new file mode 100644 index 00000000..9bbbc606 --- /dev/null +++ b/src/test/java/coffeemeet/server/common/fixture/ReportFixture.java @@ -0,0 +1,54 @@ +package coffeemeet.server.common.fixture; + +import static org.instancio.Select.field; + +import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; +import coffeemeet.server.report.domain.Report; +import coffeemeet.server.report.service.dto.GroupReportDto; +import coffeemeet.server.report.service.dto.ReportDetailDto; +import coffeemeet.server.report.service.dto.ReportListDto; +import org.instancio.Instancio; + +public class ReportFixture { + + public static Report report() { + return Instancio.of(Report.class) + .generate(field(Report::getReasonDetail), gen -> gen.string().maxLength(200)).create(); + } + + public static Report report(Long targetId, Long chattingRoomId) { + return Instancio.of(Report.class) + .set(field(Report::getTargetedId), targetId) + .set(field(Report::getChattingRoomId), chattingRoomId) + .generate(field(Report::getReasonDetail), gen -> gen.string().maxLength(200)).create(); + } + + public static GroupReportDto targetReportDto() { + return Instancio.of(GroupReportDto.class) + .create(); + } + + public static ReportDetailDto reportDetailDto() { + return Instancio.of(ReportDetailDto.class) + .create(); + } + + public static ReportDetailHTTP.Response reportDetailHTTPResponse( + ReportDetailDto response) { + return new ReportDetailHTTP.Response( + response.reporterNickname(), + response.targetedNickname(), + response.targetedEmail(), + response.reason(), + response.reasonDetail(), + response.reportedCount(), + response.createdAt() + ); + } + + public static ReportListDto reportListDto() { + return Instancio.of(ReportListDto.class) + .create(); + } + +} diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java b/src/test/java/coffeemeet/server/common/fixture/UserFixture.java similarity index 60% rename from src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java rename to src/test/java/coffeemeet/server/common/fixture/UserFixture.java index 5ed23e9f..803a23ed 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/UserFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/UserFixture.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.fixture.entity; +package coffeemeet.server.common.fixture; import static java.time.LocalDateTime.now; import static org.instancio.Select.field; @@ -8,7 +8,19 @@ import coffeemeet.server.user.domain.Profile; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.domain.UserStatus; +import coffeemeet.server.user.presentation.dto.LoginDetailsHTTP; +import coffeemeet.server.user.presentation.dto.LoginDetailsHTTP.Response; +import coffeemeet.server.user.presentation.dto.MyProfileHTTP; import coffeemeet.server.user.presentation.dto.NotificationTokenHTTP; +import coffeemeet.server.user.presentation.dto.SignupHTTP; +import coffeemeet.server.user.presentation.dto.SignupHTTP.Request; +import coffeemeet.server.user.presentation.dto.UpdateProfileHTTP; +import coffeemeet.server.user.presentation.dto.UserProfileHTTP; +import coffeemeet.server.user.presentation.dto.UserStatusHTTP; +import coffeemeet.server.user.service.dto.LoginDetailsDto; +import coffeemeet.server.user.service.dto.MyProfileDto; +import coffeemeet.server.user.service.dto.UserProfileDto; +import coffeemeet.server.user.service.dto.UserStatusDto; import java.util.List; import java.util.Set; import org.instancio.Instancio; @@ -96,11 +108,6 @@ public static NotificationTokenHTTP.Request notificationTokenHTTPRequest() { return Instancio.create(NotificationTokenHTTP.Request.class); } - public static List keywords() { - return Instancio.ofList(Keyword.class).size(3) - .create(); - } - public static String token() { return Instancio.create(String.class); } @@ -138,4 +145,88 @@ public static User userWithFixedId(Long id) { .create(); } + public static LoginDetailsDto loginDetailsDto() { + return Instancio.of(LoginDetailsDto.class) + .create(); + } + + public static LoginDetailsHTTP.Response loginDetailsHTTPResponse( + LoginDetailsDto response) { + return new Response( + response.userId(), + response.isRegistered(), + response.accessToken(), + response.refreshToken(), + response.nickname(), + response.profileImageUrl(), + response.companyName(), + response.department(), + response.interests() + ); + } + + public static MyProfileDto myProfileDtoResponse() { + return Instancio.of(MyProfileDto.class) + .create(); + } + + public static MyProfileHTTP.Response myProfileHTTPResponse(MyProfileDto response) { + return new MyProfileHTTP.Response( + response.nickname(), + response.profileImageUrl(), + response.companyName(), + response.department(), + response.interests(), + response.oAuthProvider() + ); + } + + public static UserStatusDto userStatusDto() { + return Instancio.of(UserStatusDto.class) + .create(); + } + + public static SignupHTTP.Request signupHTTPRequest() { + return Instancio.of(SignupHTTP.Request.class) + .set(field(Request::keywords), keywords()) + .create(); + } + + public static List keywords() { + return Instancio.ofList(Keyword.class) + .size(3) + .create(); + } + + public static UpdateProfileHTTP.Request updateProfileHTTPRequest() { + return Instancio.of(UpdateProfileHTTP.Request.class) + .set(field(UpdateProfileHTTP.Request::interests), keywords()) + .create(); + } + + public static UserProfileDto userProfileDtoResponse() { + return Instancio.of(UserProfileDto.class) + .create(); + } + + public static UserProfileHTTP.Response userProfileHTTPResponse(UserProfileDto response) { + return new UserProfileHTTP.Response( + response.nickname(), + response.profileImageUrl(), + response.department(), + response.interests() + ); + } + + public static UserStatusHTTP.Response userStatusHTTPResponse(UserStatusDto response) { + return new UserStatusHTTP.Response( + response.userStatus(), + response.startedAt(), + response.chattingRoomId(), + response.chattingRoomName(), + response.isCertificated(), + response.penaltyExpiration() + ); + } + } diff --git a/src/test/java/coffeemeet/server/common/fixture/UserStatusDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/UserStatusDtoFixture.java deleted file mode 100644 index 0e813885..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/UserStatusDtoFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture; - -import coffeemeet.server.user.service.dto.UserStatusDto; -import org.instancio.Instancio; - -public class UserStatusDtoFixture { - - public static UserStatusDto userStatusDto() { - return Instancio.of(UserStatusDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/GroupReportDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/GroupReportDtoFixture.java deleted file mode 100644 index 7d0ad9b4..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/GroupReportDtoFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.report.service.dto.GroupReportDto; -import org.instancio.Instancio; - -public class GroupReportDtoFixture { - - public static GroupReportDto targetReportDto() { - return Instancio.of(GroupReportDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java deleted file mode 100644 index 92c02541..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; -import org.instancio.Instancio; - -public class KakaoMemberResponseFixture { - - public static KakaoMemberDetail kakaoMemberResponse() { - return Instancio.of(KakaoMemberDetail.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/KakaoTokensFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/KakaoTokensFixture.java deleted file mode 100644 index 8f1e5216..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/KakaoTokensFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; -import org.instancio.Instancio; - -public class KakaoTokensFixture { - - public static KakaoTokens kakaoTokens() { - return Instancio.of(KakaoTokens.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsDtoFixture.java deleted file mode 100644 index b2d603fa..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsDtoFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.service.dto.LoginDetailsDto; -import org.instancio.Instancio; - -public class LoginDetailsDtoFixture { - - public static LoginDetailsDto loginDetailsDto() { - return Instancio.of(LoginDetailsDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsHTTPFixture.java deleted file mode 100644 index 6e206b58..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/LoginDetailsHTTPFixture.java +++ /dev/null @@ -1,24 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.presentation.dto.LoginDetailsHTTP; -import coffeemeet.server.user.presentation.dto.LoginDetailsHTTP.Response; -import coffeemeet.server.user.service.dto.LoginDetailsDto; - -public class LoginDetailsHTTPFixture { - - public static LoginDetailsHTTP.Response loginDetailsHTTPResponse( - LoginDetailsDto response) { - return new Response( - response.userId(), - response.isRegistered(), - response.accessToken(), - response.refreshToken(), - response.nickname(), - response.profileImageUrl(), - response.companyName(), - response.department(), - response.interests() - ); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java deleted file mode 100644 index 4620e3f3..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.service.dto.MyProfileDto; -import org.instancio.Instancio; - -public class MyProfileDtoFixture { - - public static MyProfileDto myProfileDtoResponse() { - return Instancio.of(MyProfileDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileHTTPFixture.java deleted file mode 100644 index 6cff5be3..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileHTTPFixture.java +++ /dev/null @@ -1,19 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.presentation.dto.MyProfileHTTP; -import coffeemeet.server.user.service.dto.MyProfileDto; - -public class MyProfileHTTPFixture { - - public static MyProfileHTTP.Response myProfileHTTPResponse(MyProfileDto response) { - return new MyProfileHTTP.Response( - response.nickname(), - response.profileImageUrl(), - response.companyName(), - response.department(), - response.interests(), - response.oAuthProvider() - ); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/NaverMemberResponseFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/NaverMemberResponseFixture.java deleted file mode 100644 index ece597a8..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/NaverMemberResponseFixture.java +++ /dev/null @@ -1,12 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.oauth.infrastructure.naver.dto.NaverMemberDetail; -import org.instancio.Instancio; - -public class NaverMemberResponseFixture { - - public static NaverMemberDetail naverMemberResponse() { - return Instancio.of(NaverMemberDetail.class) - .create(); - } -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/NaverTokenFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/NaverTokenFixture.java deleted file mode 100644 index 994bb72d..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/NaverTokenFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.oauth.infrastructure.naver.dto.NaverTokens; -import org.instancio.Instancio; - -public class NaverTokenFixture { - - public static NaverTokens naverTokens() { - return Instancio.of(NaverTokens.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java deleted file mode 100644 index 01e1157c..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java +++ /dev/null @@ -1,16 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import static org.instancio.Select.field; - -import coffeemeet.server.oauth.domain.OAuthMemberDetail; -import org.instancio.Instancio; - -public class OAuthUserInfoDtoFixture { - - public static OAuthMemberDetail response() { - return Instancio.of(OAuthMemberDetail.class) - .set(field("email"), "test123@gmail.com") - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/RefreshTokenFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/RefreshTokenFixture.java deleted file mode 100644 index 9140ba1a..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/RefreshTokenFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.auth.domain.RefreshToken; -import org.instancio.Instancio; - -public class RefreshTokenFixture { - - public static RefreshToken refreshToken() { - return Instancio.of(RefreshToken.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailDtoFixture.java deleted file mode 100644 index fb443b04..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailDtoFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.report.service.dto.ReportDetailDto; -import org.instancio.Instancio; - -public class ReportDetailDtoFixture { - - public static ReportDetailDto reportDetailDto() { - return Instancio.of(ReportDetailDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java deleted file mode 100644 index bf67139a..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDetailHTTPFixture.java +++ /dev/null @@ -1,21 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; -import coffeemeet.server.report.service.dto.ReportDetailDto; - -public class ReportDetailHTTPFixture { - - public static ReportDetailHTTP.Response reportDetailHTTPResponse( - ReportDetailDto response) { - return new ReportDetailHTTP.Response( - response.reporterNickname(), - response.targetedNickname(), - response.targetedEmail(), - response.reason(), - response.reasonDetail(), - response.reportedCount(), - response.createdAt() - ); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java deleted file mode 100644 index 7eef970b..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/ReportDtoFixture.java +++ /dev/null @@ -1,19 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.report.service.dto.ReportDto; -import coffeemeet.server.report.service.dto.ReportListDto; -import org.instancio.Instancio; - -public class ReportDtoFixture { - - public static ReportDto reportDto() { - return Instancio.of(ReportDto.class) - .create(); - } - - public static ReportListDto reportListDto() { - return Instancio.of(ReportListDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/SignupHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/SignupHTTPFixture.java deleted file mode 100644 index fc143010..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/SignupHTTPFixture.java +++ /dev/null @@ -1,25 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import static org.instancio.Select.field; - -import coffeemeet.server.user.domain.Keyword; -import coffeemeet.server.user.presentation.dto.SignupHTTP; -import coffeemeet.server.user.presentation.dto.SignupHTTP.Request; -import java.util.List; -import org.instancio.Instancio; - -public class SignupHTTPFixture { - - public static SignupHTTP.Request signupHTTPRequest() { - return Instancio.of(SignupHTTP.Request.class) - .set(field(Request::keywords), keywords()) - .create(); - } - - public static List keywords() { - return Instancio.ofList(Keyword.class) - .size(3) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileHTTPFixture.java deleted file mode 100644 index f65ab68d..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileHTTPFixture.java +++ /dev/null @@ -1,24 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import static org.instancio.Select.field; - -import coffeemeet.server.user.domain.Keyword; -import coffeemeet.server.user.presentation.dto.UpdateProfileHTTP; -import java.util.List; -import org.instancio.Instancio; - -public class UpdateProfileHTTPFixture { - - public static UpdateProfileHTTP.Request updateProfileHTTPRequest() { - return Instancio.of(UpdateProfileHTTP.Request.class) - .set(field(UpdateProfileHTTP.Request::interests), keywords()) - .create(); - } - - public static List keywords() { - return Instancio.ofList(Keyword.class) - .size(3) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/UserProfileDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/UserProfileDtoFixture.java deleted file mode 100644 index 3c60bf2c..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UserProfileDtoFixture.java +++ /dev/null @@ -1,13 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.service.dto.UserProfileDto; -import org.instancio.Instancio; - -public class UserProfileDtoFixture { - - public static UserProfileDto userProfileDtoResponse() { - return Instancio.of(UserProfileDto.class) - .create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/UserProfileHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/UserProfileHTTPFixture.java deleted file mode 100644 index 612a83a4..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UserProfileHTTPFixture.java +++ /dev/null @@ -1,17 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.presentation.dto.UserProfileHTTP; -import coffeemeet.server.user.service.dto.UserProfileDto; - -public class UserProfileHTTPFixture { - - public static UserProfileHTTP.Response userProfileHTTPResponse(UserProfileDto response) { - return new UserProfileHTTP.Response( - response.nickname(), - response.profileImageUrl(), - response.department(), - response.interests() - ); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/UserStatusHTTPFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/UserStatusHTTPFixture.java deleted file mode 100644 index c54899f6..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UserStatusHTTPFixture.java +++ /dev/null @@ -1,19 +0,0 @@ -package coffeemeet.server.common.fixture.dto; - -import coffeemeet.server.user.presentation.dto.UserStatusHTTP; -import coffeemeet.server.user.service.dto.UserStatusDto; - -public class UserStatusHTTPFixture { - - public static UserStatusHTTP.Response userStatusHTTPResponse(UserStatusDto response) { - return new UserStatusHTTP.Response( - response.userStatus(), - response.startedAt(), - response.chattingRoomId(), - response.chattingRoomName(), - response.isCertificated(), - response.penaltyExpiration() - ); - } - -} diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java deleted file mode 100644 index 1918a192..00000000 --- a/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java +++ /dev/null @@ -1,22 +0,0 @@ -package coffeemeet.server.common.fixture.entity; - -import static org.instancio.Select.field; - -import coffeemeet.server.report.domain.Report; -import org.instancio.Instancio; - -public class ReportFixture { - - public static Report report() { - return Instancio.of(Report.class) - .generate(field(Report::getReasonDetail), gen -> gen.string().maxLength(200)).create(); - } - - public static Report report(Long targetId, Long chattingRoomId) { - return Instancio.of(Report.class) - .set(field(Report::getTargetedId), targetId) - .set(field(Report::getChattingRoomId), chattingRoomId) - .generate(field(Report::getReasonDetail), gen -> gen.string().maxLength(200)).create(); - } - -} diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 7b2a3ba7..6632844a 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,6 +1,8 @@ package coffeemeet.server.common.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; +import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.CertificationFixture.email; +import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.then; @@ -23,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class EmailSenderTest { - private EmailSender emailSender; + private coffeemeet.server.common.implement.EmailSender emailSender; @Mock private JavaMailSender javaMailSender; @@ -36,7 +38,7 @@ class EmailSenderTest { @BeforeEach void setUp() { sender = email(); - emailSender = new EmailSender(javaMailSender, sender); + emailSender = new coffeemeet.server.common.implement.EmailSender(javaMailSender, sender); } @Test diff --git a/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java b/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java index 5f93c06c..f5cf7f25 100644 --- a/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/FCMNotificationSenderTest.java @@ -1,8 +1,8 @@ package coffeemeet.server.common.implement; -import static coffeemeet.server.common.fixture.entity.UserFixture.content; -import static coffeemeet.server.common.fixture.entity.UserFixture.notificationInfo; -import static coffeemeet.server.common.fixture.entity.UserFixture.notificationInfos; +import static coffeemeet.server.common.fixture.UserFixture.content; +import static coffeemeet.server.common.fixture.UserFixture.notificationInfo; +import static coffeemeet.server.common.fixture.UserFixture.notificationInfos; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; diff --git a/src/test/java/coffeemeet/server/inquiry/implement/InquiryCommandTest.java b/src/test/java/coffeemeet/server/inquiry/implement/InquiryCommandTest.java index ef8a2ace..1ea439d9 100644 --- a/src/test/java/coffeemeet/server/inquiry/implement/InquiryCommandTest.java +++ b/src/test/java/coffeemeet/server/inquiry/implement/InquiryCommandTest.java @@ -5,7 +5,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.entity.InquiryFixture; +import coffeemeet.server.common.fixture.InquiryFixture; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.inquiry.infrastructure.InquiryRepository; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/inquiry/implement/InquiryQueryTest.java b/src/test/java/coffeemeet/server/inquiry/implement/InquiryQueryTest.java index 38a8a020..22f9b675 100644 --- a/src/test/java/coffeemeet/server/inquiry/implement/InquiryQueryTest.java +++ b/src/test/java/coffeemeet/server/inquiry/implement/InquiryQueryTest.java @@ -4,7 +4,7 @@ import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.entity.InquiryFixture; +import coffeemeet.server.common.fixture.InquiryFixture; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.inquiry.infrastructure.InquiryQueryRepository; import coffeemeet.server.inquiry.infrastructure.InquiryRepository; diff --git a/src/test/java/coffeemeet/server/inquiry/infrastructure/InquiryQueryRepositoryTest.java b/src/test/java/coffeemeet/server/inquiry/infrastructure/InquiryQueryRepositoryTest.java index 4c4e44db..5a93288e 100644 --- a/src/test/java/coffeemeet/server/inquiry/infrastructure/InquiryQueryRepositoryTest.java +++ b/src/test/java/coffeemeet/server/inquiry/infrastructure/InquiryQueryRepositoryTest.java @@ -3,8 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import coffeemeet.server.common.config.RepositoryTestConfig; -import coffeemeet.server.common.fixture.entity.InquiryFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.InquiryFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; diff --git a/src/test/java/coffeemeet/server/inquiry/presentation/InquiryControllerTest.java b/src/test/java/coffeemeet/server/inquiry/presentation/InquiryControllerTest.java index 6c16755b..9dd2ad73 100644 --- a/src/test/java/coffeemeet/server/inquiry/presentation/InquiryControllerTest.java +++ b/src/test/java/coffeemeet/server/inquiry/presentation/InquiryControllerTest.java @@ -18,8 +18,8 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; -import coffeemeet.server.common.fixture.entity.InquiryFixture; +import coffeemeet.server.common.fixture.AuthFixture; +import coffeemeet.server.common.fixture.InquiryFixture; import coffeemeet.server.inquiry.presentation.dto.InquiryHTTP; import coffeemeet.server.inquiry.service.InquiryService; import com.epages.restdocs.apispec.Schema; @@ -42,7 +42,7 @@ void inquireTest() throws Exception { // given Long inquirerId = 1L; InquiryHTTP.Request request = InquiryFixture.request(); - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(inquirerId); diff --git a/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java b/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java index ed40713d..8a5197a9 100644 --- a/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java +++ b/src/test/java/coffeemeet/server/inquiry/service/InquiryServiceTest.java @@ -8,8 +8,8 @@ import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willDoNothing; -import coffeemeet.server.common.fixture.entity.InquiryFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.InquiryFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.inquiry.implement.InquiryCommand; import coffeemeet.server.inquiry.implement.InquiryQuery; diff --git a/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java b/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java index dc17f20c..17c71821 100644 --- a/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java +++ b/src/test/java/coffeemeet/server/matching/presentation/MatchingControllerTest.java @@ -12,7 +12,7 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; +import coffeemeet.server.common.fixture.AuthFixture; import coffeemeet.server.matching.service.MatchingService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -29,7 +29,7 @@ class MatchingControllerTest extends ControllerTestConfig { @BeforeEach void setUp() { - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); } diff --git a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java index bf987355..214f4e97 100644 --- a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java +++ b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java @@ -1,12 +1,8 @@ package coffeemeet.server.matching.service; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificatedCertifications; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingRoom; -import static coffeemeet.server.common.fixture.entity.UserFixture.fourUsers; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.fixture.entity.UserFixture.userExcludingStatus; -import static coffeemeet.server.user.domain.UserStatus.MATCHING; -import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static coffeemeet.server.common.fixture.CertificationFixture.certificatedCertifications; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; +import static coffeemeet.server.common.fixture.UserFixture.fourUsers; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willDoNothing; @@ -118,7 +114,7 @@ void cancelMatching() { } @Test - @DisplayName("매칭을 취소할 수 있다.") + @DisplayName("MATCHING 상태가 아닐 때 매칭을 취소하면 예외가 발생 한다.") void cancelMatching_BadException() { // given User user = userExcludingStatus(MATCHING); diff --git a/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java b/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java index 26accbc0..9f1c2ac8 100644 --- a/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java +++ b/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture; +import coffeemeet.server.common.fixture.OauthFixture; import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.oauth.implement.client.OAuthMemberClient; import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; @@ -36,7 +36,7 @@ void fetchTest() { // given String authCode = "authCode"; OAuthProvider oAuthProvider = OAuthProvider.KAKAO; - OAuthMemberDetail response = OAuthUserInfoDtoFixture.response(); + OAuthMemberDetail response = OauthFixture.response(); given(client.oAuthProvider()).willReturn(OAuthProvider.KAKAO); given(client.fetch(authCode)).willReturn(response); diff --git a/src/test/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClientTest.java b/src/test/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClientTest.java index d275426b..6bf403cb 100644 --- a/src/test/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClientTest.java +++ b/src/test/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClientTest.java @@ -4,8 +4,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.dto.KakaoMemberResponseFixture; -import coffeemeet.server.common.fixture.dto.KakaoTokensFixture; +import coffeemeet.server.common.fixture.OauthFixture; import coffeemeet.server.oauth.infrastructure.kakao.KakaoClient; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; @@ -38,8 +37,8 @@ void oAuthProviderTest() { void fetchTest() { // given String authCode = "authCode"; - KakaoTokens kakaoTokens = KakaoTokensFixture.kakaoTokens(); - KakaoMemberDetail response = KakaoMemberResponseFixture.kakaoMemberResponse(); + KakaoTokens kakaoTokens = OauthFixture.kakaoTokens(); + KakaoMemberDetail response = OauthFixture.kakaoMemberResponse(); given(kakaoClient.fetchToken(any())).willReturn(kakaoTokens); given(kakaoClient.fetchMember(any())).willReturn(response); diff --git a/src/test/java/coffeemeet/server/oauth/implement/client/naver/NaverMemberClientTest.java b/src/test/java/coffeemeet/server/oauth/implement/client/naver/NaverMemberClientTest.java index 4859c2b2..49f06f35 100644 --- a/src/test/java/coffeemeet/server/oauth/implement/client/naver/NaverMemberClientTest.java +++ b/src/test/java/coffeemeet/server/oauth/implement/client/naver/NaverMemberClientTest.java @@ -4,8 +4,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.dto.NaverMemberResponseFixture; -import coffeemeet.server.common.fixture.dto.NaverTokenFixture; +import coffeemeet.server.common.fixture.OauthFixture; import coffeemeet.server.oauth.infrastructure.naver.NaverClient; import coffeemeet.server.oauth.infrastructure.naver.dto.NaverMemberDetail; import coffeemeet.server.oauth.infrastructure.naver.dto.NaverTokens; @@ -38,8 +37,8 @@ void oAuthProviderTest() { void fetchTest() { // given String authCode = "authCode"; - NaverTokens naverTokens = NaverTokenFixture.naverTokens(); - NaverMemberDetail response = NaverMemberResponseFixture.naverMemberResponse(); + NaverTokens naverTokens = OauthFixture.naverTokens(); + NaverMemberDetail response = OauthFixture.naverMemberResponse(); given(naverClient.fetchToken(any())).willReturn(naverTokens); given(naverClient.fetchMember(any())).willReturn(response); diff --git a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClientTest.java b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClientTest.java index 3b2c6d66..b62043a6 100644 --- a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClientTest.java +++ b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClientTest.java @@ -7,8 +7,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.dto.KakaoMemberResponseFixture; -import coffeemeet.server.common.fixture.dto.KakaoTokensFixture; +import coffeemeet.server.common.fixture.OauthFixture; import coffeemeet.server.oauth.config.kakao.KakaoProperties; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; @@ -41,7 +40,7 @@ class KakaoClientTest { void fetchTokenTest() { // given String authCode = "authCode"; - KakaoTokens kakaoTokens = KakaoTokensFixture.kakaoTokens(); + KakaoTokens kakaoTokens = OauthFixture.kakaoTokens(); given(kakaoProperties.getClientId()).willReturn("testClientId"); given(kakaoProperties.getRedirectUrl()).willReturn("testRedirectUrl"); @@ -75,7 +74,7 @@ void fetchTokenTest() { @Test void fetchMemberTest() { // given - KakaoMemberDetail response = KakaoMemberResponseFixture.kakaoMemberResponse(); + KakaoMemberDetail response = OauthFixture.kakaoMemberResponse(); ResponseEntity mockResponse = ResponseEntity.ok(response); given(restTemplate.exchange( diff --git a/src/test/java/coffeemeet/server/oauth/infrastructure/naver/NaverClientTest.java b/src/test/java/coffeemeet/server/oauth/infrastructure/naver/NaverClientTest.java index b4d2fbf0..24cd622c 100644 --- a/src/test/java/coffeemeet/server/oauth/infrastructure/naver/NaverClientTest.java +++ b/src/test/java/coffeemeet/server/oauth/infrastructure/naver/NaverClientTest.java @@ -7,8 +7,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.dto.NaverMemberResponseFixture; -import coffeemeet.server.common.fixture.dto.NaverTokenFixture; +import coffeemeet.server.common.fixture.OauthFixture; import coffeemeet.server.oauth.config.naver.NaverProperties; import coffeemeet.server.oauth.infrastructure.naver.dto.NaverMemberDetail; import coffeemeet.server.oauth.infrastructure.naver.dto.NaverTokens; @@ -42,7 +41,7 @@ class NaverClientTest { void fetchTokenTest() { // given String authCode = "authCode"; - NaverTokens naverTokens = NaverTokenFixture.naverTokens(); + NaverTokens naverTokens = OauthFixture.naverTokens(); given(naverProperties.getClientId()).willReturn("testClientId"); given(naverProperties.getRedirectUrl()).willReturn("testRedirectUrl"); @@ -78,7 +77,7 @@ void fetchTokenTest() { @Test void fetchMemberTest() { // given - NaverMemberDetail response = NaverMemberResponseFixture.naverMemberResponse(); + NaverMemberDetail response = OauthFixture.naverMemberResponse(); ResponseEntity mockResponse = ResponseEntity.ok(response); given(restTemplate.exchange( diff --git a/src/test/java/coffeemeet/server/report/implement/ReportCommandTest.java b/src/test/java/coffeemeet/server/report/implement/ReportCommandTest.java index de29f20a..aa101190 100644 --- a/src/test/java/coffeemeet/server/report/implement/ReportCommandTest.java +++ b/src/test/java/coffeemeet/server/report/implement/ReportCommandTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.report.implement; -import static coffeemeet.server.common.fixture.entity.ReportFixture.report; +import static coffeemeet.server.common.fixture.ReportFixture.report; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; diff --git a/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java b/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java index f8166a7e..738c3eac 100644 --- a/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java +++ b/src/test/java/coffeemeet/server/report/implement/ReportQueryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.report.implement; -import static coffeemeet.server.common.fixture.entity.ReportFixture.report; +import static coffeemeet.server.common.fixture.ReportFixture.report; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; diff --git a/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java b/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java index 0c0a3326..25809aa7 100644 --- a/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java +++ b/src/test/java/coffeemeet/server/report/infrastructure/ReportQueryRepositoryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.report.infrastructure; -import static coffeemeet.server.common.fixture.entity.ReportFixture.report; +import static coffeemeet.server.common.fixture.ReportFixture.report; import static org.assertj.core.api.Assertions.assertThat; import coffeemeet.server.common.config.RepositoryTestConfig; diff --git a/src/test/java/coffeemeet/server/report/infrastructure/ReportRepositoryTest.java b/src/test/java/coffeemeet/server/report/infrastructure/ReportRepositoryTest.java index f5022f21..c2ff3c1f 100644 --- a/src/test/java/coffeemeet/server/report/infrastructure/ReportRepositoryTest.java +++ b/src/test/java/coffeemeet/server/report/infrastructure/ReportRepositoryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.report.infrastructure; -import static coffeemeet.server.common.fixture.entity.ReportFixture.report; +import static coffeemeet.server.common.fixture.ReportFixture.report; import static org.junit.jupiter.api.Assertions.assertTrue; import coffeemeet.server.common.config.RepositoryTestConfig; diff --git a/src/test/java/coffeemeet/server/report/presentation/ReportControllerTest.java b/src/test/java/coffeemeet/server/report/presentation/ReportControllerTest.java index f4e7b8b4..a752b617 100644 --- a/src/test/java/coffeemeet/server/report/presentation/ReportControllerTest.java +++ b/src/test/java/coffeemeet/server/report/presentation/ReportControllerTest.java @@ -18,7 +18,7 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; +import coffeemeet.server.common.fixture.AuthFixture; import coffeemeet.server.report.presentation.dto.CreateReportHTTP; import coffeemeet.server.report.service.ReportService; import com.epages.restdocs.apispec.Schema; @@ -38,7 +38,7 @@ class ReportControllerTest extends ControllerTestConfig { @BeforeEach void setUp() { - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); } diff --git a/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java b/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java index 2d94c767..65269c32 100644 --- a/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java +++ b/src/test/java/coffeemeet/server/report/service/ReportServiceTest.java @@ -1,7 +1,7 @@ package coffeemeet.server.report.service; -import static coffeemeet.server.common.fixture.entity.ReportFixture.report; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.ReportFixture.report; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; @@ -16,7 +16,7 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.common.execption.NotFoundException; -import coffeemeet.server.common.fixture.entity.ChattingFixture; +import coffeemeet.server.common.fixture.ChattingFixture; import coffeemeet.server.report.domain.Report; import coffeemeet.server.report.implement.ReportCommand; import coffeemeet.server.report.implement.ReportQuery; diff --git a/src/test/java/coffeemeet/server/user/domain/InterestTest.java b/src/test/java/coffeemeet/server/user/domain/InterestTest.java index 61504e62..97d8269b 100644 --- a/src/test/java/coffeemeet/server/user/domain/InterestTest.java +++ b/src/test/java/coffeemeet/server/user/domain/InterestTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.domain; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThatCode; import org.junit.jupiter.api.DisplayName; @@ -19,4 +19,4 @@ void interestTest() { assertThatCode(() -> new Interest(Keyword.게임, user)).doesNotThrowAnyException(); } -} \ No newline at end of file +} diff --git a/src/test/java/coffeemeet/server/user/implement/InterestCommandTest.java b/src/test/java/coffeemeet/server/user/implement/InterestCommandTest.java index 9ffffefc..10611e51 100644 --- a/src/test/java/coffeemeet/server/user/implement/InterestCommandTest.java +++ b/src/test/java/coffeemeet/server/user/implement/InterestCommandTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.implement; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/user/implement/InterestQueryTest.java b/src/test/java/coffeemeet/server/user/implement/InterestQueryTest.java index 69af6032..634907a6 100644 --- a/src/test/java/coffeemeet/server/user/implement/InterestQueryTest.java +++ b/src/test/java/coffeemeet/server/user/implement/InterestQueryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.implement; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/user/implement/UserCommandTest.java b/src/test/java/coffeemeet/server/user/implement/UserCommandTest.java index 809ddd65..f32b91a7 100644 --- a/src/test/java/coffeemeet/server/user/implement/UserCommandTest.java +++ b/src/test/java/coffeemeet/server/user/implement/UserCommandTest.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.implement; -import static coffeemeet.server.common.fixture.entity.UserFixture.token; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.token; +import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.user.domain.UserStatus.CHATTING_CONNECTED; import static coffeemeet.server.user.domain.UserStatus.CHATTING_UNCONNECTED; import static coffeemeet.server.user.domain.UserStatus.IDLE; diff --git a/src/test/java/coffeemeet/server/user/implement/UserQueryTest.java b/src/test/java/coffeemeet/server/user/implement/UserQueryTest.java index 009c6fba..94135eac 100644 --- a/src/test/java/coffeemeet/server/user/implement/UserQueryTest.java +++ b/src/test/java/coffeemeet/server/user/implement/UserQueryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.implement; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; diff --git a/src/test/java/coffeemeet/server/user/infrastructure/UserRepositoryTest.java b/src/test/java/coffeemeet/server/user/infrastructure/UserRepositoryTest.java index 2535ad2d..cb93a0ab 100644 --- a/src/test/java/coffeemeet/server/user/infrastructure/UserRepositoryTest.java +++ b/src/test/java/coffeemeet/server/user/infrastructure/UserRepositoryTest.java @@ -1,10 +1,10 @@ package coffeemeet.server.user.infrastructure; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import coffeemeet.server.common.config.RepositoryTestConfig; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.OAuthInfo; import coffeemeet.server.user.domain.User; import java.util.HashSet; diff --git a/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java b/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java index f381b623..cbae9d8b 100644 --- a/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java +++ b/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.presentation; -import static coffeemeet.server.common.fixture.entity.UserFixture.notificationTokenHTTPRequest; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.notificationTokenHTTPRequest; +import static coffeemeet.server.common.fixture.UserFixture.user; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; import static org.apache.http.HttpHeaders.AUTHORIZATION; @@ -33,17 +33,8 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.common.config.ControllerTestConfig; -import coffeemeet.server.common.fixture.UserStatusDtoFixture; -import coffeemeet.server.common.fixture.dto.LoginDetailsDtoFixture; -import coffeemeet.server.common.fixture.dto.LoginDetailsHTTPFixture; -import coffeemeet.server.common.fixture.dto.MyProfileDtoFixture; -import coffeemeet.server.common.fixture.dto.MyProfileHTTPFixture; -import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; -import coffeemeet.server.common.fixture.dto.SignupHTTPFixture; -import coffeemeet.server.common.fixture.dto.UpdateProfileHTTPFixture; -import coffeemeet.server.common.fixture.dto.UserProfileDtoFixture; -import coffeemeet.server.common.fixture.dto.UserProfileHTTPFixture; -import coffeemeet.server.common.fixture.dto.UserStatusHTTPFixture; +import coffeemeet.server.common.fixture.AuthFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.presentation.dto.LoginDetailsHTTP; @@ -76,7 +67,7 @@ class UserControllerTest extends ControllerTestConfig { @BeforeEach void setUp() { - RefreshToken refreshToken = RefreshTokenFixture.refreshToken(); + RefreshToken refreshToken = AuthFixture.refreshToken(); given(refreshTokenQuery.getRefreshToken(anyLong())).willReturn(refreshToken); } @@ -84,7 +75,7 @@ void setUp() { @DisplayName("회원가입을 할 수 있다.") void signupTest() throws Exception { // given - SignupHTTP.Request request = SignupHTTPFixture.signupHTTPRequest(); + SignupHTTP.Request request = UserFixture.signupHTTPRequest(); willDoNothing().given(userService).signup(any(), any(), anyList()); @@ -112,8 +103,8 @@ void signupTest() throws Exception { @DisplayName("로그인을 할 수 있다.") void loginTest() throws Exception { // given - LoginDetailsDto response = LoginDetailsDtoFixture.loginDetailsDto(); - LoginDetailsHTTP.Response expectedResponse = LoginDetailsHTTPFixture.loginDetailsHTTPResponse( + LoginDetailsDto response = UserFixture.loginDetailsDto(); + LoginDetailsHTTP.Response expectedResponse = UserFixture.loginDetailsHTTPResponse( response); given(userService.login(any(), any())).willReturn(response); @@ -155,8 +146,8 @@ void loginTest() throws Exception { @DisplayName("사용자 프로필을 조회할 수 있다.") void findUserProfileTest() throws Exception { // given - UserProfileDto response = UserProfileDtoFixture.userProfileDtoResponse(); - UserProfileHTTP.Response expectedResponse = UserProfileHTTPFixture.userProfileHTTPResponse( + UserProfileDto response = UserFixture.userProfileDtoResponse(); + UserProfileHTTP.Response expectedResponse = UserFixture.userProfileHTTPResponse( response); given(userService.findUserProfile(anyLong())).willReturn(response); @@ -189,8 +180,8 @@ void findUserProfileTest() throws Exception { @DisplayName("마이페이지를 조회할 수 있다.") void findMyProfileTest() throws Exception { // given - MyProfileDto response = MyProfileDtoFixture.myProfileDtoResponse(); - MyProfileHTTP.Response expectedResponse = MyProfileHTTPFixture.myProfileHTTPResponse(response); + MyProfileDto response = UserFixture.myProfileDtoResponse(); + MyProfileHTTP.Response expectedResponse = UserFixture.myProfileHTTPResponse(response); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(USER_ID); given(userService.findMyProfile(anyLong())).willReturn(response); @@ -254,7 +245,7 @@ void updateProfileImageTest() throws Exception { @DisplayName("본인 프로필 정보를 수정할 수 있다.") void updateProfileInfoTest() throws Exception { // given - UpdateProfileHTTP.Request request = UpdateProfileHTTPFixture.updateProfileHTTPRequest(); + UpdateProfileHTTP.Request request = UserFixture.updateProfileHTTPRequest(); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(USER_ID); willDoNothing().given( @@ -346,8 +337,8 @@ void unsubscribeNotificationTest() throws Exception { @DisplayName("유저 상태를 요청할 수 있다.") void getUserStatusTest() throws Exception { // given - UserStatusDto response = UserStatusDtoFixture.userStatusDto(); - UserStatusHTTP.Response expectedResponse = UserStatusHTTPFixture.userStatusHTTPResponse( + UserStatusDto response = UserFixture.userStatusDto(); + UserStatusHTTP.Response expectedResponse = UserFixture.userStatusHTTPResponse( response); given(userService.getUserStatus(anyLong())).willReturn(response); diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index 9b2a27a0..62dc07f6 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -1,12 +1,12 @@ package coffeemeet.server.user.service; import static coffeemeet.server.common.domain.S3KeyPrefix.PROFILE_IMAGE; -import static coffeemeet.server.common.fixture.dto.AuthTokensFixture.authTokens; -import static coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture.response; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.ChattingFixture.chattingRoom; -import static coffeemeet.server.common.fixture.entity.UserFixture.keywords; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.AuthFixture.authTokens; +import static coffeemeet.server.common.fixture.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; +import static coffeemeet.server.common.fixture.OauthFixture.response; +import static coffeemeet.server.common.fixture.UserFixture.keywords; +import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -31,8 +31,7 @@ import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.common.domain.ObjectStorage; -import coffeemeet.server.common.fixture.dto.SignupHTTPFixture; -import coffeemeet.server.common.fixture.entity.UserFixture; +import coffeemeet.server.common.fixture.UserFixture; import coffeemeet.server.matching.implement.MatchingQueueCommand; import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; @@ -98,7 +97,7 @@ class UserServiceTest { @Test void signupTest() { // given - SignupHTTP.Request request = SignupHTTPFixture.signupHTTPRequest(); + SignupHTTP.Request request = UserFixture.signupHTTPRequest(); User user = user(); given(userQuery.getNonRegisteredUserById(anyLong())).willReturn(user); @@ -153,7 +152,7 @@ void findUserProfileTest() { // given User user = user(); Certification certification = certification(); - List keywords = UserFixture.keywords(); + List keywords = keywords(); UserProfileDto response = UserProfileDto.of(user, keywords, certification); given(userQuery.getUserById(anyLong())).willReturn(user); @@ -243,7 +242,7 @@ void updateProfileImage() throws IOException { @Test void updateProfileInfo() { // given - User user = UserFixture.user(); + User user = user(); String newNickname = "새닉네임"; List newKeywords = keywords(); @@ -322,7 +321,7 @@ class GetUserStatusTest { void getUserStatusIdleTest() { // given Long userId = 1L; - User user = UserFixture.user(UserStatus.IDLE); + User user = user(UserStatus.IDLE); Certification certification = certification(); given(userQuery.getUserById(anyLong())).willReturn(user); @@ -347,7 +346,7 @@ void getUserStatusMatchingTest() { // given Long userId = 1L; LocalDateTime startedAt = LocalDateTime.of(2020, 10, 9, 8, 9); - User user = UserFixture.user(UserStatus.MATCHING); + User user = user(UserStatus.MATCHING); Certification certification = certification(); given(userQuery.getUserById(anyLong())).willReturn(user); @@ -372,7 +371,7 @@ void getUserStatusMatchingTest() { void getUserStatusChattingUnConnectingTest() { // given Long userId = 1L; - User user = UserFixture.user(UserStatus.MATCHING); + User user = user(UserStatus.MATCHING); user.completeMatching(chattingRoom()); Certification certification = certification(); @@ -397,7 +396,7 @@ void getUserStatusChattingUnConnectingTest() { void getUserStatusReportedTest() { // given Long userId = 1L; - User user = UserFixture.user(UserStatus.REPORTED); + User user = user(UserStatus.REPORTED); Certification certification = certification(); given(userQuery.getUserById(anyLong())).willReturn(user); From 04646223c9b5890157b54164848924c1322c99c9 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 20:13:53 +0900 Subject: [PATCH 25/74] =?UTF-8?q?refactor:=20String=20=EA=B0=92=20?= =?UTF-8?q?=EC=83=81=EC=88=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/coffeemeet/server/admin/implement/AdminQuery.java | 7 +++++-- .../server/matching/service/MatchingService.java | 3 ++- .../java/coffeemeet/server/user/domain/ReportInfo.java | 3 ++- src/main/java/coffeemeet/server/user/domain/User.java | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/coffeemeet/server/admin/implement/AdminQuery.java b/src/main/java/coffeemeet/server/admin/implement/AdminQuery.java index a027ccb8..e164dcc7 100644 --- a/src/main/java/coffeemeet/server/admin/implement/AdminQuery.java +++ b/src/main/java/coffeemeet/server/admin/implement/AdminQuery.java @@ -13,18 +13,21 @@ @RequiredArgsConstructor public class AdminQuery { + private static final String ID_VALIDATION_ERROR_MESSAGE = "유효하지 않은 관리자 아이디(%s)입니다."; + private static final String PASSWORD_VALIDATION_ERROR_MESSAGE = "유효하지 않은 관리자 비밀번호(%s)입니다."; + private final AdminRepository adminRepository; public void checkIdAndPassword(String id, String password) { Admin admin = adminRepository.findById(id) .orElseThrow(() -> new NotFoundException(VALIDATION_ERROR, - String.format("유효하지 않은 관리자 아이디(%s)입니다.", id))); + String.format(ID_VALIDATION_ERROR_MESSAGE, id))); if (admin.isCorrectPassword(password)) { return; } throw new NotFoundException(VALIDATION_ERROR, - String.format("유효하지 않은 관리자 비밀번호(%s)입니다.", password)); + String.format(PASSWORD_VALIDATION_ERROR_MESSAGE, password)); } } diff --git a/src/main/java/coffeemeet/server/matching/service/MatchingService.java b/src/main/java/coffeemeet/server/matching/service/MatchingService.java index df10a127..f2548877 100644 --- a/src/main/java/coffeemeet/server/matching/service/MatchingService.java +++ b/src/main/java/coffeemeet/server/matching/service/MatchingService.java @@ -23,6 +23,7 @@ @RequiredArgsConstructor public class MatchingService { + private static final String NOT_CERTIFICATED_USER_MESSAGE = "사용자(%s) 인증이 완료되지 않았습니다."; private static final long FIXED_MATCH_GROUP_SIZE = 4; private final FCMNotificationSender notificationSender; @@ -37,7 +38,7 @@ public void startMatching(Long userId) { Certification certification = certificationQuery.getCertificationByUserId(userId); // if (!certification.isCertificated()) { // throw new ForbiddenException(NOT_CERTIFICATED_USER, -// String.format("사용자(%s) 인증이 완료되지 않았습니다.", userId)); +// String.format(NOT_CERTIFICATED_USER_MESSAGE, userId)); // } String companyName = certification.getCompanyName(); diff --git a/src/main/java/coffeemeet/server/user/domain/ReportInfo.java b/src/main/java/coffeemeet/server/user/domain/ReportInfo.java index 09adca19..a5647dc4 100644 --- a/src/main/java/coffeemeet/server/user/domain/ReportInfo.java +++ b/src/main/java/coffeemeet/server/user/domain/ReportInfo.java @@ -13,6 +13,7 @@ @Embeddable public class ReportInfo { + private static final String EXCEED_REPORT_COUNT_MESSAGE = "최대 신고 누적 횟수를 초과합니다. 신고 누적 횟수(%s)"; private static final int REPORT_MIN_COUNT = 0; private static final int REPORT_MAX_COUNT = 5; @@ -27,7 +28,7 @@ public ReportInfo() { public void increment() { if (reportedCount >= REPORT_MAX_COUNT) { throw new LimitExceededException(EXCEEDED_MAX_REPORT_COUNT, - String.format("최대 신고 누적 횟수를 초과합니다. 신고 누적 횟수(%s)", reportedCount)); + String.format(EXCEED_REPORT_COUNT_MESSAGE, reportedCount)); } this.reportedCount++; int sanctionPeriodByReportCount = ReportPenalty.getSanctionPeriodByReportCount(reportedCount); diff --git a/src/main/java/coffeemeet/server/user/domain/User.java b/src/main/java/coffeemeet/server/user/domain/User.java index b20af9cb..ea2a4639 100644 --- a/src/main/java/coffeemeet/server/user/domain/User.java +++ b/src/main/java/coffeemeet/server/user/domain/User.java @@ -37,7 +37,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class User extends AdvancedBaseEntity { - public static final String INVALID_USER_STATUS = "올바르지 않은 유저 상태입니다."; + private static final String INVALID_USER_STATUS = "올바르지 않은 유저 상태입니다."; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) From 2c6a911179af0640fb3fcf484067d09639b28529 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:06:14 +0900 Subject: [PATCH 26/74] =?UTF-8?q?refactor:=20Faker=20=EB=8C=80=EC=8B=A0=20?= =?UTF-8?q?instancio=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/auth/domain/AuthTokensGeneratorTest.java | 6 +++--- .../coffeemeet/server/auth/service/AuthServiceTest.java | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java b/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java index a7f2c8b1..0e1b68e4 100644 --- a/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java +++ b/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java @@ -7,8 +7,8 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.auth.implement.RefreshTokenCommand; -import com.github.javafaker.Faker; import java.util.Date; +import org.instancio.Instancio; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -49,7 +49,7 @@ void generateTest() { REFRESH_TOKEN); // when - AuthTokens authTokens = authTokensGenerator.generate(Faker.instance().random().nextLong()); + AuthTokens authTokens = authTokensGenerator.generate(Instancio.create(Long.class)); // then assertAll( @@ -67,7 +67,7 @@ void reissueAccessTokenTest() { // when AuthTokens authTokens = authTokensGenerator.reissueAccessToken( - Faker.instance().random().nextLong(), + Instancio.create(Long.class), REFRESH_TOKEN); // then diff --git a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java index 06561b6e..14ba36c1 100644 --- a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java +++ b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java @@ -16,7 +16,6 @@ import coffeemeet.server.common.execption.InvalidAuthException; import coffeemeet.server.common.fixture.AuthFixture; import coffeemeet.server.user.service.UserService; -import com.github.javafaker.Faker; import org.instancio.Instancio; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -57,7 +56,7 @@ void renewTest() { newAuthTokens); // when - AuthTokens renewedAuthTokens = authService.renew(Faker.instance().random().nextLong(), + AuthTokens renewedAuthTokens = authService.renew(Instancio.create(Long.class), REFRESH_TOKEN); // then @@ -74,7 +73,7 @@ void renewFailTest() { given(jwtTokenProvider.isExpiredRefreshToken(REFRESH_TOKEN)).willReturn(true); // when, then - assertThatThrownBy(() -> authService.renew(Faker.instance().random().nextLong(), REFRESH_TOKEN)) + assertThatThrownBy(() -> authService.renew(Instancio.create(Long.class), REFRESH_TOKEN)) .isInstanceOf(InvalidAuthException.class); } From 8e5410428782d8f6f52f375f5c6a565eb7907e08 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 27/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/presentation/AdminController.java | 14 +++++----- .../service/CertificationService.java | 2 +- ...tionDto.java => PendingCertification.java} | 6 ++-- .../dto/PendingCertificationPageDto.java | 1 + .../ChattingMessageController.java | 4 +-- .../current/presentation/dto/ChatStomp.java | 4 +-- .../current/presentation/dto/ChatsHTTP.java | 4 +-- .../current/service/ChattingRoomService.java | 8 +++--- .../dto/{ChattingDto.java => Chatting.java} | 6 ++-- .../current/service/dto/ChattingListDto.java | 4 +-- .../dto/ChattingMessageHistoriesHTTP.java | 4 +-- .../service/ChattingRoomHistoryService.java | 9 +++--- ...ryDto.java => ChattingMessageHistory.java} | 9 +++--- .../dto/ChattingMessageHistoryListDto.java | 4 +-- .../inquiry/service/InquiryService.java | 6 ++-- .../inquiry/service/dto/InquirySearchDto.java | 4 +-- ...irySummaryDto.java => InquirySummary.java} | 6 ++-- .../server/report/service/ReportService.java | 28 ++++++++++--------- .../dto/{ReportDto.java => Report.java} | 6 ++-- .../report/service/dto/ReportListDto.java | 4 +-- .../presentation/AdminControllerTest.java | 14 +++++----- .../server/common/fixture/AdminFixture.java | 12 ++++---- .../common/fixture/CertificationFixture.java | 10 +++---- 23 files changed, 85 insertions(+), 84 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertificationDto.java => PendingCertification.java} (78%) rename src/main/java/coffeemeet/server/chatting/current/service/dto/{ChattingDto.java => Chatting.java} (83%) rename src/main/java/coffeemeet/server/chatting/history/service/dto/{ChattingMessageHistoryDto.java => ChattingMessageHistory.java} (70%) rename src/main/java/coffeemeet/server/inquiry/service/dto/{InquirySummaryDto.java => InquirySummary.java} (78%) rename src/main/java/coffeemeet/server/report/service/dto/{ReportDto.java => Report.java} (83%) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index fa72fc87..bee5dd2a 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -10,18 +10,18 @@ import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; import coffeemeet.server.inquiry.service.dto.InquirySearchDto; -import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; +import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; +import coffeemeet.server.report.service.dto.Report; import coffeemeet.server.report.service.dto.ReportDetailDto; -import coffeemeet.server.report.service.dto.ReportDto; import coffeemeet.server.report.service.dto.ReportListDto; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; @@ -127,7 +127,7 @@ public ResponseEntity dismissReport( } @GetMapping("/reports") - public ResponseEntity> findAllReports( + public ResponseEntity> findAllReports( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") Long lastReportId, @RequestParam(defaultValue = "10") int pageSize @@ -166,7 +166,7 @@ public ResponseEntity findReport( } @GetMapping("/inquiries") - public ResponseEntity> searchInquiries( + public ResponseEntity> searchInquiries( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") Long lastInquiryId, @RequestParam(defaultValue = "10") int pageSize) { @@ -203,7 +203,7 @@ public ResponseEntity checkInquiry( // TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요 @PerformanceMeasurement @GetMapping("/certifications/pending") - public ResponseEntity> getPendingCertifications( + public ResponseEntity> getPendingCertifications( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int size @@ -217,7 +217,7 @@ public ResponseEntity> getPendingCertif PendingCertificationPageDto uncertifiedUserRequests = certificationService.getUncertifiedUserRequests( pageable); - Page page = uncertifiedUserRequests.page(); + Page page = uncertifiedUserRequests.page(); return ResponseEntity.ok( AdminCustomPage.of(page.getContent(), page.hasNext()) ); diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 98d5b951..7d9ee6a6 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -15,7 +15,7 @@ import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java index 1ff1650a..7b59a245 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertificationDto( +public record PendingCertification( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertificationDto( String department ) { - public static PendingCertificationDto from(Certification certification) { - return new PendingCertificationDto( + public static PendingCertification from(Certification certification) { + return new PendingCertification( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 5e50906c..00062fab 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -12,4 +12,5 @@ public static PendingCertificationPageDto from( ) { return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); } + } diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java index eda15e1e..75437f91 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java @@ -2,7 +2,7 @@ import coffeemeet.server.chatting.current.presentation.dto.ChatStomp; import coffeemeet.server.chatting.current.service.ChattingMessageService; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.common.annotation.PerformanceMeasurement; import jakarta.validation.Valid; import java.time.LocalDateTime; @@ -42,7 +42,7 @@ public void onDisconnect(SessionDisconnectEvent event) { @MessageMapping("/chatting/messages") public void message(@Valid ChatStomp.Request request, SimpMessageHeaderAccessor accessor) { - ChattingDto response = chattingMessageService.chatting( + Chatting response = chattingMessageService.chatting( accessor.getSessionId(), request.roomId(), request.content() diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java index 9945b963..03db7e3a 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java @@ -2,7 +2,7 @@ import static lombok.AccessLevel.PRIVATE; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.chatting.current.service.dto.Chatting; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -31,7 +31,7 @@ public record Response( LocalDateTime createdAt ) { - public static ChatStomp.Response from(ChattingDto response) { + public static ChatStomp.Response from(Chatting response) { return new ChatStomp.Response( response.userId(), response.messageId(), diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java index c4a712b4..55da485b 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java @@ -2,7 +2,7 @@ import static lombok.AccessLevel.PRIVATE; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import java.util.List; import lombok.NoArgsConstructor; @@ -11,7 +11,7 @@ public final class ChatsHTTP { public record Response( - List chats, + List chats, boolean hasNext ) { diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java index 48c12520..ef2ce06a 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java @@ -6,7 +6,7 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; @@ -51,9 +51,9 @@ public ChattingListDto searchMessages(Long roomId, Long firstMessageId, int page firstMessageId, pageSize); boolean hasNext = chattingMessages.size() >= pageSize; - List chattingDtoList = chattingMessages.stream() - .map(message -> ChattingDto.of(message.getUser(), message)).toList(); - return ChattingListDto.of(chattingDtoList, hasNext); + List chattingList = chattingMessages.stream() + .map(message -> Chatting.of(message.getUser(), message)).toList(); + return ChattingListDto.of(chattingList, hasNext); } @Transactional diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/Chatting.java similarity index 83% rename from src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java rename to src/main/java/coffeemeet/server/chatting/current/service/dto/Chatting.java index 965a05a8..4590dbda 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/Chatting.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public record ChattingDto( +public record Chatting( Long userId, Long messageId, String nickname, @@ -15,8 +15,8 @@ public record ChattingDto( LocalDateTime createdAt ) { - public static ChattingDto of(User user, ChattingMessage chattingMessage) { - return new ChattingDto( + public static Chatting of(User user, ChattingMessage chattingMessage) { + return new Chatting( user.getId(), chattingMessage.getId(), user.getProfile().getNickname(), diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java index 15aa6ff1..932f4af7 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingListDto.java @@ -3,11 +3,11 @@ import java.util.List; public record ChattingListDto( - List contents, + List contents, boolean hasNext ) { - public static ChattingListDto of(List contents, boolean hasNext) { + public static ChattingListDto of(List contents, boolean hasNext) { return new ChattingListDto(contents, hasNext); } diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java index 43201573..c0c86314 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java @@ -2,7 +2,7 @@ import static lombok.AccessLevel.PRIVATE; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistory; import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import java.util.List; import lombok.NoArgsConstructor; @@ -11,7 +11,7 @@ public final class ChattingMessageHistoriesHTTP { public record Response( - List chatHistories, + List chatHistories, boolean hasNext) { public static Response from(ChattingMessageHistoryListDto chattingMessageHistoryListDto) { diff --git a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java index b784e6f7..82143a27 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java @@ -1,12 +1,11 @@ package coffeemeet.server.chatting.history.service; -import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryQuery; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryDto; +import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistory; import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; @@ -49,13 +48,13 @@ public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHis Long firstMessageId, int pageSize) { ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy( roomHistoryId); - List messageHistories = chattingMessageHistoryQuery.getMessageHistories( + List messageHistories = chattingMessageHistoryQuery.getMessageHistories( chattingRoomHistory, firstMessageId, pageSize); boolean hasNext = messageHistories.size() >= pageSize; - List historyDtoList = messageHistories + List historyDtoList = messageHistories .stream() - .map(chattingMessageHistory -> ChattingMessageHistoryDto.of( + .map(chattingMessageHistory -> ChattingMessageHistory.of( chattingMessageHistory.getUser(), chattingMessageHistory)) .toList(); return ChattingMessageHistoryListDto.of(historyDtoList, hasNext); diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java similarity index 70% rename from src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java rename to src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java index 35f75769..8bde6208 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java @@ -1,11 +1,10 @@ package coffeemeet.server.chatting.history.service.dto; -import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.user.domain.User; import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public record ChattingMessageHistoryDto( +public record ChattingMessageHistory( Long userId, Long messageId, String nickname, @@ -15,9 +14,9 @@ public record ChattingMessageHistoryDto( LocalDateTime createdAt ) { - public static ChattingMessageHistoryDto of(User user, - ChattingMessageHistory chattingMessageHistory) { - return new ChattingMessageHistoryDto( + public static ChattingMessageHistory of(User user, + coffeemeet.server.chatting.history.domain.ChattingMessageHistory chattingMessageHistory) { + return new ChattingMessageHistory( user.getId(), chattingMessageHistory.getId(), user.getProfile().getNickname(), diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java index 30eeacb9..95448b03 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java @@ -3,11 +3,11 @@ import java.util.List; public record ChattingMessageHistoryListDto( - List contents, + List contents, boolean hasNext ) { - public static ChattingMessageHistoryListDto of(List contents, + public static ChattingMessageHistoryListDto of(List contents, boolean hasNext) { return new ChattingMessageHistoryListDto(contents, hasNext); } diff --git a/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java b/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java index a28fc012..fbe8abec 100644 --- a/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java +++ b/src/main/java/coffeemeet/server/inquiry/service/InquiryService.java @@ -5,7 +5,7 @@ import coffeemeet.server.inquiry.implement.InquiryQuery; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; import coffeemeet.server.inquiry.service.dto.InquirySearchDto; -import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; +import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.user.domain.Profile; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; @@ -31,8 +31,8 @@ public void registerInquiry(Long inquirerId, String title, String content) { public InquirySearchDto searchInquiries(Long lastInquiryId, int pageSize) { List inquiries = inquiryQuery.getInquiriesBy(lastInquiryId, pageSize); Map userMap = getUserProfiles(inquiries); - List inquirySummaries = inquiries.stream() - .map(inquiry -> InquirySummaryDto.of(inquiry, userMap.get(inquiry.getInquirerId()))) + List inquirySummaries = inquiries.stream() + .map(inquiry -> InquirySummary.of(inquiry, userMap.get(inquiry.getInquirerId()))) .toList(); boolean hasNext = true; if (inquiries.size() < pageSize) { diff --git a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java index b03b833a..3676d553 100644 --- a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java +++ b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySearchDto.java @@ -3,10 +3,10 @@ import java.util.List; public record InquirySearchDto( - List contents, + List contents, boolean hasNext) { - public static InquirySearchDto of(List inquiries, boolean hasNext) { + public static InquirySearchDto of(List inquiries, boolean hasNext) { return new InquirySearchDto( inquiries, hasNext diff --git a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummary.java similarity index 78% rename from src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java rename to src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummary.java index 8e5c4652..093ea94a 100644 --- a/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummaryDto.java +++ b/src/main/java/coffeemeet/server/inquiry/service/dto/InquirySummary.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public record InquirySummaryDto( +public record InquirySummary( Long inquiryId, String inquirer, String title, @@ -13,8 +13,8 @@ public record InquirySummaryDto( LocalDateTime createdAt ) { - public static InquirySummaryDto of(Inquiry inquiry, Profile profile) { - return new InquirySummaryDto( + public static InquirySummary of(Inquiry inquiry, Profile profile) { + return new InquirySummary( inquiry.getId(), profile.getNickname(), inquiry.getTitle(), diff --git a/src/main/java/coffeemeet/server/report/service/ReportService.java b/src/main/java/coffeemeet/server/report/service/ReportService.java index 78d15e5f..83b466a4 100644 --- a/src/main/java/coffeemeet/server/report/service/ReportService.java +++ b/src/main/java/coffeemeet/server/report/service/ReportService.java @@ -6,12 +6,11 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.common.execption.NotFoundException; -import coffeemeet.server.report.domain.Report; import coffeemeet.server.report.implement.ReportCommand; import coffeemeet.server.report.implement.ReportQuery; import coffeemeet.server.report.service.dto.GroupReportDto; +import coffeemeet.server.report.service.dto.Report; import coffeemeet.server.report.service.dto.ReportDetailDto; -import coffeemeet.server.report.service.dto.ReportDto; import coffeemeet.server.report.service.dto.ReportListDto; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; @@ -43,7 +42,7 @@ public void reportUser(Long reporterId, Long chattingRoomId, Long targetId, Stri checkChattingRoomExists(reporterId, chattingRoomId); - Report report = Report.builder() + coffeemeet.server.report.domain.Report report = coffeemeet.server.report.domain.Report.builder() .reporterId(reporterId) .chattingRoomId(chattingRoomId) .targetedId(targetId) @@ -54,24 +53,25 @@ public void reportUser(Long reporterId, Long chattingRoomId, Long targetId, Stri } public ReportDetailDto findReportById(Long reportId) { - Report report = reportQuery.getReportById(reportId); + coffeemeet.server.report.domain.Report report = reportQuery.getReportById(reportId); User reporter = userQuery.getUserById(report.getReporterId()); User targetUser = userQuery.getUserById(report.getTargetedId()); return ReportDetailDto.of(report, reporter, targetUser); } public ReportListDto findAllReports(Long lastReportId, int pageSize) { - List reports = reportQuery.getAllReports(lastReportId, pageSize); + List reports = reportQuery.getAllReports(lastReportId, + pageSize); boolean hasNext = reports.size() >= pageSize; Map userMap = getUsers(reports); Map chattingRoomMap = getChattingRooms(reports); - List responses = reports.stream() + List responses = reports.stream() .map(report -> { User targetUser = userMap.get(report.getTargetedId()); ChattingRoom chattingRoom = chattingRoomMap.get(report.getChattingRoomId()); - return ReportDto.of(targetUser, chattingRoom); + return Report.of(targetUser, chattingRoom); }) .toList(); return ReportListDto.of(responses, hasNext); @@ -79,7 +79,8 @@ public ReportListDto findAllReports(Long lastReportId, int pageSize) { public List findReportByTargetIdAndChattingRoomId(Long targetId, Long chattingRoomId) { - List reports = reportQuery.getReportsByTargetIdAndChattingRoomId(targetId, + List reports = reportQuery.getReportsByTargetIdAndChattingRoomId( + targetId, chattingRoomId); return reports.stream() .map(this::mapToReportDto) @@ -104,25 +105,26 @@ private void checkChattingRoomExists(Long reporterId, Long chattingRoomId) { } } - private Map getChattingRooms(List allReports) { + private Map getChattingRooms( + List allReports) { Set chattingRoomIds = allReports.stream() - .map(Report::getChattingRoomId) + .map(coffeemeet.server.report.domain.Report::getChattingRoomId) .collect(Collectors.toSet()); Set chattingRooms = chattingRoomQuery.getChattingRoomsSetBy(chattingRoomIds); return chattingRooms.stream() .collect(Collectors.toMap(ChattingRoom::getId, Function.identity())); } - private Map getUsers(List allReports) { + private Map getUsers(List allReports) { Set targetUserIds = allReports.stream() - .map(Report::getTargetedId) + .map(coffeemeet.server.report.domain.Report::getTargetedId) .collect(Collectors.toSet()); Set users = userQuery.getUsersByIdSet(targetUserIds); return users.stream() .collect(Collectors.toMap(User::getId, Function.identity())); } - private GroupReportDto mapToReportDto(Report report) { + private GroupReportDto mapToReportDto(coffeemeet.server.report.domain.Report report) { User reporter = userQuery.getUserById(report.getReporterId()); return GroupReportDto.of(reporter.getProfile().getNickname(), reporter.getId(), report.getCreatedAt()); diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportDto.java b/src/main/java/coffeemeet/server/report/service/dto/Report.java similarity index 83% rename from src/main/java/coffeemeet/server/report/service/dto/ReportDto.java rename to src/main/java/coffeemeet/server/report/service/dto/Report.java index 5ab7a6f5..889d5072 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportDto.java +++ b/src/main/java/coffeemeet/server/report/service/dto/Report.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public record ReportDto( +public record Report( String targetedNickname, String chattingRoomName, Long targetedId, @@ -14,8 +14,8 @@ public record ReportDto( LocalDateTime createdAt ) { - public static ReportDto of(User targeted, ChattingRoom chattingRoom) { - return new ReportDto( + public static Report of(User targeted, ChattingRoom chattingRoom) { + return new Report( targeted.getProfile().getNickname(), chattingRoom.getName(), targeted.getId(), diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java b/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java index f22c6654..e217c368 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java @@ -3,11 +3,11 @@ import java.util.List; public record ReportListDto( - List contents, + List contents, boolean hasNext ) { - public static ReportListDto of(List contents, boolean hasNext) { + public static ReportListDto of(List contents, boolean hasNext) { return new ReportListDto(contents, hasNext); } diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 88a8c081..297968a7 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -34,7 +34,7 @@ import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; @@ -44,11 +44,11 @@ import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; import coffeemeet.server.inquiry.service.dto.InquirySearchDto; -import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; +import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; +import coffeemeet.server.report.service.dto.Report; import coffeemeet.server.report.service.dto.ReportDetailDto; -import coffeemeet.server.report.service.dto.ReportDto; import coffeemeet.server.report.service.dto.ReportListDto; import com.epages.restdocs.apispec.Schema; import java.util.List; @@ -237,7 +237,7 @@ void findAllReportsTest() throws Exception { Long lastReportId = 0L; int pageSize = 10; ReportListDto reportListDto = ReportFixture.reportListDto(); - AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), + AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), reportListDto.hasNext()); given(reportService.findAllReports(lastReportId, pageSize)).willReturn(reportListDto); @@ -369,7 +369,7 @@ void searchInquiriesTest() throws Exception { int pageSize = 10; InquirySearchDto inquirySearchDto = InquiryFixture.inquirySearchResponse(); - AdminCustomSlice adminCustomSlice = AdminFixture.adminCustomPageByInquiry( + AdminCustomSlice adminCustomSlice = AdminFixture.adminCustomPageByInquiry( inquirySearchDto.contents(), inquirySearchDto.hasNext()); given(inquiryService.searchInquiries(lastInquiryId, pageSize)).willReturn( inquirySearchDto); @@ -456,8 +456,8 @@ void getPendingCertificationsTest() throws Exception { Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); - Page page = pendingCertificationPageDto.page(); - AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( + Page page = pendingCertificationPageDto.page(); + AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( page.getContent(), page.hasNext()); given(certificationService.getUncertifiedUserRequests(any())).willReturn( diff --git a/src/test/java/coffeemeet/server/common/fixture/AdminFixture.java b/src/test/java/coffeemeet/server/common/fixture/AdminFixture.java index bd31bc69..32fce8f8 100644 --- a/src/test/java/coffeemeet/server/common/fixture/AdminFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/AdminFixture.java @@ -6,7 +6,7 @@ import coffeemeet.server.admin.presentation.dto.AdminLoginHTTP; import coffeemeet.server.admin.presentation.dto.ReportDeletionHTTP; import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; -import coffeemeet.server.inquiry.service.dto.InquirySummaryDto; +import coffeemeet.server.inquiry.service.dto.InquirySummary; import java.util.List; import org.instancio.Instancio; @@ -26,12 +26,12 @@ public static ReportDeletionHTTP.Request reportRejectionHTTPRequest() { } @SuppressWarnings("unchecked") - public static AdminCustomSlice adminCustomPageByInquiry( - List contents, boolean hasNext) { + public static AdminCustomSlice adminCustomPageByInquiry( + List contents, boolean hasNext) { return Instancio.of(AdminCustomSlice.class) - .withTypeParameters(InquirySummaryDto.class) - .set(field(AdminCustomSlice::contents), contents) - .set(field(AdminCustomSlice::hasNext), hasNext) + .withTypeParameters(InquirySummary.class) + .set(field(AdminCustomSlice::contents), contents) + .set(field(AdminCustomSlice::hasNext), hasNext) .create(); } diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index cac12b53..e2fd3367 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -9,7 +9,7 @@ import coffeemeet.server.certification.domain.VerificationInfo; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -141,11 +141,11 @@ public static PendingCertificationPageDto pendingCertificationPageDto(int size) return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); } - private static List pendingCertifications(int size) { - return Instancio.ofList(PendingCertificationDto.class).size(size) - .generate(field(PendingCertificationDto::businessCardUrl), + private static List pendingCertifications(int size) { + return Instancio.ofList(PendingCertification.class).size(size) + .generate(field(PendingCertification::businessCardUrl), gen -> gen.net().url().asString()) - .generate(field(PendingCertificationDto::companyEmail), gen -> gen.net().email()).create(); + .generate(field(PendingCertification::companyEmail), gen -> gen.net().email()).create(); } } From fa7a64392c554b4797a17e016084db4747aef06f Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:28:03 +0900 Subject: [PATCH 28/74] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../current/presentation/ChattingMessageController.java | 2 +- .../concurrency/ChattingMessageServiceConcurrencyTest.java | 2 +- .../chatting/current/service/ChattingMessageServiceTest.java | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java index 75437f91..372633ba 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java @@ -42,7 +42,7 @@ public void onDisconnect(SessionDisconnectEvent event) { @MessageMapping("/chatting/messages") public void message(@Valid ChatStomp.Request request, SimpMessageHeaderAccessor accessor) { - Chatting response = chattingMessageService.chatting( + Chatting response = chattingMessageService.chat( accessor.getSessionId(), request.roomId(), request.content() diff --git a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java index 54c1120d..51a2e7a8 100644 --- a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java +++ b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java @@ -74,7 +74,7 @@ void chattingConcurrencyTest() throws InterruptedException { for (int i = 0; i < userSize; i++) { executorService.submit(() -> { try { - chattingMessageService.chatting(sessionId, room.getId(), "test"); + chattingMessageService.chat(sessionId, room.getId(), "test"); } catch (Exception e) { e.printStackTrace(); } finally { diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index 20b0aae2..6490cab5 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -4,6 +4,7 @@ import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; import static coffeemeet.server.common.fixture.UserFixture.fourUsers; import static coffeemeet.server.common.fixture.UserFixture.user; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.BDDMockito.given; @@ -18,7 +19,7 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserCommand; @@ -80,7 +81,7 @@ void chattingTest() { chattingMessage); // when - ChattingDto response = chattingMessageService.chatting(chattingSession.sessionId(), + Chatting response = chattingMessageService.chat(chattingSession.sessionId(), chattingRoom.getId(), content); // then From fdee847da2b2d6f4eca50c7c6d69d0786a8a468a Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:35:32 +0900 Subject: [PATCH 29/74] refactor: ChattingMessageHistory -> ChattingHistory --- .../presentation/dto/ChattingMessageHistoriesHTTP.java | 4 ++-- .../history/service/ChattingRoomHistoryService.java | 9 +++++---- ...{ChattingMessageHistory.java => ChattingHistory.java} | 6 +++--- .../service/dto/ChattingMessageHistoryListDto.java | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) rename src/main/java/coffeemeet/server/chatting/history/service/dto/{ChattingMessageHistory.java => ChattingHistory.java} (84%) diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java index c0c86314..a94fc10e 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java @@ -2,7 +2,7 @@ import static lombok.AccessLevel.PRIVATE; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistory; +import coffeemeet.server.chatting.history.service.dto.ChattingHistory; import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import java.util.List; import lombok.NoArgsConstructor; @@ -11,7 +11,7 @@ public final class ChattingMessageHistoriesHTTP { public record Response( - List chatHistories, + List chatHistories, boolean hasNext) { public static Response from(ChattingMessageHistoryListDto chattingMessageHistoryListDto) { diff --git a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java index 82143a27..9e52eccf 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java @@ -1,11 +1,12 @@ package coffeemeet.server.chatting.history.service; +import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryQuery; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistory; +import coffeemeet.server.chatting.history.service.dto.ChattingHistory; import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; @@ -48,13 +49,13 @@ public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHis Long firstMessageId, int pageSize) { ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy( roomHistoryId); - List messageHistories = chattingMessageHistoryQuery.getMessageHistories( + List messageHistories = chattingMessageHistoryQuery.getMessageHistories( chattingRoomHistory, firstMessageId, pageSize); boolean hasNext = messageHistories.size() >= pageSize; - List historyDtoList = messageHistories + List historyDtoList = messageHistories .stream() - .map(chattingMessageHistory -> ChattingMessageHistory.of( + .map(chattingMessageHistory -> ChattingHistory.of( chattingMessageHistory.getUser(), chattingMessageHistory)) .toList(); return ChattingMessageHistoryListDto.of(historyDtoList, hasNext); diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java similarity index 84% rename from src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java rename to src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java index 8bde6208..7157cf6c 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public record ChattingMessageHistory( +public record ChattingHistory( Long userId, Long messageId, String nickname, @@ -14,9 +14,9 @@ public record ChattingMessageHistory( LocalDateTime createdAt ) { - public static ChattingMessageHistory of(User user, + public static ChattingHistory of(User user, coffeemeet.server.chatting.history.domain.ChattingMessageHistory chattingMessageHistory) { - return new ChattingMessageHistory( + return new ChattingHistory( user.getId(), chattingMessageHistory.getId(), user.getProfile().getNickname(), diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java index 95448b03..2270a8da 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java @@ -3,11 +3,11 @@ import java.util.List; public record ChattingMessageHistoryListDto( - List contents, + List contents, boolean hasNext ) { - public static ChattingMessageHistoryListDto of(List contents, + public static ChattingMessageHistoryListDto of(List contents, boolean hasNext) { return new ChattingMessageHistoryListDto(contents, hasNext); } From b81545cae84f724e05433c944029c642b15c5d56 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:38:04 +0900 Subject: [PATCH 30/74] refactor: ChatRoom -> ChattingRoom --- .../current/presentation/ChattingRoomController.java | 6 +++--- .../current/presentation/dto/ChatRoomStatusHTTP.java | 6 +++--- .../chatting/current/service/ChattingRoomService.java | 6 +++--- .../current/service/dto/ChatRoomStatusDto.java | 9 --------- .../current/service/dto/ChattingRoomStatusDto.java | 9 +++++++++ .../presentation/ChattingRoomControllerTest.java | 8 ++++---- .../current/service/ChattingRoomServiceTest.java | 10 +++++----- .../server/common/fixture/ChattingFixture.java | 10 +++++----- 8 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChatRoomStatusDto.java create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingRoomStatusDto.java diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java index 43b955a4..dc769491 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java @@ -3,7 +3,7 @@ import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; import coffeemeet.server.chatting.current.service.ChattingRoomService; -import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; @@ -39,8 +39,8 @@ public ResponseEntity exitChattingRoom(@PathVariable Long roomId) { @GetMapping("/{roomId}/exist") public ResponseEntity checkChattingRoom(@PathVariable Long roomId) { - ChatRoomStatusDto chatRoomStatusDto = chattingRoomService.checkChattingRoomStatus(roomId); - return ResponseEntity.ok(ChatRoomStatusHTTP.Response.from(chatRoomStatusDto)); + ChattingRoomStatusDto chattingRoomStatusDto = chattingRoomService.checkChattingRoomStatus(roomId); + return ResponseEntity.ok(ChatRoomStatusHTTP.Response.from(chattingRoomStatusDto)); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java index 83ab9b08..14b5c458 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java @@ -2,7 +2,7 @@ import static lombok.AccessLevel.PRIVATE; -import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) @@ -12,8 +12,8 @@ public record Response( boolean isExisted ) { - public static ChatRoomStatusHTTP.Response from(ChatRoomStatusDto chatRoomStatusDto) { - return new Response(chatRoomStatusDto.isExisted()); + public static ChatRoomStatusHTTP.Response from(ChattingRoomStatusDto chattingRoomStatusDto) { + return new Response(chattingRoomStatusDto.isExisted()); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java index ef2ce06a..8fe984ed 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java @@ -5,7 +5,7 @@ import coffeemeet.server.chatting.current.implement.ChattingMessageQuery; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; -import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; @@ -89,7 +89,7 @@ private void updateUserStatusToIdle(List users) { users.forEach(User::setIdleStatus); } - public ChatRoomStatusDto checkChattingRoomStatus(Long roomId) { - return ChatRoomStatusDto.from(chattingRoomQuery.existsBy(roomId)); + public ChattingRoomStatusDto checkChattingRoomStatus(Long roomId) { + return ChattingRoomStatusDto.from(chattingRoomQuery.existsBy(roomId)); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChatRoomStatusDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChatRoomStatusDto.java deleted file mode 100644 index bd0d307e..00000000 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChatRoomStatusDto.java +++ /dev/null @@ -1,9 +0,0 @@ -package coffeemeet.server.chatting.current.service.dto; - -public record ChatRoomStatusDto(boolean isExisted) { - - public static ChatRoomStatusDto from(boolean isExisted) { - return new ChatRoomStatusDto(isExisted); - } - -} diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingRoomStatusDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingRoomStatusDto.java new file mode 100644 index 00000000..c24d6608 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingRoomStatusDto.java @@ -0,0 +1,9 @@ +package coffeemeet.server.chatting.current.service.dto; + +public record ChattingRoomStatusDto(boolean isExisted) { + + public static ChattingRoomStatusDto from(boolean isExisted) { + return new ChattingRoomStatusDto(isExisted); + } + +} diff --git a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java index ae9f158a..095307e8 100644 --- a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java @@ -21,7 +21,7 @@ import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; import coffeemeet.server.chatting.current.service.ChattingRoomService; -import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.ChattingFixture; @@ -117,12 +117,12 @@ void checkChattingRoomTest() throws Exception { // given Long userId = 1L; Long roomId = 1L; - ChatRoomStatusDto chatRoomStatusDto = ChattingFixture.chatRoomStatusDto(); + ChattingRoomStatusDto chattingRoomStatusDto = ChattingFixture.chatRoomStatusDto(); ChatRoomStatusHTTP.Response response = ChattingFixture.chatRoomStatusHTTPResponse( - chatRoomStatusDto); + chattingRoomStatusDto); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); - given(chattingRoomService.checkChattingRoomStatus(roomId)).willReturn(chatRoomStatusDto); + given(chattingRoomService.checkChattingRoomStatus(roomId)).willReturn(chattingRoomStatusDto); // when, then mockMvc.perform(get("/api/v1/chatting/rooms/{roomId}/exist", roomId) diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java index 275f291d..e12ce7ef 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java @@ -13,7 +13,7 @@ import coffeemeet.server.chatting.current.implement.ChattingMessageQuery; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; -import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryCommand; @@ -133,15 +133,15 @@ void deleteChattingRoomTest() { void checkChattingRoomStatusTest() { // given Long roomId = 1L; - ChatRoomStatusDto chatRoomStatusDto = ChattingFixture.chatRoomStatusDto(); + ChattingRoomStatusDto chattingRoomStatusDto = ChattingFixture.chatRoomStatusDto(); - given(chattingRoomQuery.existsBy(any())).willReturn(chatRoomStatusDto.isExisted()); + given(chattingRoomQuery.existsBy(any())).willReturn(chattingRoomStatusDto.isExisted()); // when - ChatRoomStatusDto response = chattingRoomService.checkChattingRoomStatus(roomId); + ChattingRoomStatusDto response = chattingRoomService.checkChattingRoomStatus(roomId); // then - assertThat(response).isEqualTo(chatRoomStatusDto); + assertThat(response).isEqualTo(chattingRoomStatusDto); } } diff --git a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java index 1e89208f..9c9b410b 100644 --- a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java @@ -7,7 +7,7 @@ import coffeemeet.server.chatting.current.domain.ChattingSession; import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; -import coffeemeet.server.chatting.current.service.dto.ChatRoomStatusDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; @@ -115,14 +115,14 @@ public static ChattingSession chattingSession() { return Instancio.create(ChattingSession.class); } - public static ChatRoomStatusDto chatRoomStatusDto() { - return Instancio.of(ChatRoomStatusDto.class) + public static ChattingRoomStatusDto chatRoomStatusDto() { + return Instancio.of(ChattingRoomStatusDto.class) .create(); } public static ChatRoomStatusHTTP.Response chatRoomStatusHTTPResponse( - ChatRoomStatusDto chatRoomStatusDto) { - return ChatRoomStatusHTTP.Response.from(chatRoomStatusDto); + ChattingRoomStatusDto chattingRoomStatusDto) { + return ChatRoomStatusHTTP.Response.from(chattingRoomStatusDto); } public static ChattingMessageHistoryListDto chattingMessageHistoryListDto() { From 95c188691c7c56ff07c36e76b6df204b9198811b Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:41:48 +0900 Subject: [PATCH 31/74] refactor: Chat -> Chatting --- .../ChattingMessageController.java | 6 +++--- .../presentation/ChattingRoomController.java | 18 ++++++++++-------- ...ChatsHTTP.java => ChattingCustomSlice.java} | 2 +- ...usHTTP.java => ChattingRoomStatusHTTP.java} | 5 +++-- .../dto/{ChatStomp.java => ChattingStomp.java} | 6 +++--- .../current/service/ChattingRoomService.java | 2 +- .../ChattingRoomControllerTest.java | 10 +++++----- .../service/ChattingRoomServiceTest.java | 2 +- .../server/common/fixture/ChattingFixture.java | 18 +++++++++--------- 9 files changed, 36 insertions(+), 33 deletions(-) rename src/main/java/coffeemeet/server/chatting/current/presentation/dto/{ChatsHTTP.java => ChattingCustomSlice.java} (93%) rename src/main/java/coffeemeet/server/chatting/current/presentation/dto/{ChatRoomStatusHTTP.java => ChattingRoomStatusHTTP.java} (71%) rename src/main/java/coffeemeet/server/chatting/current/presentation/dto/{ChatStomp.java => ChattingStomp.java} (87%) diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java index 372633ba..7e75f11b 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.current.presentation; -import coffeemeet.server.chatting.current.presentation.dto.ChatStomp; +import coffeemeet.server.chatting.current.presentation.dto.ChattingStomp; import coffeemeet.server.chatting.current.service.ChattingMessageService; import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.common.annotation.PerformanceMeasurement; @@ -41,14 +41,14 @@ public void onDisconnect(SessionDisconnectEvent event) { } @MessageMapping("/chatting/messages") - public void message(@Valid ChatStomp.Request request, SimpMessageHeaderAccessor accessor) { + public void message(@Valid ChattingStomp.Request request, SimpMessageHeaderAccessor accessor) { Chatting response = chattingMessageService.chat( accessor.getSessionId(), request.roomId(), request.content() ); simpMessageSendingOperations.convertAndSend("/sub/chatting/rooms/" + request.roomId(), - ChatStomp.Response.from(response)); + ChattingStomp.Response.from(response)); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java index dc769491..970629e3 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingRoomController.java @@ -1,10 +1,10 @@ package coffeemeet.server.chatting.current.presentation; -import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; -import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; +import coffeemeet.server.chatting.current.presentation.dto.ChattingCustomSlice; +import coffeemeet.server.chatting.current.presentation.dto.ChattingRoomStatusHTTP; import coffeemeet.server.chatting.current.service.ChattingRoomService; -import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -22,13 +22,13 @@ public class ChattingRoomController { private final ChattingRoomService chattingRoomService; @GetMapping("/{roomId}") - public ResponseEntity viewChattingRoomMessages( + public ResponseEntity viewChattingRoomMessages( @PathVariable Long roomId, @RequestParam(defaultValue = "0") Long firstMessageId, @RequestParam(defaultValue = "50") int pageSize) { ChattingListDto responses = chattingRoomService.searchMessages(roomId, firstMessageId, pageSize); - return ResponseEntity.ok(ChatsHTTP.Response.from(responses)); + return ResponseEntity.ok(ChattingCustomSlice.Response.from(responses)); } @DeleteMapping("/{roomId}") @@ -38,9 +38,11 @@ public ResponseEntity exitChattingRoom(@PathVariable Long roomId) { } @GetMapping("/{roomId}/exist") - public ResponseEntity checkChattingRoom(@PathVariable Long roomId) { - ChattingRoomStatusDto chattingRoomStatusDto = chattingRoomService.checkChattingRoomStatus(roomId); - return ResponseEntity.ok(ChatRoomStatusHTTP.Response.from(chattingRoomStatusDto)); + public ResponseEntity checkChattingRoom( + @PathVariable Long roomId) { + ChattingRoomStatusDto chattingRoomStatusDto = chattingRoomService.checkChattingRoomStatus( + roomId); + return ResponseEntity.ok(ChattingRoomStatusHTTP.Response.from(chattingRoomStatusDto)); } } diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingCustomSlice.java similarity index 93% rename from src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java rename to src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingCustomSlice.java index 55da485b..85362191 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatsHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingCustomSlice.java @@ -8,7 +8,7 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) -public final class ChatsHTTP { +public final class ChattingCustomSlice { public record Response( List chats, diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingRoomStatusHTTP.java similarity index 71% rename from src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java rename to src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingRoomStatusHTTP.java index 14b5c458..c565b71b 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatRoomStatusHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingRoomStatusHTTP.java @@ -6,13 +6,14 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) -public final class ChatRoomStatusHTTP { +public final class ChattingRoomStatusHTTP { public record Response( boolean isExisted ) { - public static ChatRoomStatusHTTP.Response from(ChattingRoomStatusDto chattingRoomStatusDto) { + public static ChattingRoomStatusHTTP.Response from( + ChattingRoomStatusDto chattingRoomStatusDto) { return new Response(chattingRoomStatusDto.isExisted()); } diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java similarity index 87% rename from src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java rename to src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java index 03db7e3a..2a998abf 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChatStomp.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java @@ -10,7 +10,7 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) -public final class ChatStomp { +public final class ChattingStomp { public record Request( @NotNull @@ -31,8 +31,8 @@ public record Response( LocalDateTime createdAt ) { - public static ChatStomp.Response from(Chatting response) { - return new ChatStomp.Response( + public static ChattingStomp.Response from(Chatting response) { + return new ChattingStomp.Response( response.userId(), response.messageId(), response.nickname(), diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java index 8fe984ed..294ce091 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingRoomService.java @@ -5,9 +5,9 @@ import coffeemeet.server.chatting.current.implement.ChattingMessageQuery; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; -import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; diff --git a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java index 095307e8..dcd837b2 100644 --- a/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/presentation/ChattingRoomControllerTest.java @@ -18,11 +18,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; -import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; +import coffeemeet.server.chatting.current.presentation.dto.ChattingCustomSlice; +import coffeemeet.server.chatting.current.presentation.dto.ChattingRoomStatusHTTP; import coffeemeet.server.chatting.current.service.ChattingRoomService; -import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.ChattingFixture; import com.epages.restdocs.apispec.Schema; @@ -47,7 +47,7 @@ void viewChattingRoomMessagesTest() throws Exception { Long firstMessageId = 51L; int pageSize = 50; ChattingListDto responses = ChattingFixture.chattingListDto(); - ChatsHTTP.Response chatsHTTPResponse = ChattingFixture.chatsHTTPResponse(responses); + ChattingCustomSlice.Response chatsHTTPResponse = ChattingFixture.chatsHTTPResponse(responses); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); given(chattingRoomService.searchMessages(roomId, firstMessageId, pageSize)).willReturn( @@ -118,7 +118,7 @@ void checkChattingRoomTest() throws Exception { Long userId = 1L; Long roomId = 1L; ChattingRoomStatusDto chattingRoomStatusDto = ChattingFixture.chatRoomStatusDto(); - ChatRoomStatusHTTP.Response response = ChattingFixture.chatRoomStatusHTTPResponse( + ChattingRoomStatusHTTP.Response response = ChattingFixture.chatRoomStatusHTTPResponse( chattingRoomStatusDto); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java index e12ce7ef..64898bd0 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingRoomServiceTest.java @@ -13,8 +13,8 @@ import coffeemeet.server.chatting.current.implement.ChattingMessageQuery; import coffeemeet.server.chatting.current.implement.ChattingRoomCommand; import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; -import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryCommand; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryCommand; diff --git a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java index 9c9b410b..e75ffb09 100644 --- a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java @@ -5,10 +5,10 @@ import coffeemeet.server.chatting.current.domain.ChattingMessage; import coffeemeet.server.chatting.current.domain.ChattingRoom; import coffeemeet.server.chatting.current.domain.ChattingSession; -import coffeemeet.server.chatting.current.presentation.dto.ChatRoomStatusHTTP; -import coffeemeet.server.chatting.current.presentation.dto.ChatsHTTP; -import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; +import coffeemeet.server.chatting.current.presentation.dto.ChattingCustomSlice; +import coffeemeet.server.chatting.current.presentation.dto.ChattingRoomStatusHTTP; import coffeemeet.server.chatting.current.service.dto.ChattingListDto; +import coffeemeet.server.chatting.current.service.dto.ChattingRoomStatusDto; import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; @@ -58,10 +58,10 @@ public static List chattingRoomHistoryDtoResponses(int s .create(); } - public static ChatsHTTP.Response chatsHTTPResponse(ChattingListDto chats) { - return Instancio.of(ChatsHTTP.Response.class) - .set(field(ChatsHTTP.Response::chats), chats.contents()) - .set(field(ChatsHTTP.Response::hasNext), chats.hasNext()) + public static ChattingCustomSlice.Response chatsHTTPResponse(ChattingListDto chats) { + return Instancio.of(ChattingCustomSlice.Response.class) + .set(field(ChattingCustomSlice.Response::chats), chats.contents()) + .set(field(ChattingCustomSlice.Response::hasNext), chats.hasNext()) .create(); } @@ -120,9 +120,9 @@ public static ChattingRoomStatusDto chatRoomStatusDto() { .create(); } - public static ChatRoomStatusHTTP.Response chatRoomStatusHTTPResponse( + public static ChattingRoomStatusHTTP.Response chatRoomStatusHTTPResponse( ChattingRoomStatusDto chattingRoomStatusDto) { - return ChatRoomStatusHTTP.Response.from(chattingRoomStatusDto); + return ChattingRoomStatusHTTP.Response.from(chattingRoomStatusDto); } public static ChattingMessageHistoryListDto chattingMessageHistoryListDto() { From ebe545c7e2f5382b9dfe0361ca167e87d57434b5 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:47:16 +0900 Subject: [PATCH 32/74] =?UTF-8?q?refactor:=20ChattingHistoryCustomSlice,?= =?UTF-8?q?=20ChattingHistoryListDto=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChattingRoomHistoryController.java | 10 ++++----- ...P.java => ChattingHistoryCustomSlice.java} | 10 ++++----- .../service/ChattingRoomHistoryService.java | 6 ++--- .../service/dto/ChattingHistoryListDto.java | 15 +++++++++++++ .../dto/ChattingMessageHistoryListDto.java | 15 ------------- .../ChattingRoomHistoryControllerTest.java | 10 ++++----- .../ChattingRoomHistoryServiceTest.java | 4 ++-- .../common/fixture/ChattingFixture.java | 22 +++++++++---------- 8 files changed, 46 insertions(+), 46 deletions(-) rename src/main/java/coffeemeet/server/chatting/history/presentation/dto/{ChattingMessageHistoriesHTTP.java => ChattingHistoryCustomSlice.java} (52%) create mode 100644 src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java delete mode 100644 src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java b/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java index 6f7f6ec8..96a48b5f 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java @@ -1,9 +1,9 @@ package coffeemeet.server.chatting.history.presentation; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; +import coffeemeet.server.chatting.history.presentation.dto.ChattingHistoryCustomSlice; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; import coffeemeet.server.chatting.history.service.ChattingRoomHistoryService; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.domain.AuthInfo; @@ -33,14 +33,14 @@ public ResponseEntity viewChattingRoomHistor } @GetMapping("/{roomHistoryId}") - public ResponseEntity viewChattingRoomMessageHistories( + public ResponseEntity viewChattingRoomMessageHistories( @PathVariable Long roomHistoryId, @RequestParam(defaultValue = "0") Long firstMessageId, @RequestParam(defaultValue = "50") int pageSize) { - ChattingMessageHistoryListDto chattingMessageHistoryListDto = chattingRoomHistoryService.searchChattingMessageHistories( + ChattingHistoryListDto chattingHistoryListDto = chattingRoomHistoryService.searchChattingMessageHistories( roomHistoryId, firstMessageId, pageSize); return ResponseEntity.ok( - ChattingMessageHistoriesHTTP.Response.from(chattingMessageHistoryListDto)); + ChattingHistoryCustomSlice.Response.from(chattingHistoryListDto)); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingHistoryCustomSlice.java similarity index 52% rename from src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java rename to src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingHistoryCustomSlice.java index a94fc10e..2907588d 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingHistoryCustomSlice.java @@ -3,20 +3,20 @@ import static lombok.AccessLevel.PRIVATE; import coffeemeet.server.chatting.history.service.dto.ChattingHistory; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import java.util.List; import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) -public final class ChattingMessageHistoriesHTTP { +public final class ChattingHistoryCustomSlice { public record Response( List chatHistories, boolean hasNext) { - public static Response from(ChattingMessageHistoryListDto chattingMessageHistoryListDto) { - return new Response(chattingMessageHistoryListDto.contents(), - chattingMessageHistoryListDto.hasNext()); + public static Response from(ChattingHistoryListDto chattingHistoryListDto) { + return new Response(chattingHistoryListDto.contents(), + chattingHistoryListDto.hasNext()); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java index 9e52eccf..70793a48 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java @@ -7,7 +7,7 @@ import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.chatting.history.service.dto.ChattingHistory; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; @@ -45,7 +45,7 @@ public List searchChattingRoomHistories(Long userId) { } // TODO: 11/20/23 캐쉬 로직 적용 - public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHistoryId, + public ChattingHistoryListDto searchChattingMessageHistories(Long roomHistoryId, Long firstMessageId, int pageSize) { ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy( roomHistoryId); @@ -58,7 +58,7 @@ public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHis .map(chattingMessageHistory -> ChattingHistory.of( chattingMessageHistory.getUser(), chattingMessageHistory)) .toList(); - return ChattingMessageHistoryListDto.of(historyDtoList, hasNext); + return ChattingHistoryListDto.of(historyDtoList, hasNext); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java new file mode 100644 index 00000000..c4ae6751 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java @@ -0,0 +1,15 @@ +package coffeemeet.server.chatting.history.service.dto; + +import java.util.List; + +public record ChattingHistoryListDto( + List contents, + boolean hasNext +) { + + public static ChattingHistoryListDto of(List contents, + boolean hasNext) { + return new ChattingHistoryListDto(contents, hasNext); + } + +} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java deleted file mode 100644 index 2270a8da..00000000 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java +++ /dev/null @@ -1,15 +0,0 @@ -package coffeemeet.server.chatting.history.service.dto; - -import java.util.List; - -public record ChattingMessageHistoryListDto( - List contents, - boolean hasNext -) { - - public static ChattingMessageHistoryListDto of(List contents, - boolean hasNext) { - return new ChattingMessageHistoryListDto(contents, hasNext); - } - -} diff --git a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java index 9aa0278a..ad455961 100644 --- a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java @@ -17,10 +17,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP.Response; +import coffeemeet.server.chatting.history.presentation.dto.ChattingHistoryCustomSlice.Response; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; import coffeemeet.server.chatting.history.service.ChattingRoomHistoryService; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AuthFixture; @@ -95,14 +95,14 @@ void viewChattingRoomMessageHistoriesTest() throws Exception { Long firstMessageId = 51L; int pageSize = 50; - ChattingMessageHistoryListDto chattingMessageHistoryListDto = ChattingFixture.chattingMessageHistoryListDto(); + ChattingHistoryListDto chattingHistoryListDto = ChattingFixture.chattingMessageHistoryListDto(); Response response = ChattingFixture.chattingMessageHistoriesHTTPResponse( - chattingMessageHistoryListDto); + chattingHistoryListDto); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); given(chattingRoomHistoryService.searchChattingMessageHistories(roomHistoryId, firstMessageId, pageSize)).willReturn( - chattingMessageHistoryListDto); + chattingHistoryListDto); // when, then mockMvc.perform(get("/api/v1/chatting/room/histories/{roomHistoryId}", roomHistoryId) diff --git a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java index a3a376d8..268d7219 100644 --- a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java @@ -8,7 +8,7 @@ import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryQuery; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.common.fixture.ChattingFixture; import coffeemeet.server.user.implement.UserQuery; import java.util.List; @@ -67,7 +67,7 @@ void searchChattingMessageHistoriesTest(Long firstMessageId, int pageSize) { chattingMessageHistories); // when - ChattingMessageHistoryListDto responses = chattingRoomHistoryService.searchChattingMessageHistories( + ChattingHistoryListDto responses = chattingRoomHistoryService.searchChattingMessageHistories( roomHistoryId, firstMessageId, pageSize); diff --git a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java index e75ffb09..0fbf980e 100644 --- a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java @@ -12,9 +12,9 @@ import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; +import coffeemeet.server.chatting.history.presentation.dto.ChattingHistoryCustomSlice; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -125,18 +125,18 @@ public static ChattingRoomStatusHTTP.Response chatRoomStatusHTTPResponse( return ChattingRoomStatusHTTP.Response.from(chattingRoomStatusDto); } - public static ChattingMessageHistoryListDto chattingMessageHistoryListDto() { - return Instancio.of(ChattingMessageHistoryListDto.class) + public static ChattingHistoryListDto chattingMessageHistoryListDto() { + return Instancio.of(ChattingHistoryListDto.class) .create(); } - public static ChattingMessageHistoriesHTTP.Response chattingMessageHistoriesHTTPResponse( - ChattingMessageHistoryListDto chattingMessageHistoryListDto) { - return Instancio.of(ChattingMessageHistoriesHTTP.Response.class) - .set(field(ChattingMessageHistoriesHTTP.Response::chatHistories), - chattingMessageHistoryListDto.contents()) - .set(field(ChattingMessageHistoriesHTTP.Response::hasNext), - chattingMessageHistoryListDto.hasNext()) + public static ChattingHistoryCustomSlice.Response chattingMessageHistoriesHTTPResponse( + ChattingHistoryListDto chattingHistoryListDto) { + return Instancio.of(ChattingHistoryCustomSlice.Response.class) + .set(field(ChattingHistoryCustomSlice.Response::chatHistories), + chattingHistoryListDto.contents()) + .set(field(ChattingHistoryCustomSlice.Response::hasNext), + chattingHistoryListDto.hasNext()) .create(); } From 63d38d06bae986ab4965b6efd021ed275da38c9b Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:50:04 +0900 Subject: [PATCH 33/74] =?UTF-8?q?refactor:=20ReportSummary=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/admin/presentation/AdminController.java | 4 ++-- .../coffeemeet/server/report/service/ReportService.java | 6 +++--- .../coffeemeet/server/report/service/dto/ReportListDto.java | 4 ++-- .../report/service/dto/{Report.java => ReportSummary.java} | 6 +++--- .../server/admin/presentation/AdminControllerTest.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) rename src/main/java/coffeemeet/server/report/service/dto/{Report.java => ReportSummary.java} (81%) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index bee5dd2a..994f4ad7 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -20,7 +20,7 @@ import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; -import coffeemeet.server.report.service.dto.Report; +import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; import jakarta.servlet.http.HttpServletRequest; @@ -127,7 +127,7 @@ public ResponseEntity dismissReport( } @GetMapping("/reports") - public ResponseEntity> findAllReports( + public ResponseEntity> findAllReports( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") Long lastReportId, @RequestParam(defaultValue = "10") int pageSize diff --git a/src/main/java/coffeemeet/server/report/service/ReportService.java b/src/main/java/coffeemeet/server/report/service/ReportService.java index 83b466a4..c9b32f33 100644 --- a/src/main/java/coffeemeet/server/report/service/ReportService.java +++ b/src/main/java/coffeemeet/server/report/service/ReportService.java @@ -9,7 +9,7 @@ import coffeemeet.server.report.implement.ReportCommand; import coffeemeet.server.report.implement.ReportQuery; import coffeemeet.server.report.service.dto.GroupReportDto; -import coffeemeet.server.report.service.dto.Report; +import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; import coffeemeet.server.user.domain.User; @@ -67,11 +67,11 @@ public ReportListDto findAllReports(Long lastReportId, int pageSize) { Map userMap = getUsers(reports); Map chattingRoomMap = getChattingRooms(reports); - List responses = reports.stream() + List responses = reports.stream() .map(report -> { User targetUser = userMap.get(report.getTargetedId()); ChattingRoom chattingRoom = chattingRoomMap.get(report.getChattingRoomId()); - return Report.of(targetUser, chattingRoom); + return ReportSummary.of(targetUser, chattingRoom); }) .toList(); return ReportListDto.of(responses, hasNext); diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java b/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java index e217c368..b6e99789 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportListDto.java @@ -3,11 +3,11 @@ import java.util.List; public record ReportListDto( - List contents, + List contents, boolean hasNext ) { - public static ReportListDto of(List contents, boolean hasNext) { + public static ReportListDto of(List contents, boolean hasNext) { return new ReportListDto(contents, hasNext); } diff --git a/src/main/java/coffeemeet/server/report/service/dto/Report.java b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java similarity index 81% rename from src/main/java/coffeemeet/server/report/service/dto/Report.java rename to src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java index 889d5072..9b1b8f86 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/Report.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -public record Report( +public record ReportSummary( String targetedNickname, String chattingRoomName, Long targetedId, @@ -14,8 +14,8 @@ public record Report( LocalDateTime createdAt ) { - public static Report of(User targeted, ChattingRoom chattingRoom) { - return new Report( + public static ReportSummary of(User targeted, ChattingRoom chattingRoom) { + return new ReportSummary( targeted.getProfile().getNickname(), chattingRoom.getName(), targeted.getId(), diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 297968a7..88d387bb 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -47,7 +47,7 @@ import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; -import coffeemeet.server.report.service.dto.Report; +import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; import com.epages.restdocs.apispec.Schema; @@ -237,7 +237,7 @@ void findAllReportsTest() throws Exception { Long lastReportId = 0L; int pageSize = 10; ReportListDto reportListDto = ReportFixture.reportListDto(); - AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), + AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), reportListDto.hasNext()); given(reportService.findAllReports(lastReportId, pageSize)).willReturn(reportListDto); From 752c0019c9fc1a3a5321734c38b6e06841866cfd Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:52:59 +0900 Subject: [PATCH 34/74] refactor: import Report --- .../admin/presentation/AdminController.java | 2 +- .../server/report/service/ReportService.java | 21 ++++++++++--------- .../presentation/AdminControllerTest.java | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 994f4ad7..502dd11f 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -20,9 +20,9 @@ import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; -import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; +import coffeemeet.server.report.service.dto.ReportSummary; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; import jakarta.validation.Valid; diff --git a/src/main/java/coffeemeet/server/report/service/ReportService.java b/src/main/java/coffeemeet/server/report/service/ReportService.java index c9b32f33..fcb77024 100644 --- a/src/main/java/coffeemeet/server/report/service/ReportService.java +++ b/src/main/java/coffeemeet/server/report/service/ReportService.java @@ -6,12 +6,13 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.common.execption.NotFoundException; +import coffeemeet.server.report.domain.Report; import coffeemeet.server.report.implement.ReportCommand; import coffeemeet.server.report.implement.ReportQuery; import coffeemeet.server.report.service.dto.GroupReportDto; -import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; +import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; import java.util.List; @@ -42,7 +43,7 @@ public void reportUser(Long reporterId, Long chattingRoomId, Long targetId, Stri checkChattingRoomExists(reporterId, chattingRoomId); - coffeemeet.server.report.domain.Report report = coffeemeet.server.report.domain.Report.builder() + Report report = Report.builder() .reporterId(reporterId) .chattingRoomId(chattingRoomId) .targetedId(targetId) @@ -53,14 +54,14 @@ public void reportUser(Long reporterId, Long chattingRoomId, Long targetId, Stri } public ReportDetailDto findReportById(Long reportId) { - coffeemeet.server.report.domain.Report report = reportQuery.getReportById(reportId); + Report report = reportQuery.getReportById(reportId); User reporter = userQuery.getUserById(report.getReporterId()); User targetUser = userQuery.getUserById(report.getTargetedId()); return ReportDetailDto.of(report, reporter, targetUser); } public ReportListDto findAllReports(Long lastReportId, int pageSize) { - List reports = reportQuery.getAllReports(lastReportId, + List reports = reportQuery.getAllReports(lastReportId, pageSize); boolean hasNext = reports.size() >= pageSize; @@ -79,7 +80,7 @@ public ReportListDto findAllReports(Long lastReportId, int pageSize) { public List findReportByTargetIdAndChattingRoomId(Long targetId, Long chattingRoomId) { - List reports = reportQuery.getReportsByTargetIdAndChattingRoomId( + List reports = reportQuery.getReportsByTargetIdAndChattingRoomId( targetId, chattingRoomId); return reports.stream() @@ -106,25 +107,25 @@ private void checkChattingRoomExists(Long reporterId, Long chattingRoomId) { } private Map getChattingRooms( - List allReports) { + List allReports) { Set chattingRoomIds = allReports.stream() - .map(coffeemeet.server.report.domain.Report::getChattingRoomId) + .map(Report::getChattingRoomId) .collect(Collectors.toSet()); Set chattingRooms = chattingRoomQuery.getChattingRoomsSetBy(chattingRoomIds); return chattingRooms.stream() .collect(Collectors.toMap(ChattingRoom::getId, Function.identity())); } - private Map getUsers(List allReports) { + private Map getUsers(List allReports) { Set targetUserIds = allReports.stream() - .map(coffeemeet.server.report.domain.Report::getTargetedId) + .map(Report::getTargetedId) .collect(Collectors.toSet()); Set users = userQuery.getUsersByIdSet(targetUserIds); return users.stream() .collect(Collectors.toMap(User::getId, Function.identity())); } - private GroupReportDto mapToReportDto(coffeemeet.server.report.domain.Report report) { + private GroupReportDto mapToReportDto(Report report) { User reporter = userQuery.getUserById(report.getReporterId()); return GroupReportDto.of(reporter.getProfile().getNickname(), reporter.getId(), report.getCreatedAt()); diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 88d387bb..714a786e 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -47,9 +47,9 @@ import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; -import coffeemeet.server.report.service.dto.ReportSummary; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; +import coffeemeet.server.report.service.dto.ReportSummary; import com.epages.restdocs.apispec.Schema; import java.util.List; import org.junit.jupiter.api.DisplayName; From c2465c470dcccfe9211b2818ec30c35d7e38f886 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 20 Dec 2023 00:16:19 +0900 Subject: [PATCH 35/74] =?UTF-8?q?feat:=20ChattingDto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VO 와 Dto 로 분리 --- .../ChattingMessageController.java | 4 +-- .../presentation/dto/ChattingStomp.java | 16 +++++----- .../service/ChattingMessageService.java | 4 ++- .../current/service/dto/ChattingDto.java | 29 +++++++++++++++++++ .../service/ChattingMessageServiceTest.java | 4 ++- 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java index 7e75f11b..de68b8f8 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/ChattingMessageController.java @@ -2,7 +2,7 @@ import coffeemeet.server.chatting.current.presentation.dto.ChattingStomp; import coffeemeet.server.chatting.current.service.ChattingMessageService; -import coffeemeet.server.chatting.current.service.dto.Chatting; +import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import jakarta.validation.Valid; import java.time.LocalDateTime; @@ -42,7 +42,7 @@ public void onDisconnect(SessionDisconnectEvent event) { @MessageMapping("/chatting/messages") public void message(@Valid ChattingStomp.Request request, SimpMessageHeaderAccessor accessor) { - Chatting response = chattingMessageService.chat( + ChattingDto response = chattingMessageService.chat( accessor.getSessionId(), request.roomId(), request.content() diff --git a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java index 2a998abf..9cfcbd6d 100644 --- a/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java +++ b/src/main/java/coffeemeet/server/chatting/current/presentation/dto/ChattingStomp.java @@ -2,7 +2,7 @@ import static lombok.AccessLevel.PRIVATE; -import coffeemeet.server.chatting.current.service.dto.Chatting; +import coffeemeet.server.chatting.current.service.dto.ChattingDto; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -31,14 +31,14 @@ public record Response( LocalDateTime createdAt ) { - public static ChattingStomp.Response from(Chatting response) { + public static ChattingStomp.Response from(ChattingDto chatting) { return new ChattingStomp.Response( - response.userId(), - response.messageId(), - response.nickname(), - response.content(), - response.profileImageUrl(), - response.createdAt() + chatting.userId(), + chatting.messageId(), + chatting.nickname(), + chatting.content(), + chatting.profileImageUrl(), + chatting.createdAt() ); } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java index f1183170..1f2aa24b 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java @@ -7,6 +7,8 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; @@ -31,7 +33,7 @@ public class ChattingMessageService { private final UserCommand userCommand; private final FCMNotificationSender fcmNotificationSender; - public ChattingDto chatting(String sessionId, Long roomId, String content) { + public ChattingDto chat(String sessionId, Long roomId, String content) { Long userId = chattingSessionQuery.getUserIdById(sessionId); ChattingRoom room = chattingRoomQuery.getChattingRoomById(roomId); List users = userQuery.getUsersByRoom(room); diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java new file mode 100644 index 00000000..965a05a8 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java @@ -0,0 +1,29 @@ +package coffeemeet.server.chatting.current.service.dto; + +import coffeemeet.server.chatting.current.domain.ChattingMessage; +import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; + +public record ChattingDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + + public static ChattingDto of(User user, ChattingMessage chattingMessage) { + return new ChattingDto( + user.getId(), + chattingMessage.getId(), + user.getProfile().getNickname(), + chattingMessage.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessage.getCreatedAt() + ); + } + +} diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index 6490cab5..96488f9c 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -19,6 +19,8 @@ import coffeemeet.server.chatting.current.implement.ChattingRoomQuery; import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; +import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.common.implement.FCMNotificationSender; import coffeemeet.server.chatting.current.service.dto.Chatting; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; @@ -81,7 +83,7 @@ void chattingTest() { chattingMessage); // when - Chatting response = chattingMessageService.chat(chattingSession.sessionId(), + ChattingDto response = chattingMessageService.chat(chattingSession.sessionId(), chattingRoom.getId(), content); // then From d8618c2e4770c753539e32e207e63c2e7c1057f3 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Tue, 19 Dec 2023 22:28:28 +0900 Subject: [PATCH 36/74] =?UTF-8?q?test:=20=EB=A9=94=EC=9D=B8=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=A7=A4=EC=B9=AD=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EC=8B=A4=ED=8C=A8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/service/MatchingServiceTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java index 214f4e97..aa9be746 100644 --- a/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java +++ b/src/test/java/coffeemeet/server/matching/service/MatchingServiceTest.java @@ -3,6 +3,10 @@ import static coffeemeet.server.common.fixture.CertificationFixture.certificatedCertifications; import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; import static coffeemeet.server.common.fixture.UserFixture.fourUsers; +import static coffeemeet.server.common.fixture.UserFixture.user; +import static coffeemeet.server.common.fixture.UserFixture.userExcludingStatus; +import static coffeemeet.server.user.domain.UserStatus.MATCHING; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.willDoNothing; @@ -69,8 +73,8 @@ void startTest() { User requestedUser = users.get(0); Certification requestedUsersCertification = certifications.get(0); ChattingRoom chattingRoom = chattingRoom(); - Set notificationInfos = users.stream().map(User::getNotificationInfo).collect( - Collectors.toSet()); + Set notificationInfos = users.stream().map(User::getNotificationInfo) + .collect(Collectors.toSet()); given(certificationQuery.getCertificationByUserId(requestedUser.getId())).willReturn( requestedUsersCertification); @@ -79,8 +83,7 @@ void startTest() { given(matchingQueueQuery.dequeueMatchingGroupSize(companyName, users.size())).willReturn( fourUsers().stream().map(User::getId).collect(Collectors.toSet())); given(chattingRoomCommand.createChattingRoom()).willReturn(chattingRoom); - given(userQuery.getNotificationInfosByIdSet(userIds)).willReturn( - notificationInfos); + given(userQuery.getNotificationInfosByIdSet(userIds)).willReturn(notificationInfos); // when matchingService.startMatching(requestedUser.getId()); @@ -91,8 +94,8 @@ void startTest() { then(userCommand).should().setToMatching(requestedUser.getId()); then(userCommand).should().assignUsersToChattingRoom(userIds, chattingRoom); then(fcmNotificationSender).should() - .sendMultiNotificationsWithData(notificationInfos, "두근두근 커피밋 채팅을 시작하세요!", - "chattingRoomId", String.valueOf(chattingRoom.getId())); + .sendMultiNotificationsWithData(notificationInfos, "두근두근 커피밋 채팅을 시작하세요!", "chattingRoomId", + String.valueOf(chattingRoom.getId())); } @Test From 69e7f3992e2c097a02d4ef8d6b5ec424cbec2012 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:46:27 +0900 Subject: [PATCH 37/74] =?UTF-8?q?refactor:=20infra=20->=20domain=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/{implement => infrastructure}/ImageDeleter.java | 0 .../common/{implement => infrastructure}/ImageUploader.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/ImageDeleter.java (100%) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/ImageUploader.java (100%) diff --git a/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java b/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java similarity index 100% rename from src/main/java/coffeemeet/server/common/implement/ImageDeleter.java rename to src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java diff --git a/src/main/java/coffeemeet/server/common/implement/ImageUploader.java b/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java similarity index 100% rename from src/main/java/coffeemeet/server/common/implement/ImageUploader.java rename to src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java From 95547a532458366b0ba411f30fcce1911393745d Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:51:02 +0900 Subject: [PATCH 38/74] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatting/current/service/ChattingMessageService.java | 2 -- .../server/admin/presentation/AdminControllerTest.java | 5 +++++ .../chatting/current/service/ChattingMessageServiceTest.java | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java index 1f2aa24b..68282c42 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java @@ -7,8 +7,6 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; -import coffeemeet.server.common.implement.FCMNotificationSender; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 714a786e..62be7e81 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -1,5 +1,10 @@ package coffeemeet.server.admin.presentation; +import static coffeemeet.server.common.fixture.entity.AdminFixture.adminLoginHTTPRequest; +import static coffeemeet.server.common.fixture.entity.AdminFixture.reportApprovalHTTPRequest; +import static coffeemeet.server.common.fixture.entity.AdminFixture.reportRejectionHTTPRequest; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPageDto; import static coffeemeet.server.common.fixture.AdminFixture.adminLoginHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportApprovalHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportRejectionHTTPRequest; diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index 96488f9c..b580025f 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -21,7 +21,7 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.implement.FCMNotificationSender; -import coffeemeet.server.chatting.current.service.dto.Chatting; +import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserCommand; From 461404b7af0bca008c7079f08f239211749874f0 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:55:19 +0900 Subject: [PATCH 39/74] =?UTF-8?q?refactor:=20facade=20=ED=8C=A8=ED=84=B4?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20Service=20=EA=B3=84=EC=B8=B5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/certification/service/CertificationService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 7d9ee6a6..65448e47 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -16,6 +16,12 @@ import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.implement.CompanyEmailValidator; +import coffeemeet.server.certification.implement.VerificationCodeGenerator; +import coffeemeet.server.certification.implement.VerificationCodeValidator; +import coffeemeet.server.certification.implement.VerificationInfoCommand; +import coffeemeet.server.certification.implement.VerificationInfoQuery; +import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; From b5278c387147790eee084cc7c1de54f52d581f32 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:55:53 +0900 Subject: [PATCH 40/74] =?UTF-8?q?feat:=20=EC=A0=95=EC=A0=81=20=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../certification/service/dto/PendingCertificationPageDto.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 00062fab..5e50906c 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -12,5 +12,4 @@ public static PendingCertificationPageDto from( ) { return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); } - } From 120efd448649d233c8a6c5134698bb62fa573649 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:56:51 +0900 Subject: [PATCH 41/74] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CertificationRepositoryTest.java | 5 +++++ .../implement/CertificationCommandTest.java | 7 +++++++ .../service/CertificationServiceTest.java | 19 ++++++++++++++++--- .../common/implement/EmailSenderTest.java | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index 6391ad22..b5a4552d 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,5 +1,10 @@ package coffeemeet.server.certification.domain.repository; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.entity.UserFixture.users; +import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.common.fixture.UserFixture.users; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index 072f6da1..4fc57c1f 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,5 +1,12 @@ package coffeemeet.server.certification.implement; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index 049f50c0..c66f37ed 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,5 +1,12 @@ package coffeemeet.server.certification.service; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPage; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.CertificationFixture.department; @@ -25,6 +32,13 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.implement.CompanyEmailValidator; +import coffeemeet.server.certification.implement.VerificationCodeGenerator; +import coffeemeet.server.certification.implement.VerificationCodeValidator; +import coffeemeet.server.certification.implement.VerificationInfoCommand; +import coffeemeet.server.certification.implement.VerificationInfoQuery; +import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import org.instancio.Instancio; @@ -67,7 +81,7 @@ class CertificationServiceTest { @DisplayName("인증 정보를 등록할 수 있다.") void registerCertificationTest() { // given - long userId = 1L; + Long userId = 1L; String companyName = companyName(); String email = email(); String departmentName = department().name(); @@ -158,8 +172,7 @@ void getUncertifiedUserRequestsTest() { Page certificationPage = pendingCertificationPage( pageable.getPageSize()); - given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn( - certificationPage); + given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn(certificationPage); // when PendingCertificationPageDto result = certificationService.getUncertifiedUserRequests(pageable); diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 6632844a..64413aab 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,5 +1,6 @@ package coffeemeet.server.common.implement; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.CertificationFixture.email; import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; From 71fa16ec74c0771f58c23879bff0a170d77d43d1 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 10:59:53 +0900 Subject: [PATCH 42/74] =?UTF-8?q?refactor:=20=EC=BB=A8=ED=94=8C=EB=A6=AD?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CertificationService.java | 12 ++---------- .../ImageDeleter.java | 2 +- .../ImageUploader.java | 2 +- .../infrastructure/S3ObjectStorage.java | 2 +- .../presentation/AdminControllerTest.java | 6 +----- .../admin/service/AdminServiceTest.java | 2 -- .../domain/CertificationTest.java | 10 +++++----- .../CertificationRepositoryTest.java | 18 +++++++++--------- .../BusinessCardImageDeleterTest.java | 4 ++-- .../implement/CertificationCommandTest.java | 8 +------- .../VerificationInfoCommandTest.java | 2 +- .../implement/VerificationInfoQueryTest.java | 2 +- .../implement/VerificationMailSenderTest.java | 4 ++-- .../service/CertificationServiceTest.java | 19 ++++--------------- .../service/ChattingMessageServiceTest.java | 2 -- .../common/fixture/CertificationFixture.java | 10 +--------- .../common/implement/EmailSenderTest.java | 7 ++----- 17 files changed, 34 insertions(+), 78 deletions(-) rename src/main/java/coffeemeet/server/common/{infrastructure => implement}/ImageDeleter.java (100%) rename src/main/java/coffeemeet/server/common/{infrastructure => implement}/ImageUploader.java (100%) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 65448e47..12fe9612 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -13,15 +13,6 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.implement.EmailVerificationCommand; -import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertification; -import coffeemeet.server.certification.implement.CompanyEmailValidator; -import coffeemeet.server.certification.implement.VerificationCodeGenerator; -import coffeemeet.server.certification.implement.VerificationCodeValidator; -import coffeemeet.server.certification.implement.VerificationInfoCommand; -import coffeemeet.server.certification.implement.VerificationInfoQuery; -import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; @@ -85,7 +76,8 @@ public void compareCode(Long userId, String userInputCode) { } public PendingCertificationPageDto getUncertifiedUserRequests(Pageable pageable) { - Page pendingCertifications = certificationQuery.getPendingCertification(pageable); + Page pendingCertifications = certificationQuery.getPendingCertification( + pageable); return PendingCertificationPageDto.from(pendingCertifications); } diff --git a/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java b/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java similarity index 100% rename from src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java rename to src/main/java/coffeemeet/server/common/implement/ImageDeleter.java index e8e6fa4f..2f8152a4 100644 --- a/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java +++ b/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java @@ -1,7 +1,7 @@ package coffeemeet.server.common.implement; -import coffeemeet.server.common.domain.S3KeyPrefix; import coffeemeet.server.common.domain.ObjectStorage; +import coffeemeet.server.common.domain.S3KeyPrefix; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java b/src/main/java/coffeemeet/server/common/implement/ImageUploader.java similarity index 100% rename from src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java rename to src/main/java/coffeemeet/server/common/implement/ImageUploader.java index 479049ec..ad082a16 100644 --- a/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java +++ b/src/main/java/coffeemeet/server/common/implement/ImageUploader.java @@ -1,7 +1,7 @@ package coffeemeet.server.common.implement; -import coffeemeet.server.common.domain.S3KeyPrefix; import coffeemeet.server.common.domain.ObjectStorage; +import coffeemeet.server.common.domain.S3KeyPrefix; import coffeemeet.server.common.util.FileUtils; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java b/src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java index 12b6adda..2fd98edd 100644 --- a/src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java +++ b/src/main/java/coffeemeet/server/common/infrastructure/S3ObjectStorage.java @@ -1,7 +1,7 @@ package coffeemeet.server.common.infrastructure; -import coffeemeet.server.common.domain.S3KeyPrefix; import coffeemeet.server.common.domain.ObjectStorage; +import coffeemeet.server.common.domain.S3KeyPrefix; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.s3.AmazonS3; import java.io.File; diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 62be7e81..6c6d6f35 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -1,13 +1,9 @@ package coffeemeet.server.admin.presentation; -import static coffeemeet.server.common.fixture.entity.AdminFixture.adminLoginHTTPRequest; -import static coffeemeet.server.common.fixture.entity.AdminFixture.reportApprovalHTTPRequest; -import static coffeemeet.server.common.fixture.entity.AdminFixture.reportRejectionHTTPRequest; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPageDto; import static coffeemeet.server.common.fixture.AdminFixture.adminLoginHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportApprovalHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportRejectionHTTPRequest; +import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertificationPageDto; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; diff --git a/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java b/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java index 88034293..d75e5db4 100644 --- a/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java +++ b/src/test/java/coffeemeet/server/admin/service/AdminServiceTest.java @@ -15,8 +15,6 @@ import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.common.fixture.InquiryFixture; -import coffeemeet.server.common.implement.FCMNotificationSender; -import coffeemeet.server.common.fixture.entity.InquiryFixture; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.inquiry.domain.Inquiry; import coffeemeet.server.inquiry.implement.InquiryCommand; diff --git a/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java b/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java index eac68f72..c1c7acb6 100644 --- a/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/CertificationTest.java @@ -1,10 +1,10 @@ package coffeemeet.server.certification.domain; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.CertificationFixture.department; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index b5a4552d..56fe4294 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,23 +1,18 @@ package coffeemeet.server.certification.domain.repository; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.fixture.entity.UserFixture.users; -import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.UserFixture.user; -import static coffeemeet.server.common.fixture.UserFixture.users; +import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.UserFixture.usersWithNullId; import static org.assertj.core.api.Assertions.assertThat; import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.domain.repository.CertificationRepository; import coffeemeet.server.common.config.RepositoryTestConfig; import coffeemeet.server.common.fixture.CertificationFixture; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import java.util.List; -import org.junit.jupiter.api.AfterEach; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -68,8 +63,13 @@ void deleteByUserIdTest() { // given Certification certification = certification(user); certificationRepository.save(certification); - // when, then + + // when certificationRepository.deleteByUserId(user.getId()); + + // then + Optional result = certificationRepository.findByUserId(user.getId()); + assertThat(result).isEmpty(); } @Test diff --git a/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java b/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java index 18c813dd..99ba509f 100644 --- a/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/BusinessCardImageDeleterTest.java @@ -1,8 +1,8 @@ package coffeemeet.server.certification.implement; import static coffeemeet.server.common.domain.S3KeyPrefix.BUSINESS_CARD; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.UserFixture.user; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.only; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index 4fc57c1f..e4168d4a 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,17 +1,11 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.CertificationFixture.department; +import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertification; import static coffeemeet.server.common.fixture.UserFixture.user; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java index 2bf0b8f0..f566b3ad 100644 --- a/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoCommandTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailVerification; +import static coffeemeet.server.common.fixture.CertificationFixture.emailVerification; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java index d834b1c3..cb70dfd8 100644 --- a/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationInfoQueryTest.java @@ -1,6 +1,6 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.emailVerification; +import static coffeemeet.server.common.fixture.CertificationFixture.emailVerification; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java b/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java index 69732711..73af896f 100644 --- a/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/VerificationMailSenderTest.java @@ -1,7 +1,7 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; +import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.only; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index c66f37ed..4d104d70 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,17 +1,12 @@ package coffeemeet.server.certification.service; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPage; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.CertificationFixture.department; import static coffeemeet.server.common.fixture.CertificationFixture.email; import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; +import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertificationPage; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -32,13 +27,6 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.implement.CompanyEmailValidator; -import coffeemeet.server.certification.implement.VerificationCodeGenerator; -import coffeemeet.server.certification.implement.VerificationCodeValidator; -import coffeemeet.server.certification.implement.VerificationInfoCommand; -import coffeemeet.server.certification.implement.VerificationInfoQuery; -import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import org.instancio.Instancio; @@ -172,7 +160,8 @@ void getUncertifiedUserRequestsTest() { Page certificationPage = pendingCertificationPage( pageable.getPageSize()); - given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn(certificationPage); + given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn( + certificationPage); // when PendingCertificationPageDto result = certificationService.getUncertifiedUserRequests(pageable); diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index b580025f..59e2d100 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -20,8 +20,6 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; -import coffeemeet.server.common.implement.FCMNotificationSender; -import coffeemeet.server.chatting.current.service.dto.ChattingDto.Response; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserCommand; diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index e2fd3367..8397bc08 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -9,7 +9,6 @@ import coffeemeet.server.certification.domain.VerificationInfo; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -138,14 +137,7 @@ private static List certificationsNotCertificated(int size) { } public static PendingCertificationPageDto pendingCertificationPageDto(int size) { - return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); - } - - private static List pendingCertifications(int size) { - return Instancio.ofList(PendingCertification.class).size(size) - .generate(field(PendingCertification::businessCardUrl), - gen -> gen.net().url().asString()) - .generate(field(PendingCertification::companyEmail), gen -> gen.net().email()).create(); + return PendingCertificationPageDto.from(pendingCertificationPage(size)); } } diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 64413aab..9df89765 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,9 +1,6 @@ package coffeemeet.server.common.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.CertificationFixture.email; -import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.then; @@ -26,7 +23,7 @@ @ExtendWith(MockitoExtension.class) class EmailSenderTest { - private coffeemeet.server.common.implement.EmailSender emailSender; + private EmailSender emailSender; @Mock private JavaMailSender javaMailSender; @@ -39,7 +36,7 @@ class EmailSenderTest { @BeforeEach void setUp() { sender = email(); - emailSender = new coffeemeet.server.common.implement.EmailSender(javaMailSender, sender); + emailSender = new EmailSender(javaMailSender, sender); } @Test From ff6d24a9da9a32e70dc12bd86ab4b4cb06b13992 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:59:05 +0900 Subject: [PATCH 43/74] =?UTF-8?q?refactor:=20certification=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/admin/presentation/AdminController.java | 6 +++--- ...ndingCertification.java => PendingCertificationDto.java} | 6 +++--- .../server/admin/presentation/AdminControllerTest.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertification.java => PendingCertificationDto.java} (78%) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 502dd11f..29679af7 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -10,7 +10,7 @@ import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; @@ -203,7 +203,7 @@ public ResponseEntity checkInquiry( // TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요 @PerformanceMeasurement @GetMapping("/certifications/pending") - public ResponseEntity> getPendingCertifications( + public ResponseEntity> getPendingCertifications( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int size @@ -217,7 +217,7 @@ public ResponseEntity> getPendingCertifica PendingCertificationPageDto uncertifiedUserRequests = certificationService.getUncertifiedUserRequests( pageable); - Page page = uncertifiedUserRequests.page(); + Page page = uncertifiedUserRequests.page(); return ResponseEntity.ok( AdminCustomPage.of(page.getContent(), page.hasNext()) ); diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java index 7b59a245..1ff1650a 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertification( +public record PendingCertificationDto( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertification( String department ) { - public static PendingCertification from(Certification certification) { - return new PendingCertification( + public static PendingCertificationDto from(Certification certification) { + return new PendingCertificationDto( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 6c6d6f35..37158a41 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -35,7 +35,7 @@ import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; @@ -457,8 +457,8 @@ void getPendingCertificationsTest() throws Exception { Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); - Page page = pendingCertificationPageDto.page(); - AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( + Page page = pendingCertificationPageDto.page(); + AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( page.getContent(), page.hasNext()); given(certificationService.getUncertifiedUserRequests(any())).willReturn( From cb1e0b4c5dbddd2edd8609b509f1bb42dc3791ac Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 44/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tionDto.java => PendingCertification.java} | 6 ++-- .../current/service/dto/ChattingDto.java | 29 ------------------- .../report/service/dto/ReportSummary.java | 9 ++++++ 3 files changed, 12 insertions(+), 32 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertificationDto.java => PendingCertification.java} (78%) delete mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java index 1ff1650a..7b59a245 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertificationDto( +public record PendingCertification( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertificationDto( String department ) { - public static PendingCertificationDto from(Certification certification) { - return new PendingCertificationDto( + public static PendingCertification from(Certification certification) { + return new PendingCertification( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java deleted file mode 100644 index 965a05a8..00000000 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package coffeemeet.server.chatting.current.service.dto; - -import coffeemeet.server.chatting.current.domain.ChattingMessage; -import coffeemeet.server.user.domain.User; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; - -public record ChattingDto( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt -) { - - public static ChattingDto of(User user, ChattingMessage chattingMessage) { - return new ChattingDto( - user.getId(), - chattingMessage.getId(), - user.getProfile().getNickname(), - chattingMessage.getMessage(), - user.getOauthInfo().getProfileImageUrl(), - chattingMessage.getCreatedAt() - ); - } - -} diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java index 9b1b8f86..e7bb000f 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java @@ -5,7 +5,11 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; +<<<<<<<< HEAD:src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java public record ReportSummary( +======== +public record Report( +>>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java String targetedNickname, String chattingRoomName, Long targetedId, @@ -14,8 +18,13 @@ public record ReportSummary( LocalDateTime createdAt ) { +<<<<<<<< HEAD:src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java public static ReportSummary of(User targeted, ChattingRoom chattingRoom) { return new ReportSummary( +======== + public static Report of(User targeted, ChattingRoom chattingRoom) { + return new Report( +>>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java targeted.getProfile().getNickname(), chattingRoom.getName(), targeted.getId(), From 3e0515d1218b3b23f7cf95d0231df8f7d3594483 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 20 Dec 2023 00:16:19 +0900 Subject: [PATCH 45/74] =?UTF-8?q?feat:=20ChattingDto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VO 와 Dto 로 분리 --- .../current/service/dto/ChattingDto.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java new file mode 100644 index 00000000..965a05a8 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java @@ -0,0 +1,29 @@ +package coffeemeet.server.chatting.current.service.dto; + +import coffeemeet.server.chatting.current.domain.ChattingMessage; +import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; + +public record ChattingDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + + public static ChattingDto of(User user, ChattingMessage chattingMessage) { + return new ChattingDto( + user.getId(), + chattingMessage.getId(), + user.getProfile().getNickname(), + chattingMessage.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessage.getCreatedAt() + ); + } + +} From 4adb6cde21dc6d50fe70ef825c6f458af117291f Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:46:27 +0900 Subject: [PATCH 46/74] =?UTF-8?q?refactor:=20infra=20->=20domain=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/{implement => infrastructure}/ImageDeleter.java | 0 .../common/{implement => infrastructure}/ImageUploader.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/ImageDeleter.java (100%) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/ImageUploader.java (100%) diff --git a/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java b/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java similarity index 100% rename from src/main/java/coffeemeet/server/common/implement/ImageDeleter.java rename to src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java diff --git a/src/main/java/coffeemeet/server/common/implement/ImageUploader.java b/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java similarity index 100% rename from src/main/java/coffeemeet/server/common/implement/ImageUploader.java rename to src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java From d2fc3e537c40fa73d799fafca3f8e01656333e84 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:51:02 +0900 Subject: [PATCH 47/74] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/coffeemeet/server/user/service/UserServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index 62dc07f6..878ba10a 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -2,9 +2,9 @@ import static coffeemeet.server.common.domain.S3KeyPrefix.PROFILE_IMAGE; import static coffeemeet.server.common.fixture.AuthFixture.authTokens; +import static coffeemeet.server.common.fixture.OauthFixture.response; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; -import static coffeemeet.server.common.fixture.OauthFixture.response; import static coffeemeet.server.common.fixture.UserFixture.keywords; import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; From 218dcf71846c9fd0138072d60c199af06bbf52e9 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 15:33:42 +0900 Subject: [PATCH 48/74] =?UTF-8?q?refactor:=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔티티의 필드 타입에 맞게 Id 값의 타입은 Reference Type 사용 - 시간 또는 카운트 숫자의 데이터 경우 성능을 고려해서 Primitive Type 사용 --- .../coffeemeet/server/common/fixture/entity/ReportFixture.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/ReportFixture.java new file mode 100644 index 00000000..e69de29b From 789b8f5539c57f8e2efb6698eb567ea9205e093d Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:59:05 +0900 Subject: [PATCH 49/74] =?UTF-8?q?refactor:=20certification=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/certification/service/CertificationService.java | 3 +++ ...ndingCertification.java => PendingCertificationDto.java} | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertification.java => PendingCertificationDto.java} (78%) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 12fe9612..3d41f1e5 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -13,6 +13,9 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java index 7b59a245..1ff1650a 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertification( +public record PendingCertificationDto( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertification( String department ) { - public static PendingCertification from(Certification certification) { - return new PendingCertification( + public static PendingCertificationDto from(Certification certification) { + return new PendingCertificationDto( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), From 8dc477787208266756c77c03fa9607e117e8ed6e Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 18:54:01 +0900 Subject: [PATCH 50/74] =?UTF-8?q?test:=20Fixture=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 도메인별로 픽스처 구분 --- .../chatting/current/service/ChattingMessageServiceTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index 59e2d100..d6c2a2d1 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -4,7 +4,6 @@ import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; import static coffeemeet.server.common.fixture.UserFixture.fourUsers; import static coffeemeet.server.common.fixture.UserFixture.user; -import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.BDDMockito.given; From 941d026a018b1a6aa8d15a2f49c75e736a2d21ae Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 51/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/presentation/AdminController.java | 6 ++-- .../service/CertificationService.java | 2 +- ...tionDto.java => PendingCertification.java} | 6 ++-- .../dto/PendingCertificationPageDto.java | 1 + .../current/service/dto/ChattingDto.java | 29 ------------------- .../history/service/dto/ChattingHistory.java | 2 +- .../presentation/AdminControllerTest.java | 6 ++-- 7 files changed, 12 insertions(+), 40 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertificationDto.java => PendingCertification.java} (78%) delete mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 29679af7..502dd11f 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -10,7 +10,7 @@ import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; @@ -203,7 +203,7 @@ public ResponseEntity checkInquiry( // TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요 @PerformanceMeasurement @GetMapping("/certifications/pending") - public ResponseEntity> getPendingCertifications( + public ResponseEntity> getPendingCertifications( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int size @@ -217,7 +217,7 @@ public ResponseEntity> getPendingCertif PendingCertificationPageDto uncertifiedUserRequests = certificationService.getUncertifiedUserRequests( pageable); - Page page = uncertifiedUserRequests.page(); + Page page = uncertifiedUserRequests.page(); return ResponseEntity.ok( AdminCustomPage.of(page.getContent(), page.hasNext()) ); diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 3d41f1e5..d392766b 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -15,7 +15,7 @@ import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java index 1ff1650a..7b59a245 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertificationDto( +public record PendingCertification( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertificationDto( String department ) { - public static PendingCertificationDto from(Certification certification) { - return new PendingCertificationDto( + public static PendingCertification from(Certification certification) { + return new PendingCertification( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 5e50906c..00062fab 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -12,4 +12,5 @@ public static PendingCertificationPageDto from( ) { return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); } + } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java deleted file mode 100644 index 965a05a8..00000000 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package coffeemeet.server.chatting.current.service.dto; - -import coffeemeet.server.chatting.current.domain.ChattingMessage; -import coffeemeet.server.user.domain.User; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; - -public record ChattingDto( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt -) { - - public static ChattingDto of(User user, ChattingMessage chattingMessage) { - return new ChattingDto( - user.getId(), - chattingMessage.getId(), - user.getProfile().getNickname(), - chattingMessage.getMessage(), - user.getOauthInfo().getProfileImageUrl(), - chattingMessage.getCreatedAt() - ); - } - -} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java index 7157cf6c..4b71b637 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java @@ -15,7 +15,7 @@ public record ChattingHistory( ) { public static ChattingHistory of(User user, - coffeemeet.server.chatting.history.domain.ChattingMessageHistory chattingMessageHistory) { + ChattingMessageHistory chattingMessageHistory) { return new ChattingHistory( user.getId(), chattingMessageHistory.getId(), diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 37158a41..6c6d6f35 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -35,7 +35,7 @@ import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; @@ -457,8 +457,8 @@ void getPendingCertificationsTest() throws Exception { Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); - Page page = pendingCertificationPageDto.page(); - AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( + Page page = pendingCertificationPageDto.page(); + AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( page.getContent(), page.hasNext()); given(certificationService.getUncertifiedUserRequests(any())).willReturn( From fb34c6b756afade8b2add30d6b3b907f8f26b3f3 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 20 Dec 2023 00:16:19 +0900 Subject: [PATCH 52/74] =?UTF-8?q?feat:=20ChattingDto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VO 와 Dto 로 분리 --- .../service/ChattingMessageService.java | 2 ++ .../current/service/dto/ChattingDto.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java index 68282c42..1f2aa24b 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java @@ -7,6 +7,8 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; +import coffeemeet.server.common.implement.FCMNotificationSender; +import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java new file mode 100644 index 00000000..965a05a8 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java @@ -0,0 +1,29 @@ +package coffeemeet.server.chatting.current.service.dto; + +import coffeemeet.server.chatting.current.domain.ChattingMessage; +import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; + +public record ChattingDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + + public static ChattingDto of(User user, ChattingMessage chattingMessage) { + return new ChattingDto( + user.getId(), + chattingMessage.getId(), + user.getProfile().getNickname(), + chattingMessage.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessage.getCreatedAt() + ); + } + +} From b250c015645fad1bf67f975709fd2705408ef8c2 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:51:02 +0900 Subject: [PATCH 53/74] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatting/current/service/ChattingMessageService.java | 2 -- .../server/admin/presentation/AdminControllerTest.java | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java index 1f2aa24b..68282c42 100644 --- a/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java +++ b/src/main/java/coffeemeet/server/chatting/current/service/ChattingMessageService.java @@ -7,8 +7,6 @@ import coffeemeet.server.chatting.current.implement.ChattingSessionCommand; import coffeemeet.server.chatting.current.implement.ChattingSessionQuery; import coffeemeet.server.chatting.current.service.dto.ChattingDto; -import coffeemeet.server.common.implement.FCMNotificationSender; -import coffeemeet.server.chatting.current.service.dto.ChattingDto; import coffeemeet.server.common.infrastructure.FCMNotificationSender; import coffeemeet.server.user.domain.NotificationInfo; import coffeemeet.server.user.domain.User; diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 6c6d6f35..7a2ad908 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -1,5 +1,10 @@ package coffeemeet.server.admin.presentation; +import static coffeemeet.server.common.fixture.entity.AdminFixture.adminLoginHTTPRequest; +import static coffeemeet.server.common.fixture.entity.AdminFixture.reportApprovalHTTPRequest; +import static coffeemeet.server.common.fixture.entity.AdminFixture.reportRejectionHTTPRequest; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPageDto; import static coffeemeet.server.common.fixture.AdminFixture.adminLoginHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportApprovalHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportRejectionHTTPRequest; From 11a6eb4453da60c13ed08a8c27264845c6ce6a2f Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:56:51 +0900 Subject: [PATCH 54/74] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/CertificationRepositoryTest.java | 5 +++++ .../implement/CertificationCommandTest.java | 7 +++++++ .../service/CertificationServiceTest.java | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index 56fe4294..b04136ad 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,5 +1,10 @@ package coffeemeet.server.certification.domain.repository; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.entity.UserFixture.users; +import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index e4168d4a..ffdd5604 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,5 +1,12 @@ package coffeemeet.server.certification.implement; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index 4d104d70..9d27684c 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,5 +1,12 @@ package coffeemeet.server.certification.service; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPage; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.CertificationFixture.department; @@ -27,6 +34,13 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.implement.CompanyEmailValidator; +import coffeemeet.server.certification.implement.VerificationCodeGenerator; +import coffeemeet.server.certification.implement.VerificationCodeValidator; +import coffeemeet.server.certification.implement.VerificationInfoCommand; +import coffeemeet.server.certification.implement.VerificationInfoQuery; +import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import org.instancio.Instancio; @@ -160,8 +174,7 @@ void getUncertifiedUserRequestsTest() { Page certificationPage = pendingCertificationPage( pageable.getPageSize()); - given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn( - certificationPage); + given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn(certificationPage); // when PendingCertificationPageDto result = certificationService.getUncertifiedUserRequests(pageable); From f267eabdfc24c5878ec4fcd816295266304c489d Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 10:59:53 +0900 Subject: [PATCH 55/74] =?UTF-8?q?refactor:=20=EC=BB=A8=ED=94=8C=EB=A6=AD?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageDeleter.java | 0 .../ImageUploader.java | 0 .../admin/presentation/AdminControllerTest.java | 5 ----- .../repository/CertificationRepositoryTest.java | 5 ----- .../implement/CertificationCommandTest.java | 7 ------- .../service/CertificationServiceTest.java | 14 -------------- 6 files changed, 31 deletions(-) rename src/main/java/coffeemeet/server/common/{infrastructure => implement}/ImageDeleter.java (100%) rename src/main/java/coffeemeet/server/common/{infrastructure => implement}/ImageUploader.java (100%) diff --git a/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java b/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java similarity index 100% rename from src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java rename to src/main/java/coffeemeet/server/common/implement/ImageDeleter.java diff --git a/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java b/src/main/java/coffeemeet/server/common/implement/ImageUploader.java similarity index 100% rename from src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java rename to src/main/java/coffeemeet/server/common/implement/ImageUploader.java diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 7a2ad908..6c6d6f35 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -1,10 +1,5 @@ package coffeemeet.server.admin.presentation; -import static coffeemeet.server.common.fixture.entity.AdminFixture.adminLoginHTTPRequest; -import static coffeemeet.server.common.fixture.entity.AdminFixture.reportApprovalHTTPRequest; -import static coffeemeet.server.common.fixture.entity.AdminFixture.reportRejectionHTTPRequest; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPageDto; import static coffeemeet.server.common.fixture.AdminFixture.adminLoginHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportApprovalHTTPRequest; import static coffeemeet.server.common.fixture.AdminFixture.reportRejectionHTTPRequest; diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index b04136ad..56fe4294 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,10 +1,5 @@ package coffeemeet.server.certification.domain.repository; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.fixture.entity.UserFixture.users; -import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index ffdd5604..e4168d4a 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,12 +1,5 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index 9d27684c..62ca75de 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,12 +1,5 @@ package coffeemeet.server.certification.service; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertificationPage; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.CertificationFixture.department; @@ -34,13 +27,6 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.implement.CompanyEmailValidator; -import coffeemeet.server.certification.implement.VerificationCodeGenerator; -import coffeemeet.server.certification.implement.VerificationCodeValidator; -import coffeemeet.server.certification.implement.VerificationInfoCommand; -import coffeemeet.server.certification.implement.VerificationInfoQuery; -import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import org.instancio.Instancio; From 21e3d1f2bebb7f6d690d7d4adeb0c28ed55a6057 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 15:33:42 +0900 Subject: [PATCH 56/74] =?UTF-8?q?refactor:=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔티티의 필드 타입에 맞게 Id 값의 타입은 Reference Type 사용 - 시간 또는 카운트 숫자의 데이터 경우 성능을 고려해서 Primitive Type 사용 --- .../service/CertificationService.java | 3 -- .../history/service/dto/ChattingHistory.java | 1 + .../report/service/dto/ReportSummary.java | 36 +++++++++---------- .../CertificationRepositoryTest.java | 2 +- .../service/CertificationServiceTest.java | 8 ++--- .../server/user/service/UserServiceTest.java | 2 +- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index d392766b..12fe9612 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -13,9 +13,6 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.implement.EmailVerificationCommand; -import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java index 4b71b637..a333d7c8 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java @@ -1,5 +1,6 @@ package coffeemeet.server.chatting.history.service.dto; +import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.user.domain.User; import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java index e7bb000f..19bb1afa 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java @@ -1,36 +1,34 @@ package coffeemeet.server.report.service.dto; -import coffeemeet.server.chatting.current.domain.ChattingRoom; -import coffeemeet.server.user.domain.User; import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; -<<<<<<<< HEAD:src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java +<<<<<<<>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java + >>>>>>>>e82e9257(refactor:네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java String targetedNickname, String chattingRoomName, Long targetedId, Long chattingRoomId, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") +@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt -) { + ){ -<<<<<<<< HEAD:src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java - public static ReportSummary of(User targeted, ChattingRoom chattingRoom) { + <<<<<<<>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java - targeted.getProfile().getNickname(), - chattingRoom.getName(), - targeted.getId(), - chattingRoom.getId(), - targeted.getCreatedAt() + >>>>>>>>e82e9257(refactor:네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java + targeted.getProfile().getNickname(), + chattingRoom.getName(), + targeted.getId(), + chattingRoom.getId(), + targeted.getCreatedAt() ); - } + } -} + } diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index 56fe4294..6c01ce69 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,8 +1,8 @@ package coffeemeet.server.certification.domain.repository; import static coffeemeet.server.common.fixture.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.common.fixture.UserFixture.usersWithNullId; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index 62ca75de..bb7df334 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -1,13 +1,12 @@ package coffeemeet.server.certification.service; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.CertificationFixture.companyName; import static coffeemeet.server.common.fixture.CertificationFixture.department; import static coffeemeet.server.common.fixture.CertificationFixture.email; -import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; -import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertificationPage; -import static org.assertj.core.api.Assertions.assertThat; +import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; @@ -160,7 +159,8 @@ void getUncertifiedUserRequestsTest() { Page certificationPage = pendingCertificationPage( pageable.getPageSize()); - given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn(certificationPage); + given(certificationQuery.getPendingCertification(any(Pageable.class))).willReturn( + certificationPage); // when PendingCertificationPageDto result = certificationService.getUncertifiedUserRequests(pageable); diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index 878ba10a..62dc07f6 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -2,9 +2,9 @@ import static coffeemeet.server.common.domain.S3KeyPrefix.PROFILE_IMAGE; import static coffeemeet.server.common.fixture.AuthFixture.authTokens; -import static coffeemeet.server.common.fixture.OauthFixture.response; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; +import static coffeemeet.server.common.fixture.OauthFixture.response; import static coffeemeet.server.common.fixture.UserFixture.keywords; import static coffeemeet.server.common.fixture.UserFixture.user; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; From 25ad2d4f78bb647e4a079c89ac37f97a69407304 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:59:05 +0900 Subject: [PATCH 57/74] =?UTF-8?q?refactor:=20certification=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/presentation/AdminController.java | 6 +- .../service/CertificationService.java | 103 +++++++++++------- ...tion.java => PendingCertificationDto.java} | 6 +- .../dto/PendingCertificationPageDto.java | 9 +- .../presentation/AdminControllerTest.java | 6 +- .../common/fixture/CertificationFixture.java | 54 ++++----- 6 files changed, 98 insertions(+), 86 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertification.java => PendingCertificationDto.java} (78%) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 502dd11f..29679af7 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -10,7 +10,7 @@ import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; @@ -203,7 +203,7 @@ public ResponseEntity checkInquiry( // TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요 @PerformanceMeasurement @GetMapping("/certifications/pending") - public ResponseEntity> getPendingCertifications( + public ResponseEntity> getPendingCertifications( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int size @@ -217,7 +217,7 @@ public ResponseEntity> getPendingCertifica PendingCertificationPageDto uncertifiedUserRequests = certificationService.getUncertifiedUserRequests( pageable); - Page page = uncertifiedUserRequests.page(); + Page page = uncertifiedUserRequests.page(); return ResponseEntity.ok( AdminCustomPage.of(page.getContent(), page.hasNext()) ); diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 12fe9612..14468e6f 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,20 +1,25 @@ package coffeemeet.server.certification.service; +import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; +import static coffeemeet.server.common.domain.KeyType.BUSINESS_CARD; + import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.implement.BusinessCardImageDeleter; -import coffeemeet.server.certification.implement.BusinessCardImageUploader; import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; -import coffeemeet.server.certification.implement.CompanyEmailValidator; -import coffeemeet.server.certification.implement.VerificationCodeGenerator; -import coffeemeet.server.certification.implement.VerificationCodeValidator; -import coffeemeet.server.certification.implement.VerificationInfoCommand; -import coffeemeet.server.certification.implement.VerificationInfoQuery; -import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; +import coffeemeet.server.common.execption.InvalidInputException; +import coffeemeet.server.common.implement.EmailSender; +import coffeemeet.server.common.implement.MediaManager; +import coffeemeet.server.common.util.FileUtils; +import coffeemeet.server.user.domain.User; +import coffeemeet.server.user.implement.UserQuery; import java.io.File; +import java.util.random.RandomGenerator; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -24,61 +29,81 @@ @RequiredArgsConstructor public class CertificationService { - private final BusinessCardImageUploader businessCardImageUploader; - private final BusinessCardImageDeleter businessCardImageDeleter; + private static final String WRONG_VERIFICATION_CODE_MESSAGE = "사용자(%s)가 잘못된 인증코드(%s)를 입력했습니다."; + private static final RandomGenerator RANDOM_GENERATOR = RandomGenerator.getDefault(); + + private final MediaManager mediaManager; + private final EmailSender emailSender; + private final UserQuery userQuery; private final CertificationCommand certificationCommand; private final CertificationQuery certificationQuery; - private final CompanyEmailValidator companyEmailValidator; - private final VerificationCodeGenerator verificationCodeGenerator; - private final VerificationCodeValidator verificationCodeValidator; - private final VerificationInfoQuery verificationInfoQuery; - private final VerificationInfoCommand verificationInfoCommand; - private final VerificationMailSender verificationMailSender; + private final EmailVerificationCommand emailVerificationCommand; + private final EmailVerificationQuery emailVerificationQuery; public void registerCertification(Long userId, String companyName, String email, String departmentName, File businessCardImage) { - CompanyEmail companyEmail = new CompanyEmail(email); - Department department = Department.valueOf(departmentName); - - String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage( - businessCardImage); - - certificationCommand.createCertification(userId, companyName, companyEmail, department, - businessCardImageUrl); + processCertification(userId, companyName, email, departmentName, businessCardImage, false); } public void updateCertification(Long userId, String companyName, String email, String departmentName, File businessCardImage) { + processCertification(userId, companyName, email, departmentName, businessCardImage, true); + } + + private void processCertification(Long userId, String companyName, String email, + String departmentName, File businessCardImage, boolean isUpdate) { + String key = mediaManager.generateKey(BUSINESS_CARD); + uploadBusinessCard(userId, key, businessCardImage); + CompanyEmail companyEmail = new CompanyEmail(email); + String businessCardUrl = mediaManager.getUrl(key); Department department = Department.valueOf(departmentName); + User user = userQuery.getUserById(userId); - businessCardImageDeleter.deleteBusinessCardImageByUserId(userId); - String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage( - businessCardImage); + if (isUpdate) { + certificationCommand.deleteCertification(userId); + } + certificationCommand.createCertification(user, companyName, companyEmail, department, + businessCardUrl); + } + + private void uploadBusinessCard(Long userId, String key, File businessCardUrl) { + certificationCommand.applyIfCertifiedUser(userId, certification -> { + String oldKey = mediaManager.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD); + mediaManager.delete(oldKey); + }); - certificationCommand.updateCertification(userId, companyName, companyEmail, department, - businessCardImageUrl); + mediaManager.upload(key, businessCardUrl); + FileUtils.delete(businessCardUrl); } public void sendVerificationMail(Long userId, String email) { CompanyEmail companyEmail = new CompanyEmail(email); - companyEmailValidator.validateDuplicatedCompanyEmail(companyEmail); + certificationCommand.hasDuplicatedCompanyEmail(companyEmail); - String verificationCode = verificationCodeGenerator.generateVerificationCode(); - verificationMailSender.sendVerificationMail(companyEmail, verificationCode); + String verificationCode = generateVerificationCode(); + emailSender.sendVerificationCode(companyEmail, verificationCode); + emailVerificationCommand.createEmailVerification(userId, companyEmail, verificationCode); + } - verificationInfoCommand.createVerificationInfo(userId, companyEmail, verificationCode); + private String generateVerificationCode() { + return String.format("%06d", RANDOM_GENERATOR.nextInt(1000000)); } - public void compareCode(Long userId, String userInputCode) { - String verificationCode = verificationInfoQuery.getVerificationCodeById(userId); - verificationCodeValidator.validateVerificationCode(verificationCode, userInputCode); + public void compareCode(Long userId, String verificationCode) { + String correctCode = emailVerificationQuery.getCodeById(userId); + if (!correctCode.equals(verificationCode)) { + throw new InvalidInputException(INVALID_VERIFICATION_CODE, + String.format(WRONG_VERIFICATION_CODE_MESSAGE, userId, verificationCode)); + } } public PendingCertificationPageDto getUncertifiedUserRequests(Pageable pageable) { - Page pendingCertifications = certificationQuery.getPendingCertification( - pageable); - return PendingCertificationPageDto.from(pendingCertifications); + Page pendingCertification = + certificationQuery.getPendingCertification(pageable); + Page pendingCertificationPage = pendingCertification.map( + PendingCertificationDto::from); + return PendingCertificationPageDto.from(pendingCertificationPage); } } diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java index 7b59a245..1ff1650a 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertification( +public record PendingCertificationDto( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertification( String department ) { - public static PendingCertification from(Certification certification) { - return new PendingCertification( + public static PendingCertificationDto from(Certification certification) { + return new PendingCertificationDto( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 00062fab..82680d41 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -1,16 +1,13 @@ package coffeemeet.server.certification.service.dto; -import coffeemeet.server.certification.domain.Certification; import org.springframework.data.domain.Page; public record PendingCertificationPageDto( - Page page + Page page ) { - public static PendingCertificationPageDto from( - Page certificationPage - ) { - return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); + public static PendingCertificationPageDto from(Page page) { + return new PendingCertificationPageDto(page); } } diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 6c6d6f35..37158a41 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -35,7 +35,7 @@ import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; @@ -457,8 +457,8 @@ void getPendingCertificationsTest() throws Exception { Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); - Page page = pendingCertificationPageDto.page(); - AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( + Page page = pendingCertificationPageDto.page(); + AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( page.getContent(), page.hasNext()); given(certificationService.getUncertifiedUserRequests(any())).willReturn( diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index 8397bc08..ccc0c1bf 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -1,14 +1,15 @@ -package coffeemeet.server.common.fixture; +package coffeemeet.server.common.fixture.entity; -import static coffeemeet.server.common.fixture.UserFixture.users; +import static coffeemeet.server.common.fixture.entity.UserFixture.users; import static org.instancio.Select.field; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.domain.VerificationInfo; +import coffeemeet.server.certification.domain.EmailVerification; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -16,7 +17,6 @@ import org.instancio.internal.generator.domain.internet.EmailGenerator; import org.instancio.internal.generator.lang.IntegerGenerator; import org.instancio.internal.generator.net.URLGenerator; -import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -43,7 +43,7 @@ public static Certification certification(User user) { public static Certification certificatedCertification(User user, String companyName) { return Instancio.of(Certification.class) .generate(field(Certification::getBusinessCardUrl), gen -> gen.net().url().asString()) - .set(field(Certification::getCompanyEmail), new CompanyEmail(email())) + .set(field(Certification::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())) .set(field(Certification::getCompanyName), companyName) .set(field(Certification::getId), user.getId()) .set(field(Certification::getUser), user) @@ -51,16 +51,6 @@ public static Certification certificatedCertification(User user, String companyN .create(); } - public static Certification pendingCertification(User user) { - return Instancio.of(Certification.class) - .generate(field(Certification::getBusinessCardUrl), gen -> gen.net().url().asString()) - .set(field(Certification::getCompanyEmail), new CompanyEmail(email())) - .set(field(Certification::getId), user.getId()) - .set(field(Certification::getUser), user) - .set(field(Certification::isCertificated), false) - .create(); - } - public static List certificatedCertifications(List users, String companyName) { return users.stream() @@ -68,14 +58,18 @@ public static List certificatedCertifications(List users, .toList(); } - public static VerificationInfo emailVerification() { - return Instancio.of(VerificationInfo.class).set(field(VerificationInfo::getCompanyEmail), + public static List certifications() { + return users().stream().map(CertificationFixture::certification).toList(); + } + + public static EmailVerification emailVerification() { + return Instancio.of(EmailVerification.class).set(field(EmailVerification::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())).create(); } - public static VerificationInfo emailVerification(Long userId) { - return Instancio.of(VerificationInfo.class).set(field(VerificationInfo::getUserId), userId) - .set(field(VerificationInfo::getCompanyEmail), + public static EmailVerification emailVerification(Long userId) { + return Instancio.of(EmailVerification.class).set(field(EmailVerification::getUserId), userId) + .set(field(EmailVerification::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())).create(); } @@ -119,25 +113,21 @@ public static VerificationCodeHTTP.Request verificationCodeDtoRequest() { String.format("%06d", new IntegerGenerator().range(0, 999999).get())).create(); } - public static Pageable certificationPageable() { + public static Pageable pageable() { int page = 0; int size = new IntegerGenerator().range(1, 100).get(); return PageRequest.of(page, size, Sort.by("updatedAt").ascending()); } - public static Page pendingCertificationPage(int size) { - return new PageImpl<>(certificationsNotCertificated(size)); - } - - private static List certificationsNotCertificated(int size) { - List users = users(size); - return users.stream() - .map(CertificationFixture::pendingCertification) - .toList(); + public static PendingCertificationPageDto pendingCertificationPageDto(int size) { + return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); } - public static PendingCertificationPageDto pendingCertificationPageDto(int size) { - return PendingCertificationPageDto.from(pendingCertificationPage(size)); + private static List pendingCertifications(int size) { + return Instancio.ofList(PendingCertificationDto.class).size(size) + .generate(field(PendingCertificationDto::businessCardUrl), + gen -> gen.net().url().asString()) + .generate(field(PendingCertificationDto::companyEmail), gen -> gen.net().email()).create(); } } From 87d8082fae7d1ebc2a42cf44e2f072b08b03acd8 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 18:54:01 +0900 Subject: [PATCH 58/74] =?UTF-8?q?test:=20Fixture=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 도메인별로 픽스처 구분 --- .../server/common/fixture/CertificationFixture.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index ccc0c1bf..395252e2 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -1,6 +1,6 @@ -package coffeemeet.server.common.fixture.entity; +package coffeemeet.server.common.fixture; -import static coffeemeet.server.common.fixture.entity.UserFixture.users; +import static coffeemeet.server.common.fixture.UserFixture.users; import static org.instancio.Select.field; import coffeemeet.server.certification.domain.Certification; From ad129c49152608af8e2d91b0d80f057a0bf34d7b Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 59/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CertificationService.java | 6 ++-- ...tionDto.java => PendingCertification.java} | 6 ++-- .../dto/PendingCertificationPageDto.java | 4 +-- .../current/service/dto/ChattingDto.java | 29 ------------------- .../history/service/dto/ChattingHistory.java | 11 ++++++- .../common/fixture/CertificationFixture.java | 10 +++---- 6 files changed, 23 insertions(+), 43 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertificationDto.java => PendingCertification.java} (78%) delete mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 14468e6f..19f34f80 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -10,7 +10,7 @@ import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.execption.InvalidInputException; import coffeemeet.server.common.implement.EmailSender; @@ -101,8 +101,8 @@ public void compareCode(Long userId, String verificationCode) { public PendingCertificationPageDto getUncertifiedUserRequests(Pageable pageable) { Page pendingCertification = certificationQuery.getPendingCertification(pageable); - Page pendingCertificationPage = pendingCertification.map( - PendingCertificationDto::from); + Page pendingCertificationPage = pendingCertification.map( + PendingCertification::from); return PendingCertificationPageDto.from(pendingCertificationPage); } diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java index 1ff1650a..7b59a245 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertificationDto( +public record PendingCertification( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertificationDto( String department ) { - public static PendingCertificationDto from(Certification certification) { - return new PendingCertificationDto( + public static PendingCertification from(Certification certification) { + return new PendingCertification( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 82680d41..88c1c29f 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -3,10 +3,10 @@ import org.springframework.data.domain.Page; public record PendingCertificationPageDto( - Page page + Page page ) { - public static PendingCertificationPageDto from(Page page) { + public static PendingCertificationPageDto from(Page page) { return new PendingCertificationPageDto(page); } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java deleted file mode 100644 index 965a05a8..00000000 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package coffeemeet.server.chatting.current.service.dto; - -import coffeemeet.server.chatting.current.domain.ChattingMessage; -import coffeemeet.server.user.domain.User; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; - -public record ChattingDto( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt -) { - - public static ChattingDto of(User user, ChattingMessage chattingMessage) { - return new ChattingDto( - user.getId(), - chattingMessage.getId(), - user.getProfile().getNickname(), - chattingMessage.getMessage(), - user.getOauthInfo().getProfileImageUrl(), - chattingMessage.getCreatedAt() - ); - } - -} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java index a333d7c8..acb29989 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java @@ -1,11 +1,14 @@ package coffeemeet.server.chatting.history.service.dto; -import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.user.domain.User; import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; +<<<<<<<< HEAD:src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java public record ChattingHistory( +======== +public record ChattingMessageHistory( +>>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java Long userId, Long messageId, String nickname, @@ -15,9 +18,15 @@ public record ChattingHistory( LocalDateTime createdAt ) { +<<<<<<<< HEAD:src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java public static ChattingHistory of(User user, ChattingMessageHistory chattingMessageHistory) { return new ChattingHistory( +======== + public static ChattingMessageHistory of(User user, + coffeemeet.server.chatting.history.domain.ChattingMessageHistory chattingMessageHistory) { + return new ChattingMessageHistory( +>>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java user.getId(), chattingMessageHistory.getId(), user.getProfile().getNickname(), diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index 395252e2..03dcea6f 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -9,7 +9,7 @@ import coffeemeet.server.certification.domain.EmailVerification; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -123,11 +123,11 @@ public static PendingCertificationPageDto pendingCertificationPageDto(int size) return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); } - private static List pendingCertifications(int size) { - return Instancio.ofList(PendingCertificationDto.class).size(size) - .generate(field(PendingCertificationDto::businessCardUrl), + private static List pendingCertifications(int size) { + return Instancio.ofList(PendingCertification.class).size(size) + .generate(field(PendingCertification::businessCardUrl), gen -> gen.net().url().asString()) - .generate(field(PendingCertificationDto::companyEmail), gen -> gen.net().email()).create(); + .generate(field(PendingCertification::companyEmail), gen -> gen.net().email()).create(); } } From ebc3aa1aadc451da8e57e7da64d38ea6d232d8c4 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 20 Dec 2023 00:16:19 +0900 Subject: [PATCH 60/74] =?UTF-8?q?feat:=20ChattingDto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VO 와 Dto 로 분리 --- .../current/service/dto/ChattingDto.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java new file mode 100644 index 00000000..965a05a8 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java @@ -0,0 +1,29 @@ +package coffeemeet.server.chatting.current.service.dto; + +import coffeemeet.server.chatting.current.domain.ChattingMessage; +import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; + +public record ChattingDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + + public static ChattingDto of(User user, ChattingMessage chattingMessage) { + return new ChattingDto( + user.getId(), + chattingMessage.getId(), + user.getProfile().getNickname(), + chattingMessage.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessage.getCreatedAt() + ); + } + +} From a3aa96581a1bcbbba23a7ca046f5df89723f8b78 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:46:27 +0900 Subject: [PATCH 61/74] =?UTF-8?q?refactor:=20infra=20->=20domain=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/{implement => infrastructure}/ImageDeleter.java | 0 .../common/{implement => infrastructure}/ImageUploader.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/ImageDeleter.java (100%) rename src/main/java/coffeemeet/server/common/{implement => infrastructure}/ImageUploader.java (100%) diff --git a/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java b/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java similarity index 100% rename from src/main/java/coffeemeet/server/common/implement/ImageDeleter.java rename to src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java diff --git a/src/main/java/coffeemeet/server/common/implement/ImageUploader.java b/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java similarity index 100% rename from src/main/java/coffeemeet/server/common/implement/ImageUploader.java rename to src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java From 9188212a270bd64526a8e00217a54e626f4134e8 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:51:02 +0900 Subject: [PATCH 62/74] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/admin/presentation/AdminControllerTest.java | 3 --- .../concurrency/ChattingMessageServiceConcurrencyTest.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 37158a41..35586497 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -40,17 +40,14 @@ import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; import coffeemeet.server.common.fixture.InquiryFixture; -import coffeemeet.server.common.fixture.ReportFixture; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; -import coffeemeet.server.inquiry.service.dto.InquirySearchDto; import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; -import coffeemeet.server.report.service.dto.ReportSummary; import com.epages.restdocs.apispec.Schema; import java.util.List; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java index 51a2e7a8..3e88fb75 100644 --- a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java +++ b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java @@ -86,7 +86,7 @@ void chattingConcurrencyTest() throws InterruptedException { // then List messages = chattingMessageRepository.findAll(); - assertThat(messages).hasSize(userSize); + assertThat(messages).hasSize(count); } } From fc7a8f80848dd9cc8a37c411403b161b28d94bcb Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:55:19 +0900 Subject: [PATCH 63/74] =?UTF-8?q?refactor:=20facade=20=ED=8C=A8=ED=84=B4?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20Service=20=EA=B3=84=EC=B8=B5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CertificationService.java | 108 +++++++----------- 1 file changed, 41 insertions(+), 67 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 19f34f80..5c83737e 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,25 +1,20 @@ package coffeemeet.server.certification.service; -import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; -import static coffeemeet.server.common.domain.KeyType.BUSINESS_CARD; - import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; +import coffeemeet.server.certification.implement.BusinessCardImageDeleter; +import coffeemeet.server.certification.implement.BusinessCardImageUploader; import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.CertificationQuery; -import coffeemeet.server.certification.implement.EmailVerificationCommand; -import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertification; +import coffeemeet.server.certification.implement.CompanyEmailValidator; +import coffeemeet.server.certification.implement.VerificationCodeGenerator; +import coffeemeet.server.certification.implement.VerificationCodeValidator; +import coffeemeet.server.certification.implement.VerificationInfoCommand; +import coffeemeet.server.certification.implement.VerificationInfoQuery; +import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; -import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.common.implement.EmailSender; -import coffeemeet.server.common.implement.MediaManager; -import coffeemeet.server.common.util.FileUtils; -import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.implement.UserQuery; import java.io.File; -import java.util.random.RandomGenerator; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -29,81 +24,60 @@ @RequiredArgsConstructor public class CertificationService { - private static final String WRONG_VERIFICATION_CODE_MESSAGE = "사용자(%s)가 잘못된 인증코드(%s)를 입력했습니다."; - private static final RandomGenerator RANDOM_GENERATOR = RandomGenerator.getDefault(); - - private final MediaManager mediaManager; - private final EmailSender emailSender; - private final UserQuery userQuery; + private final BusinessCardImageUploader businessCardImageUploader; + private final BusinessCardImageDeleter businessCardImageDeleter; private final CertificationCommand certificationCommand; private final CertificationQuery certificationQuery; - private final EmailVerificationCommand emailVerificationCommand; - private final EmailVerificationQuery emailVerificationQuery; - - public void registerCertification(Long userId, String companyName, String email, + private final CompanyEmailValidator companyEmailValidator; + private final VerificationCodeGenerator verificationCodeGenerator; + private final VerificationCodeValidator verificationCodeValidator; + private final VerificationInfoQuery verificationInfoQuery; + private final VerificationInfoCommand verificationInfoCommand; + private final VerificationMailSender verificationMailSender; + + public void registerCertification(long userId, String companyName, String email, String departmentName, File businessCardImage) { - processCertification(userId, companyName, email, departmentName, businessCardImage, false); - } + CompanyEmail companyEmail = new CompanyEmail(email); + Department department = Department.valueOf(departmentName); - public void updateCertification(Long userId, String companyName, String email, - String departmentName, File businessCardImage) { - processCertification(userId, companyName, email, departmentName, businessCardImage, true); - } + String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage( + businessCardImage); - private void processCertification(Long userId, String companyName, String email, - String departmentName, File businessCardImage, boolean isUpdate) { - String key = mediaManager.generateKey(BUSINESS_CARD); - uploadBusinessCard(userId, key, businessCardImage); + certificationCommand.createCertification(userId, companyName, companyEmail, department, + businessCardImageUrl); + } + public void updateCertification(long userId, String companyName, String email, + String departmentName, File businessCardImage) { CompanyEmail companyEmail = new CompanyEmail(email); - String businessCardUrl = mediaManager.getUrl(key); Department department = Department.valueOf(departmentName); - User user = userQuery.getUserById(userId); - if (isUpdate) { - certificationCommand.deleteCertification(userId); - } - certificationCommand.createCertification(user, companyName, companyEmail, department, - businessCardUrl); - } - - private void uploadBusinessCard(Long userId, String key, File businessCardUrl) { - certificationCommand.applyIfCertifiedUser(userId, certification -> { - String oldKey = mediaManager.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD); - mediaManager.delete(oldKey); - }); + businessCardImageDeleter.deleteBusinessCardImageByUserId(userId); + String businessCardImageUrl = businessCardImageUploader.uploadBusinessCardImage( + businessCardImage); - mediaManager.upload(key, businessCardUrl); - FileUtils.delete(businessCardUrl); + certificationCommand.updateCertification(userId, companyName, companyEmail, department, + businessCardImageUrl); } public void sendVerificationMail(Long userId, String email) { CompanyEmail companyEmail = new CompanyEmail(email); - certificationCommand.hasDuplicatedCompanyEmail(companyEmail); + companyEmailValidator.validateDuplicatedCompanyEmail(companyEmail); - String verificationCode = generateVerificationCode(); - emailSender.sendVerificationCode(companyEmail, verificationCode); - emailVerificationCommand.createEmailVerification(userId, companyEmail, verificationCode); - } + String verificationCode = verificationCodeGenerator.generateVerificationCode(); + verificationMailSender.sendVerificationMail(companyEmail, verificationCode); - private String generateVerificationCode() { - return String.format("%06d", RANDOM_GENERATOR.nextInt(1000000)); + verificationInfoCommand.createVerificationInfo(userId, companyEmail, verificationCode); } - public void compareCode(Long userId, String verificationCode) { - String correctCode = emailVerificationQuery.getCodeById(userId); - if (!correctCode.equals(verificationCode)) { - throw new InvalidInputException(INVALID_VERIFICATION_CODE, - String.format(WRONG_VERIFICATION_CODE_MESSAGE, userId, verificationCode)); - } + public void compareCode(Long userId, String userInputCode) { + String verificationCode = verificationInfoQuery.getVerificationCodeById(userId); + verificationCodeValidator.validateVerificationCode(verificationCode, userInputCode); } public PendingCertificationPageDto getUncertifiedUserRequests(Pageable pageable) { - Page pendingCertification = - certificationQuery.getPendingCertification(pageable); - Page pendingCertificationPage = pendingCertification.map( - PendingCertification::from); - return PendingCertificationPageDto.from(pendingCertificationPage); + Page pendingCertifications = certificationQuery.getPendingCertification(pageable); + return PendingCertificationPageDto.from(pendingCertifications); } } From 9ab8b4c1461337e514dfc7e33c7e5964dea02293 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:55:53 +0900 Subject: [PATCH 64/74] =?UTF-8?q?feat:=20=EC=A0=95=EC=A0=81=20=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dto/PendingCertificationPageDto.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 88c1c29f..5e50906c 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -1,13 +1,15 @@ package coffeemeet.server.certification.service.dto; +import coffeemeet.server.certification.domain.Certification; import org.springframework.data.domain.Page; public record PendingCertificationPageDto( Page page ) { - public static PendingCertificationPageDto from(Page page) { - return new PendingCertificationPageDto(page); + public static PendingCertificationPageDto from( + Page certificationPage + ) { + return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); } - } From 93c280e6dfc675e846c07f5ff5a989c6d5be2c59 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:56:51 +0900 Subject: [PATCH 65/74] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/fixture/CertificationFixture.java | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index 03dcea6f..e2fd3367 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -6,7 +6,7 @@ import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.domain.EmailVerification; +import coffeemeet.server.certification.domain.VerificationInfo; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; import coffeemeet.server.certification.service.dto.PendingCertification; @@ -17,6 +17,7 @@ import org.instancio.internal.generator.domain.internet.EmailGenerator; import org.instancio.internal.generator.lang.IntegerGenerator; import org.instancio.internal.generator.net.URLGenerator; +import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -43,7 +44,7 @@ public static Certification certification(User user) { public static Certification certificatedCertification(User user, String companyName) { return Instancio.of(Certification.class) .generate(field(Certification::getBusinessCardUrl), gen -> gen.net().url().asString()) - .set(field(Certification::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())) + .set(field(Certification::getCompanyEmail), new CompanyEmail(email())) .set(field(Certification::getCompanyName), companyName) .set(field(Certification::getId), user.getId()) .set(field(Certification::getUser), user) @@ -51,6 +52,16 @@ public static Certification certificatedCertification(User user, String companyN .create(); } + public static Certification pendingCertification(User user) { + return Instancio.of(Certification.class) + .generate(field(Certification::getBusinessCardUrl), gen -> gen.net().url().asString()) + .set(field(Certification::getCompanyEmail), new CompanyEmail(email())) + .set(field(Certification::getId), user.getId()) + .set(field(Certification::getUser), user) + .set(field(Certification::isCertificated), false) + .create(); + } + public static List certificatedCertifications(List users, String companyName) { return users.stream() @@ -58,18 +69,14 @@ public static List certificatedCertifications(List users, .toList(); } - public static List certifications() { - return users().stream().map(CertificationFixture::certification).toList(); - } - - public static EmailVerification emailVerification() { - return Instancio.of(EmailVerification.class).set(field(EmailVerification::getCompanyEmail), + public static VerificationInfo emailVerification() { + return Instancio.of(VerificationInfo.class).set(field(VerificationInfo::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())).create(); } - public static EmailVerification emailVerification(Long userId) { - return Instancio.of(EmailVerification.class).set(field(EmailVerification::getUserId), userId) - .set(field(EmailVerification::getCompanyEmail), + public static VerificationInfo emailVerification(Long userId) { + return Instancio.of(VerificationInfo.class).set(field(VerificationInfo::getUserId), userId) + .set(field(VerificationInfo::getCompanyEmail), new CompanyEmail(new EmailGenerator().get())).create(); } @@ -113,12 +120,23 @@ public static VerificationCodeHTTP.Request verificationCodeDtoRequest() { String.format("%06d", new IntegerGenerator().range(0, 999999).get())).create(); } - public static Pageable pageable() { + public static Pageable certificationPageable() { int page = 0; int size = new IntegerGenerator().range(1, 100).get(); return PageRequest.of(page, size, Sort.by("updatedAt").ascending()); } + public static Page pendingCertificationPage(int size) { + return new PageImpl<>(certificationsNotCertificated(size)); + } + + private static List certificationsNotCertificated(int size) { + List users = users(size); + return users.stream() + .map(CertificationFixture::pendingCertification) + .toList(); + } + public static PendingCertificationPageDto pendingCertificationPageDto(int size) { return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); } From 1eb6670f3002ce721e87d8eeb9a15f6cd9b78556 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 15:33:42 +0900 Subject: [PATCH 66/74] =?UTF-8?q?refactor:=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔티티의 필드 타입에 맞게 Id 값의 타입은 Reference Type 사용 - 시간 또는 카운트 숫자의 데이터 경우 성능을 고려해서 Primitive Type 사용 --- .../server/certification/service/CertificationService.java | 4 ++-- .../concurrency/ChattingMessageServiceConcurrencyTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 5c83737e..59489431 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -35,7 +35,7 @@ public class CertificationService { private final VerificationInfoCommand verificationInfoCommand; private final VerificationMailSender verificationMailSender; - public void registerCertification(long userId, String companyName, String email, + public void registerCertification(Long userId, String companyName, String email, String departmentName, File businessCardImage) { CompanyEmail companyEmail = new CompanyEmail(email); Department department = Department.valueOf(departmentName); @@ -47,7 +47,7 @@ public void registerCertification(long userId, String companyName, String email, businessCardImageUrl); } - public void updateCertification(long userId, String companyName, String email, + public void updateCertification(Long userId, String companyName, String email, String departmentName, File businessCardImage) { CompanyEmail companyEmail = new CompanyEmail(email); Department department = Department.valueOf(departmentName); diff --git a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java index 3e88fb75..51a2e7a8 100644 --- a/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java +++ b/src/test/java/coffeemeet/server/chatting/concurrency/ChattingMessageServiceConcurrencyTest.java @@ -86,7 +86,7 @@ void chattingConcurrencyTest() throws InterruptedException { // then List messages = chattingMessageRepository.findAll(); - assertThat(messages).hasSize(count); + assertThat(messages).hasSize(userSize); } } From f6b10a6a46bf56ddecb899d376234c444a004eaa Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:59:05 +0900 Subject: [PATCH 67/74] =?UTF-8?q?refactor:=20certification=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/certification/service/CertificationService.java | 3 +++ ...ndingCertification.java => PendingCertificationDto.java} | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertification.java => PendingCertificationDto.java} (78%) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 59489431..98d5b951 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -13,6 +13,9 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; +import coffeemeet.server.certification.service.dto.PendingCertificationDto; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java index 7b59a245..1ff1650a 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertification( +public record PendingCertificationDto( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertification( String department ) { - public static PendingCertification from(Certification certification) { - return new PendingCertification( + public static PendingCertificationDto from(Certification certification) { + return new PendingCertificationDto( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), From 0d90e3e696cc823693e15f154d803c860d77c7aa Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 68/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CertificationService.java | 2 +- ...tionDto.java => PendingCertification.java} | 6 ++-- .../dto/PendingCertificationPageDto.java | 1 + .../current/service/dto/ChattingDto.java | 29 ------------------- 4 files changed, 5 insertions(+), 33 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertificationDto.java => PendingCertification.java} (78%) delete mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 98d5b951..7d9ee6a6 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -15,7 +15,7 @@ import coffeemeet.server.certification.implement.VerificationMailSender; import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java index 1ff1650a..7b59a245 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertificationDto( +public record PendingCertification( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertificationDto( String department ) { - public static PendingCertificationDto from(Certification certification) { - return new PendingCertificationDto( + public static PendingCertification from(Certification certification) { + return new PendingCertification( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java index 5e50906c..00062fab 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationPageDto.java @@ -12,4 +12,5 @@ public static PendingCertificationPageDto from( ) { return new PendingCertificationPageDto(certificationPage.map(PendingCertification::from)); } + } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java deleted file mode 100644 index 965a05a8..00000000 --- a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package coffeemeet.server.chatting.current.service.dto; - -import coffeemeet.server.chatting.current.domain.ChattingMessage; -import coffeemeet.server.user.domain.User; -import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; - -public record ChattingDto( - Long userId, - Long messageId, - String nickname, - String content, - String profileImageUrl, - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") - LocalDateTime createdAt -) { - - public static ChattingDto of(User user, ChattingMessage chattingMessage) { - return new ChattingDto( - user.getId(), - chattingMessage.getId(), - user.getProfile().getNickname(), - chattingMessage.getMessage(), - user.getOauthInfo().getProfileImageUrl(), - chattingMessage.getCreatedAt() - ); - } - -} From 5b918779eb99c035646721cdaf3eafae18d4e16d Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 08:56:51 +0900 Subject: [PATCH 69/74] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/CertificationRepositoryTest.java | 5 +++++ .../certification/implement/CertificationCommandTest.java | 7 +++++++ .../server/common/implement/EmailSenderTest.java | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index 6c01ce69..ec002d2c 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,5 +1,10 @@ package coffeemeet.server.certification.domain.repository; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; +import static coffeemeet.server.common.fixture.entity.UserFixture.users; +import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.UserFixture.user; diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index e4168d4a..ffdd5604 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,5 +1,12 @@ package coffeemeet.server.certification.implement; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; +import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 9df89765..64413aab 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,6 +1,9 @@ package coffeemeet.server.common.implement; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; +import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.CertificationFixture.email; +import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.then; @@ -23,7 +26,7 @@ @ExtendWith(MockitoExtension.class) class EmailSenderTest { - private EmailSender emailSender; + private coffeemeet.server.common.implement.EmailSender emailSender; @Mock private JavaMailSender javaMailSender; @@ -36,7 +39,7 @@ class EmailSenderTest { @BeforeEach void setUp() { sender = email(); - emailSender = new EmailSender(javaMailSender, sender); + emailSender = new coffeemeet.server.common.implement.EmailSender(javaMailSender, sender); } @Test From 7afe8bef511e0ab208f6659a4433fbb67d3d354a Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 10:59:53 +0900 Subject: [PATCH 70/74] =?UTF-8?q?refactor:=20=EC=BB=A8=ED=94=8C=EB=A6=AD?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{infrastructure => implement}/ImageDeleter.java | 0 .../{infrastructure => implement}/ImageUploader.java | 0 .../implement/CertificationCommandTest.java | 7 ------- .../server/common/fixture/CertificationFixture.java | 10 +--------- .../server/common/implement/EmailSenderTest.java | 7 ++----- 5 files changed, 3 insertions(+), 21 deletions(-) rename src/main/java/coffeemeet/server/common/{infrastructure => implement}/ImageDeleter.java (100%) rename src/main/java/coffeemeet/server/common/{infrastructure => implement}/ImageUploader.java (100%) diff --git a/src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java b/src/main/java/coffeemeet/server/common/implement/ImageDeleter.java similarity index 100% rename from src/main/java/coffeemeet/server/common/infrastructure/ImageDeleter.java rename to src/main/java/coffeemeet/server/common/implement/ImageDeleter.java diff --git a/src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java b/src/main/java/coffeemeet/server/common/implement/ImageUploader.java similarity index 100% rename from src/main/java/coffeemeet/server/common/infrastructure/ImageUploader.java rename to src/main/java/coffeemeet/server/common/implement/ImageUploader.java diff --git a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java index ffdd5604..e4168d4a 100644 --- a/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/implement/CertificationCommandTest.java @@ -1,12 +1,5 @@ package coffeemeet.server.certification.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.businessCardUrl; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyName; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.pendingCertification; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.fixture.CertificationFixture.businessCardUrl; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; diff --git a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java index e2fd3367..8397bc08 100644 --- a/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/CertificationFixture.java @@ -9,7 +9,6 @@ import coffeemeet.server.certification.domain.VerificationInfo; import coffeemeet.server.certification.presentation.dto.EmailHTTP; import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -138,14 +137,7 @@ private static List certificationsNotCertificated(int size) { } public static PendingCertificationPageDto pendingCertificationPageDto(int size) { - return PendingCertificationPageDto.from(new PageImpl<>(pendingCertifications(size))); - } - - private static List pendingCertifications(int size) { - return Instancio.ofList(PendingCertification.class).size(size) - .generate(field(PendingCertification::businessCardUrl), - gen -> gen.net().url().asString()) - .generate(field(PendingCertification::companyEmail), gen -> gen.net().email()).create(); + return PendingCertificationPageDto.from(pendingCertificationPage(size)); } } diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 64413aab..9df89765 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,9 +1,6 @@ package coffeemeet.server.common.implement; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; -import static coffeemeet.server.common.fixture.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.CertificationFixture.email; -import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.then; @@ -26,7 +23,7 @@ @ExtendWith(MockitoExtension.class) class EmailSenderTest { - private coffeemeet.server.common.implement.EmailSender emailSender; + private EmailSender emailSender; @Mock private JavaMailSender javaMailSender; @@ -39,7 +36,7 @@ class EmailSenderTest { @BeforeEach void setUp() { sender = email(); - emailSender = new coffeemeet.server.common.implement.EmailSender(javaMailSender, sender); + emailSender = new EmailSender(javaMailSender, sender); } @Test From d5e9278ce75ba5b689bdc2ca623f0a8535e31c53 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Mon, 18 Dec 2023 16:59:05 +0900 Subject: [PATCH 71/74] =?UTF-8?q?refactor:=20certification=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ndingCertification.java => PendingCertificationDto.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertification.java => PendingCertificationDto.java} (78%) diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java index 7b59a245..1ff1650a 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertification( +public record PendingCertificationDto( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertification( String department ) { - public static PendingCertification from(Certification certification) { - return new PendingCertification( + public static PendingCertificationDto from(Certification certification) { + return new PendingCertificationDto( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), From 214a054c67efe4721e7cf51360e57f16c1f508a5 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 72/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ndingCertificationDto.java => PendingCertification.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/main/java/coffeemeet/server/certification/service/dto/{PendingCertificationDto.java => PendingCertification.java} (78%) diff --git a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java rename to src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java index 1ff1650a..7b59a245 100644 --- a/src/main/java/coffeemeet/server/certification/service/dto/PendingCertificationDto.java +++ b/src/main/java/coffeemeet/server/certification/service/dto/PendingCertification.java @@ -2,7 +2,7 @@ import coffeemeet.server.certification.domain.Certification; -public record PendingCertificationDto( +public record PendingCertification( Long certificationId, String nickname, String companyName, @@ -11,8 +11,8 @@ public record PendingCertificationDto( String department ) { - public static PendingCertificationDto from(Certification certification) { - return new PendingCertificationDto( + public static PendingCertification from(Certification certification) { + return new PendingCertification( certification.getId(), certification.getUser().getProfile().getNickname(), certification.getCompanyName(), From 2a3471876a6410f4d891e4c8eeb9d9f846e27cf6 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Tue, 19 Dec 2023 23:25:27 +0900 Subject: [PATCH 73/74] =?UTF-8?q?refactor:=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/admin/presentation/AdminController.java | 6 +++--- .../server/admin/presentation/AdminControllerTest.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 29679af7..502dd11f 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -10,7 +10,7 @@ import coffeemeet.server.admin.presentation.dto.UserPunishmentHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.annotation.PerformanceMeasurement; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; @@ -203,7 +203,7 @@ public ResponseEntity checkInquiry( // TODO: 11/27/23 임시로 페이징(옵셋 기반) 처리, 개선 필요 @PerformanceMeasurement @GetMapping("/certifications/pending") - public ResponseEntity> getPendingCertifications( + public ResponseEntity> getPendingCertifications( @SessionAttribute(name = ADMIN_SESSION_ATTRIBUTE, required = false) String adminId, @RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int size @@ -217,7 +217,7 @@ public ResponseEntity> getPendingCertif PendingCertificationPageDto uncertifiedUserRequests = certificationService.getUncertifiedUserRequests( pageable); - Page page = uncertifiedUserRequests.page(); + Page page = uncertifiedUserRequests.page(); return ResponseEntity.ok( AdminCustomPage.of(page.getContent(), page.hasNext()) ); diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 35586497..b3fcb7a0 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -35,7 +35,7 @@ import coffeemeet.server.admin.presentation.dto.ReportDetailHTTP; import coffeemeet.server.admin.service.AdminService; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.certification.service.dto.PendingCertificationDto; +import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; @@ -454,8 +454,8 @@ void getPendingCertificationsTest() throws Exception { Pageable pageable = certificationPageable(); PendingCertificationPageDto pendingCertificationPageDto = pendingCertificationPageDto( pageable.getPageSize()); - Page page = pendingCertificationPageDto.page(); - AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( + Page page = pendingCertificationPageDto.page(); + AdminCustomPage pendingCertificationAdminCustomPage = AdminCustomPage.of( page.getContent(), page.hasNext()); given(certificationService.getUncertifiedUserRequests(any())).willReturn( From 41a0c860a913f515874afd44c6dcefac5489e6bb Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 20 Dec 2023 21:47:52 +0900 Subject: [PATCH 74/74] =?UTF-8?q?refactor:=20=EC=BB=A8=ED=94=8C=EB=A6=AD?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CertificationService.java | 6 ++-- .../current/service/dto/ChattingDto.java | 29 +++++++++++++++ .../history/service/dto/ChattingHistory.java | 12 +------ .../report/service/dto/ReportSummary.java | 35 ++++++++----------- .../presentation/AdminControllerTest.java | 6 +++- .../CertificationRepositoryTest.java | 5 --- .../service/CertificationServiceTest.java | 1 + .../service/ChattingMessageServiceTest.java | 1 + 8 files changed, 53 insertions(+), 42 deletions(-) create mode 100644 src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 7d9ee6a6..12fe9612 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -13,9 +13,6 @@ import coffeemeet.server.certification.implement.VerificationInfoCommand; import coffeemeet.server.certification.implement.VerificationInfoQuery; import coffeemeet.server.certification.implement.VerificationMailSender; -import coffeemeet.server.certification.implement.EmailVerificationCommand; -import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.certification.service.dto.PendingCertification; import coffeemeet.server.certification.service.dto.PendingCertificationPageDto; import java.io.File; import lombok.RequiredArgsConstructor; @@ -79,7 +76,8 @@ public void compareCode(Long userId, String userInputCode) { } public PendingCertificationPageDto getUncertifiedUserRequests(Pageable pageable) { - Page pendingCertifications = certificationQuery.getPendingCertification(pageable); + Page pendingCertifications = certificationQuery.getPendingCertification( + pageable); return PendingCertificationPageDto.from(pendingCertifications); } diff --git a/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java new file mode 100644 index 00000000..965a05a8 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/current/service/dto/ChattingDto.java @@ -0,0 +1,29 @@ +package coffeemeet.server.chatting.current.service.dto; + +import coffeemeet.server.chatting.current.domain.ChattingMessage; +import coffeemeet.server.user.domain.User; +import com.fasterxml.jackson.annotation.JsonFormat; +import java.time.LocalDateTime; + +public record ChattingDto( + Long userId, + Long messageId, + String nickname, + String content, + String profileImageUrl, + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + LocalDateTime createdAt +) { + + public static ChattingDto of(User user, ChattingMessage chattingMessage) { + return new ChattingDto( + user.getId(), + chattingMessage.getId(), + user.getProfile().getNickname(), + chattingMessage.getMessage(), + user.getOauthInfo().getProfileImageUrl(), + chattingMessage.getCreatedAt() + ); + } + +} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java index acb29989..7157cf6c 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java @@ -4,11 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; -<<<<<<<< HEAD:src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java public record ChattingHistory( -======== -public record ChattingMessageHistory( ->>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java Long userId, Long messageId, String nickname, @@ -18,15 +14,9 @@ >>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/c LocalDateTime createdAt ) { -<<<<<<<< HEAD:src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistory.java public static ChattingHistory of(User user, - ChattingMessageHistory chattingMessageHistory) { - return new ChattingHistory( -======== - public static ChattingMessageHistory of(User user, coffeemeet.server.chatting.history.domain.ChattingMessageHistory chattingMessageHistory) { - return new ChattingMessageHistory( ->>>>>>>> e82e9257 (refactor: 네이밍 변경):src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistory.java + return new ChattingHistory( user.getId(), chattingMessageHistory.getId(), user.getProfile().getNickname(), diff --git a/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java index 19bb1afa..a9978c70 100644 --- a/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java +++ b/src/main/java/coffeemeet/server/report/service/dto/ReportSummary.java @@ -1,34 +1,27 @@ package coffeemeet.server.report.service.dto; +import coffeemeet.server.chatting.current.domain.ChattingRoom; +import coffeemeet.server.user.domain.User; import com.fasterxml.jackson.annotation.JsonFormat; - -<<<<<<<>>>>>>>e82e9257(refactor:네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java String targetedNickname, String chattingRoomName, Long targetedId, Long chattingRoomId, -@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") LocalDateTime createdAt - ){ +) { - <<<<<<<>>>>>>>e82e9257(refactor:네이밍 변경):src/main/java/coffeemeet/server/report/service/dto/Report.java - targeted.getProfile().getNickname(), - chattingRoom.getName(), - targeted.getId(), - chattingRoom.getId(), - targeted.getCreatedAt() - ); + public static ReportSummary of(User targeted, ChattingRoom chattingRoom) { + return new ReportSummary( + targeted.getProfile().getNickname(), + chattingRoom.getName(), + targeted.getId(), + chattingRoom.getId(), + targeted.getCreatedAt() + ); } - } +} diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index b3fcb7a0..653a2c65 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -5,6 +5,7 @@ import static coffeemeet.server.common.fixture.AdminFixture.reportRejectionHTTPRequest; import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertificationPageDto; +import static coffeemeet.server.common.fixture.ReportFixture.reportListDto; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; import static org.mockito.ArgumentMatchers.any; @@ -40,14 +41,17 @@ import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AdminFixture; import coffeemeet.server.common.fixture.InquiryFixture; +import coffeemeet.server.common.fixture.ReportFixture; import coffeemeet.server.inquiry.presentation.dto.InquiryDetailHTTP; import coffeemeet.server.inquiry.service.InquiryService; import coffeemeet.server.inquiry.service.dto.InquiryDetailDto; +import coffeemeet.server.inquiry.service.dto.InquirySearchDto; import coffeemeet.server.inquiry.service.dto.InquirySummary; import coffeemeet.server.report.service.ReportService; import coffeemeet.server.report.service.dto.GroupReportDto; import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; +import coffeemeet.server.report.service.dto.ReportSummary; import com.epages.restdocs.apispec.Schema; import java.util.List; import org.junit.jupiter.api.DisplayName; @@ -234,7 +238,7 @@ void findAllReportsTest() throws Exception { // given Long lastReportId = 0L; int pageSize = 10; - ReportListDto reportListDto = ReportFixture.reportListDto(); + ReportListDto reportListDto = reportListDto(); AdminCustomPage result = new AdminCustomPage<>(reportListDto.contents(), reportListDto.hasNext()); diff --git a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java index ec002d2c..6c01ce69 100644 --- a/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/domain/repository/CertificationRepositoryTest.java @@ -1,10 +1,5 @@ package coffeemeet.server.certification.domain.repository; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; -import static coffeemeet.server.common.fixture.entity.CertificationFixture.certificationPageable; -import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.fixture.entity.UserFixture.users; -import static coffeemeet.server.common.fixture.entity.UserFixture.usersWithNullId; import static coffeemeet.server.common.fixture.CertificationFixture.certification; import static coffeemeet.server.common.fixture.CertificationFixture.certificationPageable; import static coffeemeet.server.common.fixture.UserFixture.user; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index bb7df334..e6e0a428 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -7,6 +7,7 @@ import static coffeemeet.server.common.fixture.CertificationFixture.email; import static coffeemeet.server.common.fixture.CertificationFixture.pendingCertificationPage; import static coffeemeet.server.common.fixture.CertificationFixture.verificationCode; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java index d6c2a2d1..59e2d100 100644 --- a/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/current/service/ChattingMessageServiceTest.java @@ -4,6 +4,7 @@ import static coffeemeet.server.common.fixture.ChattingFixture.chattingRoom; import static coffeemeet.server.common.fixture.UserFixture.fourUsers; import static coffeemeet.server.common.fixture.UserFixture.user; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.BDDMockito.given;