From 39f30596f91d4506e4c4579f8879b19515e885b9 Mon Sep 17 00:00:00 2001 From: hgh1472 Date: Sun, 8 Dec 2024 16:57:05 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8B=A0=EA=B3=A0=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=BB=B4=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../complaint/domain/ComplaintsTest.java | 6 ++- .../infra/KeywordComplaintRepositoryTest.java | 6 +-- .../infra/MapComplaintRepositoryTest.java | 6 +-- .../service/ComplaintServiceTest.java | 49 ++++++++++--------- src/test/resources/application.yml | 43 ++++++++++++++++ 5 files changed, 78 insertions(+), 32 deletions(-) diff --git a/src/test/java/postman/bottler/complaint/domain/ComplaintsTest.java b/src/test/java/postman/bottler/complaint/domain/ComplaintsTest.java index 1b115ce9..f38ab757 100644 --- a/src/test/java/postman/bottler/complaint/domain/ComplaintsTest.java +++ b/src/test/java/postman/bottler/complaint/domain/ComplaintsTest.java @@ -13,9 +13,11 @@ public class ComplaintsTest { @DisplayName("한 편지의 신고자가 2명일 경우, DuplicateComplainException 예외를 발생시킨다.") public void duplicateException() { // GIVEN - Complaints complaints = Complaints.from(List.of(KeywordComplaint.create(1L, 1L, "욕설 사용"))); + Complaint complaint = Complaint.create(1L, 1L, "욕설 사용"); + Complaint duplicate = Complaint.create(1L, 1L, "욕설 사용"); + Complaints complaints = Complaints.from(List.of(complaint)); // WHEN - THEN - assertThatThrownBy(() -> complaints.validateDuplication(1L)).isInstanceOf(DuplicateComplainException.class); + assertThatThrownBy(() -> complaints.add(duplicate)).isInstanceOf(DuplicateComplainException.class); } } diff --git a/src/test/java/postman/bottler/complaint/infra/KeywordComplaintRepositoryTest.java b/src/test/java/postman/bottler/complaint/infra/KeywordComplaintRepositoryTest.java index 127f0698..4f5ede34 100644 --- a/src/test/java/postman/bottler/complaint/infra/KeywordComplaintRepositoryTest.java +++ b/src/test/java/postman/bottler/complaint/infra/KeywordComplaintRepositoryTest.java @@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; +import postman.bottler.complaint.domain.Complaint; import postman.bottler.complaint.domain.Complaints; -import postman.bottler.complaint.domain.KeywordComplaint; import postman.bottler.complaint.service.KeywordComplaintRepository; @DisplayName("키워드 신고 리포지토리 테스트") @@ -21,12 +21,12 @@ public class KeywordComplaintRepositoryTest { @DisplayName("편지 ID로 찾은 신고 객체들은 mutable이어야 한다.") public void mutable() { // GIVEN - keywordComplaintRepository.save(KeywordComplaint.create(1L, 1L, "설명")); + keywordComplaintRepository.save(Complaint.create(1L, 1L, "설명")); // WHEN Complaints find = keywordComplaintRepository.findByLetterId(1L); // THEN - Assertions.assertDoesNotThrow(() -> find.add(KeywordComplaint.create(1L, 1L, "설명"))); + Assertions.assertDoesNotThrow(() -> find.add(Complaint.create(1L, 1L, "설명"))); } } diff --git a/src/test/java/postman/bottler/complaint/infra/MapComplaintRepositoryTest.java b/src/test/java/postman/bottler/complaint/infra/MapComplaintRepositoryTest.java index b1fd8f9b..dc20c5b7 100644 --- a/src/test/java/postman/bottler/complaint/infra/MapComplaintRepositoryTest.java +++ b/src/test/java/postman/bottler/complaint/infra/MapComplaintRepositoryTest.java @@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; +import postman.bottler.complaint.domain.Complaint; import postman.bottler.complaint.domain.Complaints; -import postman.bottler.complaint.domain.MapComplaint; import postman.bottler.complaint.service.MapComplaintRepository; @DisplayName("지도 편지 리포지토리 테스트") @@ -21,12 +21,12 @@ public class MapComplaintRepositoryTest { @DisplayName("편지 ID로 찾은 신고 객체들은 mutable이어야 한다.") public void mutable() { // GIVEN - mapComplaintRepository.save(MapComplaint.create(1L, 1L, "설명")); + mapComplaintRepository.save(Complaint.create(1L, 1L, "설명")); // WHEN Complaints find = mapComplaintRepository.findByLetterId(1L); // THEN - Assertions.assertDoesNotThrow(() -> find.add(MapComplaint.create(1L, 1L, "설명"))); + Assertions.assertDoesNotThrow(() -> find.add(Complaint.create(1L, 1L, "설명"))); } } diff --git a/src/test/java/postman/bottler/complaint/service/ComplaintServiceTest.java b/src/test/java/postman/bottler/complaint/service/ComplaintServiceTest.java index db83a66b..590fdc8c 100644 --- a/src/test/java/postman/bottler/complaint/service/ComplaintServiceTest.java +++ b/src/test/java/postman/bottler/complaint/service/ComplaintServiceTest.java @@ -4,6 +4,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; +import static postman.bottler.complaint.domain.ComplaintType.KEYWORD_LETTER; +import static postman.bottler.complaint.domain.ComplaintType.KEYWORD_REPLY_LETTER; +import static postman.bottler.complaint.domain.ComplaintType.MAP_LETTER; +import static postman.bottler.complaint.domain.ComplaintType.MAP_REPLY_LETTER; import java.time.LocalDateTime; import java.util.ArrayList; @@ -14,11 +18,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import postman.bottler.complaint.domain.Complaint; import postman.bottler.complaint.domain.Complaints; -import postman.bottler.complaint.domain.KeywordComplaint; -import postman.bottler.complaint.domain.KeywordReplyComplaint; -import postman.bottler.complaint.domain.MapComplaint; -import postman.bottler.complaint.domain.MapReplyComplaint; import postman.bottler.complaint.dto.response.ComplaintResponseDTO; import postman.bottler.complaint.exception.DuplicateComplainException; @@ -42,10 +43,10 @@ public void complainKeywordLetter() { // GIVEN when(keywordComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())); when(keywordComplaintRepository.save(any())).thenReturn( - KeywordComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); + Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); // WHEN - ComplaintResponseDTO response = complaintService.complainKeywordLetter(1L, 1L, "욕설 사용"); + ComplaintResponseDTO response = complaintService.complain(KEYWORD_LETTER, 1L, 1L, "욕설 사용"); // THEN assertThat(response.id()).isEqualTo(1L); @@ -55,14 +56,14 @@ public void complainKeywordLetter() { @DisplayName("같은 키워드 편지를 2회 이상 신고 시도할 경우, DuplicateComplainException을 발생시킨다.") public void duplicateKeywordComplain() { // GIVEN - KeywordComplaint complaint = KeywordComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); + Complaint complaint = Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); when(keywordComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())) .thenReturn(Complaints.from(List.of(complaint))); when(keywordComplaintRepository.save(any())).thenReturn(complaint); - complaintService.complainKeywordLetter(1L, 1L, "욕설 사용"); + complaintService.complain(KEYWORD_LETTER, 1L, 1L, "욕설 사용"); // WHEN - THEN - assertThatThrownBy(() -> complaintService.complainKeywordLetter(1L, 1L, "욕설 사용")) + assertThatThrownBy(() -> complaintService.complain(KEYWORD_LETTER, 1L, 1L, "욕설 사용")) .isInstanceOf(DuplicateComplainException.class); } @@ -71,10 +72,10 @@ public void duplicateKeywordComplain() { public void complainMapLetter() { // GIVEN when(mapComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())); - when(mapComplaintRepository.save(any())).thenReturn(MapComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); + when(mapComplaintRepository.save(any())).thenReturn(Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); // WHEN - ComplaintResponseDTO response = complaintService.complainMapLetter(1L, 1L, "욕설 사용"); + ComplaintResponseDTO response = complaintService.complain(MAP_LETTER, 1L, 1L, "욕설 사용"); // THEN assertThat(response.id()).isEqualTo(1L); @@ -84,14 +85,14 @@ public void complainMapLetter() { @DisplayName("같은 지도 편지를 2회 이상 신고 시도할 경우, DuplicateComplainException을 발생시킨다.") public void duplicateMapComplain() { // GIVEN - MapComplaint complaint = MapComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); + Complaint complaint = Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); when(mapComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())) .thenReturn(Complaints.from(List.of(complaint))); when(mapComplaintRepository.save(any())).thenReturn(complaint); - complaintService.complainMapLetter(1L, 1L, "욕설 사용"); + complaintService.complain(MAP_LETTER, 1L, 1L, "욕설 사용"); // WHEN - THEN - assertThatThrownBy(() -> complaintService.complainMapLetter(1L, 1L, "욕설 사용")) + assertThatThrownBy(() -> complaintService.complain(MAP_LETTER, 1L, 1L, "욕설 사용")) .isInstanceOf(DuplicateComplainException.class); } @@ -101,10 +102,10 @@ public void complainKeywordReplyLetter() { // GIVEN when(keywordReplyComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())); when(keywordReplyComplaintRepository.save(any())).thenReturn( - KeywordReplyComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); + Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); // WHEN - ComplaintResponseDTO response = complaintService.complainKeywordReplyLetter(1L, 1L, "욕설 사용"); + ComplaintResponseDTO response = complaintService.complain(KEYWORD_REPLY_LETTER, 1L, 1L, "욕설 사용"); // THEN assertThat(response.id()).isEqualTo(1L); @@ -114,14 +115,14 @@ public void complainKeywordReplyLetter() { @DisplayName("같은 답장 편지를 2회 이상 신고 시도할 경우, DuplicateComplainException을 발생시킨다.") public void duplicateKeywordReplyComplain() { // GIVEN - KeywordReplyComplaint complaint = KeywordReplyComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); + Complaint complaint = Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); when(keywordReplyComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())) .thenReturn(Complaints.from(List.of(complaint))); when(keywordReplyComplaintRepository.save(any())).thenReturn(complaint); - complaintService.complainKeywordReplyLetter(1L, 1L, "욕설 사용"); + complaintService.complain(KEYWORD_REPLY_LETTER, 1L, 1L, "욕설 사용"); // WHEN - THEN - assertThatThrownBy(() -> complaintService.complainKeywordReplyLetter(1L, 1L, "욕설 사용")) + assertThatThrownBy(() -> complaintService.complain(KEYWORD_REPLY_LETTER, 1L, 1L, "욕설 사용")) .isInstanceOf(DuplicateComplainException.class); } @@ -131,10 +132,10 @@ public void complainMapReplyLetter() { // GIVEN when(mapReplyComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())); when(mapReplyComplaintRepository.save(any())).thenReturn( - MapReplyComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); + Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now())); // WHEN - ComplaintResponseDTO response = complaintService.complainMapReplyLetter(1L, 1L, "욕설 사용"); + ComplaintResponseDTO response = complaintService.complain(MAP_REPLY_LETTER, 1L, 1L, "욕설 사용"); // THEN assertThat(response.id()).isEqualTo(1L); @@ -144,14 +145,14 @@ public void complainMapReplyLetter() { @DisplayName("같은 답장 편지를 2회 이상 신고 시도할 경우, DuplicateComplainException을 발생시킨다.") public void duplicateMapReplyComplain() { // GIVEN - MapReplyComplaint complaint = MapReplyComplaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); + Complaint complaint = Complaint.of(1L, 1L, 1L, "욕설사용", LocalDateTime.now()); when(mapReplyComplaintRepository.findByLetterId(1L)).thenReturn(Complaints.from(new ArrayList<>())) .thenReturn(Complaints.from(List.of(complaint))); when(mapReplyComplaintRepository.save(any())).thenReturn(complaint); - complaintService.complainMapReplyLetter(1L, 1L, "욕설 사용"); + complaintService.complain(MAP_REPLY_LETTER, 1L, 1L, "욕설 사용"); // WHEN - THEN - assertThatThrownBy(() -> complaintService.complainMapReplyLetter(1L, 1L, "욕설 사용")) + assertThatThrownBy(() -> complaintService.complain(MAP_REPLY_LETTER, 1L, 1L, "욕설 사용")) .isInstanceOf(DuplicateComplainException.class); } } diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 7d206dce..ed3e6526 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -14,6 +14,49 @@ spring: host: ${REDIS_HOST} port: ${REDIS_PORT} +logging: + level: + org.springframework.jdbc.core.JdbcTemplate: DEBUG + org.springframework.jdbc.core.StatementCreatorUtils: TRACE + + fcm: private-key: ${BOTTLER_FCM_BASE64} +jwt: + secret: ${JWT_SECRET_KEY} # JWT 비밀 키 + access: + token: + expiration: 1800000 # 액세스 토큰 유효 시간 (30분) + # expiration: 10000 # 액세스 토큰 유효 시간 (10초) + refresh: + token: + expiration: 604800000 # 리프레시 토큰 유효 시간 (7일) + +mail: + host: smtp.gmail.com + port: 587 + username: ${EMAIL_USER_NAME} + password: ${EMAIL_PASSWORD} + properties: + mail: + smtp: + auth: true + starttls: + enable: true + required: true + connectiontimeout: 5000 + timeout: 5000 + writetimeout: 5000 + +kakao: + client: + id: ${KAKAO_CLIENT_ID} + secret: ${KAKAO_CLIENT_SECRET} + redirect: + url: ${KAKAO_REDIRECT_URL} + +slack: + token: ${SLACK_TOKEN} + +