diff --git a/.dockerignore b/.dockerignore
index 22aacdec..a94e11df 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -19,3 +19,6 @@ Dockerfile
# 깃허브 파일
.github/
+
+# README.md 전용 동영상
+video/
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..5f9b1ec3
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+*.gif filter=lfs diff=lfs merge=lfs -text
+*.png filter=lfs diff=lfs merge=lfs -text
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d270e348..99745631 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -60,7 +60,23 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Check Dockerfile or Dependency Changes
+ id: check_changes
+ run: |
+ git fetch origin ${{ github.event.before }}
+ echo "Changed files between commits:"
+ changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
+ echo "$changed_files"
+
+ if echo "$changed_files" | grep -qE 'Dockerfile|build\.gradle|settings\.gradle|gradle\.properties|gradlew|gradle/wrapper/gradle-wrapper\.properties'; then
+ echo "changed=true" >> $GITHUB_ENV
+ else
+ echo "changed=false" >> $GITHUB_ENV
+ fi
+
- name: Build & Push Dependency Cache
+ if: env.changed == 'true'
run: |
docker buildx build \
--builder mybuilder \
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..59e7c2bf
--- /dev/null
+++ b/README.md
@@ -0,0 +1,186 @@
+# 👗 Clokey: 스마트한 옷장 관리 서비스 (1.0 Legacy)
+
+
+
+
+
+👕 당신만을 위한 스마트한 옷장 관리 서비스, Clokey 입니다.
+
+
+ 나의 옷장을 등록해서 관리하고 남들과 마음껏 공유해보세요!
+
+
+
+ - 2025년 5월부터 iOS 앱스토어에서 서비스 중입니다!
+ - 아래 링크에서 새로워진 Clokey 2.0을 만나보세요!
+
+
+
+ 🔗 Clokey 2.0 Repository
+ 📲 앱 스토어에서 Clokey 만나보기
+
+
+
+🧑💻 Clokey Backend Team
+
+
+
+
+
+
+# Clokey 기능들의 작동 영상을 확인해 보세요!
+
+
+ 🏠 홈화면
+
+
+
+
+
+
+ ✔️ 주요 기능
+ - 날씨 기반 옷 추천
+ - 친구 Recap 확인
+ - 해시태그 기반 소식 피드
+
+
+
+
+
+ 📅 캘린더
+
+
+
+
+
+
+ ✔️ 주요 기능
+ - OOTD 캘린더 등록
+ - 월별 옷 기록 정리
+ - 날짜별 코디 확인
+
+
+
+
+
+ ➕ 옷 추가
+
+
+
+
+
+
+ ✔️ 주요 기능
+ - AI 기반 옷 분류
+ - 두께감/온도 정보 입력
+ - 브랜드 및 상품 정보 등록
+
+
+
+
+
+ 👕 내 옷장
+
+
+
+
+
+
+ ✔️ 주요 기능
+ - 옷장 등록 및 조회
+ - 카테고리별 필터링
+ - 사진 기반 정렬
+
+
+
+
+
+ 👤 내 프로필
+
+
+
+
+
+
+ ✔️ 주요 기능
+ - 프로필 이미지 및 소개 설정
+ - 코디 수/좋아요 수 통계
+
+
+
+
+
+ 🔍 검색 기능
+
+
+
+
+
+
+ ✔️ 주요 기능
+ - 친구 닉네임 검색
+ - 해시태그 기반 탐색
+ - 인기 사용자 확인
+
+
+
+# 🚀 Service Architecture
+
+
+
+
+# 🔧 Tech Stack
+
+### Language & Framework
+
+  
+ 
+
+
+### Database
+
+
+
+
+
+### DevOps
+     
+  
+
+
+# 🎨 ERD
+
+
+
+
diff --git a/src/test/java/com/clokey/server/domain/JpaIntegrationTestSupport.java b/src/test/java/com/clokey/server/domain/JpaIntegrationTestSupport.java
deleted file mode 100644
index a32cfc34..00000000
--- a/src/test/java/com/clokey/server/domain/JpaIntegrationTestSupport.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.clokey.server.domain;
-
-import com.clokey.server.global.config.QuerydslConfig;
-import org.junit.jupiter.api.Disabled;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.context.annotation.Import;
-import org.springframework.test.context.ActiveProfiles;
-
-@Disabled
-@DataJpaTest
-@ActiveProfiles("test")
-@Import(QuerydslConfig.class)
-public abstract class JpaIntegrationTestSupport {
-}
diff --git a/src/test/java/com/clokey/server/domain/SpringIntegrationTestSupport.java b/src/test/java/com/clokey/server/domain/SpringIntegrationTestSupport.java
deleted file mode 100644
index f43ea9a3..00000000
--- a/src/test/java/com/clokey/server/domain/SpringIntegrationTestSupport.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.clokey.server.domain;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.transaction.annotation.Transactional;
-
-@SpringBootTest
-@Transactional(readOnly = true)
-@ActiveProfiles("test")
-public abstract class SpringIntegrationTestSupport {
-}
diff --git a/src/test/java/com/clokey/server/domain/WebMvcIntegrationTestSupport.java b/src/test/java/com/clokey/server/domain/WebMvcIntegrationTestSupport.java
deleted file mode 100644
index 485721d0..00000000
--- a/src/test/java/com/clokey/server/domain/WebMvcIntegrationTestSupport.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.clokey.server.domain;
-
-import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-
-@WebMvcTest(controllers = {
- // 여기에 추가하세요
-})
-public abstract class WebMvcIntegrationTestSupport {
-}
diff --git a/src/test/java/com/clokey/server/domain/history/application/HistoryCreateTest.java b/src/test/java/com/clokey/server/domain/history/application/HistoryCreateTest.java
deleted file mode 100644
index dc36470a..00000000
--- a/src/test/java/com/clokey/server/domain/history/application/HistoryCreateTest.java
+++ /dev/null
@@ -1,631 +0,0 @@
-package com.clokey.server.domain.history.application;
-
-import com.clokey.server.domain.cloth.domain.repository.ClothRepository;
-import com.clokey.server.domain.cloth.exception.ClothException;
-import com.clokey.server.domain.history.api.HistoryRestController;
-import com.clokey.server.domain.history.domain.entity.Comment;
-import com.clokey.server.domain.history.domain.repository.*;
-import com.clokey.server.domain.history.dto.HistoryRequestDTO;
-import com.clokey.server.domain.history.dto.HistoryResponseDTO;
-import com.clokey.server.domain.history.exception.HistoryException;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.model.entity.enums.Visibility;
-import com.clokey.server.global.error.code.status.ErrorStatus;
-import jakarta.validation.ConstraintViolationException;
-import jakarta.validation.ValidationException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.junit.jupiter.params.provider.NullSource;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.mock.web.MockMultipartFile;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-
-@Disabled
-@SpringBootTest
-@Transactional
-@ActiveProfiles("local")
-public class HistoryCreateTest {
-
- @Autowired
- private HistoryService historyService;
-
- @Autowired
- private HistoryRestController historyRestController;
-
- @Autowired
- private MemberRepository memberRepository;
-
- @Autowired
- private ClothRepository clothRepository;
-
- @Autowired
- private HistoryClothRepository historyClothRepository;
-
- @Autowired
- private HashtagRepository hashtagRepository;
-
- @Autowired
- private HashtagHistoryRepository hashtagHistoryRepository;
-
- @Autowired
- private MemberLikeRepository memberLikeRepository;
-
- @Autowired
- private CommentRepository commentRepository;
-
- private List imageFiles;
-
- @BeforeEach
- void setUp() {
-
- MockMultipartFile imageFile1 = new MockMultipartFile(
- "imageFile",
- "sample.jpg",
- "image/jpeg",
- "test-image-content".getBytes()
- );
- imageFiles = List.of(imageFile1);
- }
-
- /**
- * 날짜별 옷 기록 추가 API TEST
- */
-
- @DisplayName("옷의 착용 횟수와 매핑 테이블에 새로운 필드가 반영된다.")
- @Test
- void 기록_생성_성공_옷등록() {
-
- /**
- * 최초 생성시 옷에 대한 정보를 등록한다.
- */
- // given
- Long memberId = 1L;
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // when
- HistoryResponseDTO.HistoryCreateResult result = historyService.createHistory(requestDto, memberId, imageFiles);
-
- // then
- // 성공적으로 다음 history 생성
- assertThat(result.getHistoryId()).isNotNull();
-
- // 옷의 착용 횟수 증가 확인
- assertThat(clothRepository.findById(1L).get().getWearNum()).isEqualTo(7);
- assertThat(clothRepository.findById(2L).get().getWearNum()).isEqualTo(17);
-
- // 기록- 옷 매핑 테이블 추가 확인
- assertThat(historyClothRepository.existsByHistoryIdAndClothId(result.getHistoryId(), 1L)).isTrue();
- assertThat(historyClothRepository.existsByHistoryIdAndClothId(result.getHistoryId(), 2L)).isTrue();
-
- /**
- * 같은 날짜에 대해서 기록을 다시 만들 경우 옷의 변화를 반영한다 ( 없어진 옷을 내리고 새로 생긴 옷 등록 )
- */
-
- // given
- HistoryRequestDTO.HistoryCreate updateRequest = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 11L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // when
- HistoryResponseDTO.HistoryCreateResult updateResult = historyService.createHistory(updateRequest, memberId, imageFiles);
-
- // then
- // 옷 착용 횟수 업데이트 확인 ( 1L : 유지 , 2L : 1감소 , 11L : 1증가 )
- assertThat(clothRepository.findById(1L).get().getWearNum()).isEqualTo(7);
- assertThat(clothRepository.findById(2L).get().getWearNum()).isEqualTo(16);
- assertThat(clothRepository.findById(11L).get().getWearNum()).isEqualTo(1);
-
- // 기록- 옷 매핑 테이블 업데이트 확인 ( 1L : 유지 , 2L : 삭제 , 11L : 추가 )
- assertThat(historyClothRepository.existsByHistoryIdAndClothId(result.getHistoryId(), 1L)).isTrue();
- assertThat(historyClothRepository.existsByHistoryIdAndClothId(result.getHistoryId(), 2L)).isFalse();
- assertThat(historyClothRepository.existsByHistoryIdAndClothId(result.getHistoryId(), 11L)).isTrue();
- }
-
- @DisplayName("기존 해시태그가 매핑 테이블에 추가되거나 새로운 해시태그가 추가된다, 한 번 생성된 해시태그는 삭제되지는 않는다.")
- @Test
- void 기록_생성_성공_해시태그_등록() {
-
- /**
- * 존재하지 않는 해시태그를 기록에 등록할 경우 해시태그가 생성되고 매핑 테이블에 추가된다.
- */
- // given
- Long memberId = 1L;
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새로운 테스트 해시태그"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- assertThat(hashtagRepository.findByName("새로운 테스트 해시태그").isPresent()).isFalse();
-
- // when
- HistoryResponseDTO.HistoryCreateResult result = historyService.createHistory(requestDto, memberId, imageFiles);
-
- // then
- // 해시태그가 생성됨
- assertThat(hashtagRepository.findByName("새로운 테스트 해시태그").isPresent()).isTrue();
-
- // 매핑 테이블에 추가됨
- assertThat(hashtagHistoryRepository.existsByHashtagIdAndHistoryId(
- hashtagRepository.findByName("새로운 테스트 해시태그").get().getId(),
- result.getHistoryId()
- )).isTrue();
-
- /**
- * 같은 날짜에 대해서 해시태그를 업데이트 하면 해시태그의 변화를 반영한다 ( 기록에서 제외될 수 있으나 해시태그는 삭제되지 않음 )
- */
-
- // given
- HistoryRequestDTO.HistoryCreate updateRequestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // when
- HistoryResponseDTO.HistoryCreateResult updateResult = historyService.createHistory(updateRequestDto, memberId, imageFiles);
-
- // then
- // 새로운 해시태그 "시해 결심"은 매핑 테이블에 추가되고 "새로운 테스트 해시태그"는 제외된다, 하지만 삭제되지는 않는다.
- assertThat(hashtagHistoryRepository.existsByHashtagIdAndHistoryId(
- hashtagRepository.findByName("새해결심").get().getId(),
- updateResult.getHistoryId()
- )).isTrue();
- assertThat(hashtagRepository.findByName("새로운 테스트 해시태그").isPresent()).isTrue();
- assertThat(hashtagHistoryRepository.existsByHashtagIdAndHistoryId(
- hashtagRepository.findByName("새로운 테스트 해시태그").get().getId(),
- updateResult.getHistoryId()
- )).isFalse();
- }
-
- @DisplayName("신고당한 기록을 PUBLIC으로 전화하려 시도하는 경우 Service단에서 에러를 던집니다.")
- @Test
- void 기록_생성_예외1() {
- // given
- Long memberId = 1L;
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-11-01")
- .build();
-
- // then
- assertThatThrownBy(() -> historyService.createHistory(requestDto, memberId, imageFiles))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.BANNED_HISTORY_TO_PUBLIC)
- );
- }
-
- @DisplayName("나의 옷이 아닌 옷을 등록하려 하는 경우 Service에서 에러를 던집니다")
- @Test
- void 기록_생성_예외2() {
- // given
- Long memberId = 1L;
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(3L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // then
- assertThatThrownBy(() -> historyService.createHistory(requestDto, memberId, imageFiles))
- .isInstanceOfSatisfying(ClothException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.NOT_MY_CLOTH)
- );
- }
-
- @DisplayName("날짜 형식이 'YYYY-MM-DD'에 맞지 않으면 Controller단에서 예외가 발생합니다.")
- @ParameterizedTest
- @ValueSource(strings = {"2025-1-1", "2025년 1월 1일", "2025/1/1", "2025-11"})
- void 기록_생성_예외3(String month) {
- // given
- Member member = memberRepository.findById(1L).get();
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date(month)
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.createHistory(requestDto, imageFiles, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.DATE_INVALID.name())
- );
- }
-
- @DisplayName("content가 200자가 넘어가는 경우 Controller에서 예외가 발생합니다.")
- @Test
- void 기록_생성_예외4() {
- // given
- Member member = memberRepository.findById(1L).get();
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("a".repeat(201))
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.createHistory(requestDto, imageFiles, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.HISTORY_CONTENT_OUT_OF_RANGE.name())
- );
- }
-
- @DisplayName("중복된 cloth를 등록하려는 경우 Controller에서 예외가 발생합니다.")
- @Test
- void 기록_생성_예외5() {
- // given
- Member member = memberRepository.findById(1L).get();
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 1L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.createHistory(requestDto, imageFiles, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.DUPLICATE_CLOTHES_FOR_HISTORY.name())
- );
- }
-
- @DisplayName("11개 이상의 사진을 기록에 등록하려는 경우 Controller단에서 에러를 던집니다.")
- @Test
- void 기록_생성_예외6() {
- // given
- Member member = memberRepository.findById(1L).get();
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 1L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- List filesOf11Images = new ArrayList<>();
-
- for (int i = 0; i < 11; i++) {
- MultipartFile file = new MockMultipartFile(
- "imageFile", // name
- "test-image-" + i + ".jpg", // original filename
- "image/jpeg", // content type
- "dummy-image-content".getBytes() // file content
- );
- filesOf11Images.add(file);
- }
- // then
- assertThatThrownBy(() -> historyRestController.createHistory(requestDto, filesOf11Images, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.IMAGE_QUANTITY_OVER_HISTORY_IMAGE_LIMIT.name())
- );
- }
-
- @DisplayName("기록에 사진을 등록하지 않는 경우 Controller단에서 에러를 던집니다.")
- @Test
- void 기록_생성_예외7() {
- // given
- Member member = memberRepository.findById(1L).get();
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of(1L, 2L))
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- List emptyImageFile = new ArrayList<>();
-
-
- // then
- assertThatThrownBy(() -> historyRestController.createHistory(requestDto, emptyImageFile, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.IMAGE_QUANTITY_OVER_HISTORY_IMAGE_LIMIT.name())
- );
- }
-
- @DisplayName("옷을 등록하지 않는 경우 Controller단에서 에러를 던집니다.")
- @Test
- void 기록_생성_예외8() {
- // given
- Member member = memberRepository.findById(1L).get();
-
- HistoryRequestDTO.HistoryCreate requestDto = HistoryRequestDTO.HistoryCreate.builder()
- .content("테스트 내용")
- .clothes(List.of())
- .hashtags(List.of("새해결심"))
- .visibility(Visibility.PUBLIC)
- .date("2025-02-02")
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.createHistory(requestDto, imageFiles, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_CLOTH_FOR_HISTORY.name())
- );
- }
-
- /**
- * 좋아요 API TEST
- */
-
- @DisplayName("좋아요 취소 기능")
- @Test
- void 좋아요_성공1() {
- // given
- // member 1은 history 10번을 좋아요 한 상태이다.
- Long memberId = 1L;
- Long historyId = 10L;
- boolean isLiked = true;
- assertThat(memberLikeRepository.existsByMemberIdAndHistoryId(1L, 10L)).isTrue();
-
- // when
- // 좋아요 취소
- HistoryResponseDTO.LikeResult result = historyService.changeLike(memberId, historyId, isLiked);
-
- // then
- assertThat(memberLikeRepository.existsByMemberIdAndHistoryId(1L, 10L)).isFalse();
- assertThat(result)
- .extracting("historyId", "isLiked", "likeCount")
- .containsExactly(10L, false, 0);
- }
-
- @DisplayName("좋아요 하기 기능")
- @Test
- void 좋아요_성공2() {
- // given
- // member 1은 history 3번을 좋아요 하지 않은 상태다
- Long memberId = 1L;
- Long historyId = 3L;
- boolean isLiked = false;
- assertThat(memberLikeRepository.existsByMemberIdAndHistoryId(1L, 3L)).isFalse();
-
- // when
- // 좋아요 누르기
- HistoryResponseDTO.LikeResult result = historyService.changeLike(memberId, historyId, isLiked);
-
- // then
- assertThat(memberLikeRepository.existsByMemberIdAndHistoryId(1L, 3L)).isTrue();
- assertThat(result)
- .extracting("historyId", "isLiked", "likeCount")
- .containsExactly(3L, true, 2);
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 좋아요_예외1(Long historyId) {
-
- // given
- Member member = memberRepository.findById(1L).get();
- HistoryRequestDTO.LikeStatusChange requestDto = HistoryRequestDTO.LikeStatusChange.builder()
- .historyId(historyId)
- .isLiked(false)
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.like(member, requestDto))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_HISTORY.name())
- );
- }
-
- @DisplayName("좋아요 정보가 잘못된 경우 Serivce단에서 에러를 던집니다")
- @ParameterizedTest(name = "historyId={0}, 좋아요 누른 멤버={1}, 좋아요 여부={2}")
- @CsvSource(
- nullValues = "null",
- value = {
- "1,1,false", //거짓 - 1번 멤버는 1번 history에 좋아요한 상태
- "3,1, true" //거짓 - 1번 멤버는 3번 history에 좋아요를 누르지 않음
- }
- )
- void 좋아요_예외2(Long historyId, Long memberId, boolean isLiked) {
-
- //then
- assertThatThrownBy(() -> historyService.changeLike(memberId, historyId, isLiked))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.IS_LIKED_INVALID)
- );
- }
-
- /**
- * 댓글 작성 API TEST
- */
-
- @DisplayName("부모 댓글을 정확하게 작성할 수 있다.")
- @Test
- void 댓글_작성_성공1() {
-
- // given
- Long historyToWriteComment = 1L;
- Long parentCommentId = null;
- Long commentWriter = 1L;
- String content = "테스트 부모 댓글";
-
- // when
- HistoryResponseDTO.CommentWriteResult result = historyService.writeComment(historyToWriteComment, parentCommentId, commentWriter, content);
- Comment writtenComment = commentRepository.findById(result.getCommentId()).get();
-
- // then
- assertThat(writtenComment.getHistory().getId()).isEqualTo(historyToWriteComment);
- assertThat(writtenComment.getComment()).isNull();
- assertThat(writtenComment.getMember().getId()).isEqualTo(commentWriter);
- assertThat(writtenComment.getContent()).isEqualTo(content);
- }
-
- @DisplayName("대댓글을 정확하게 작성할 수 있다.")
- @Test
- void 댓글_작성_성공2() {
-
- // given
- Long historyToWriteComment = 1L;
- Long parentCommentId = 1L;
- Long commentWriter = 1L;
- String content = "테스트 대댓글";
-
- // when
- HistoryResponseDTO.CommentWriteResult result = historyService.writeComment(historyToWriteComment, parentCommentId, commentWriter, content);
- Comment writtenComment = commentRepository.findById(result.getCommentId()).get();
-
- // then
- assertThat(writtenComment.getHistory().getId()).isEqualTo(historyToWriteComment);
- assertThat(writtenComment.getComment().getId()).isEqualTo(parentCommentId);
- assertThat(writtenComment.getMember().getId()).isEqualTo(commentWriter);
- assertThat(writtenComment.getContent()).isEqualTo(content);
- }
-
- @DisplayName("깊이 2이상의 댓글 (대댓글에 대댓글 달기)을 작성하면 Controller단에서 에러를 던진다.")
- @Test
- void 댓글_작성_예외1() {
-
- // given
- Long historyToWriteComment = 1L;
- Member commentWriter = memberRepository.findById(1L).get();
- HistoryRequestDTO.CommentWrite requestDto = HistoryRequestDTO.CommentWrite.builder()
- .commentId(6L) //이미 1번 history의 1번 댓글에 달린 대댓글
- .content("테스트 깊이 2댓글")
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.writeComments(historyToWriteComment, commentWriter, requestDto))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NESTED_COMMENT.name())
- );
-
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 댓글_작성_예외2(Long historyId) {
-
- // given
- Member commentWriter = memberRepository.findById(1L).get();
- HistoryRequestDTO.CommentWrite requestDto = HistoryRequestDTO.CommentWrite.builder()
- .commentId(6L) //이미 1번 history의 1번 댓글에 달린 대댓글
- .content("테스트 댓글")
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.writeComments(historyId, commentWriter, requestDto))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_HISTORY.name())
- );
- }
-
- @DisplayName("Content에 빈칸 또는 null값을 입력하는 경우 Controller단에서 예외를 던진다.")
- @ParameterizedTest
- @NullSource
- @ValueSource(strings = {"", " "})
- void 댓글_작성_예외3(String content) {
-
- // given
- Long historyToWriteComment = 1L;
- Member commentWriter = memberRepository.findById(1L).get();
- HistoryRequestDTO.CommentWrite requestDto = HistoryRequestDTO.CommentWrite.builder()
- .commentId(1L)
- .content(content)
- .build();
-
- // then
- assertThatThrownBy(() -> historyRestController.writeComments(historyToWriteComment, commentWriter, requestDto))
- .isInstanceOf(ValidationException.class);
- }
-
- @DisplayName("Content가 50자를 넘어가면 Controller단에서 에러를 던집니다.")
- @Test
- void 댓글_작성_예외4() {
- // given
- Long historyToWriteComment = 1L;
- Member commentWriter = memberRepository.findById(1L).get();
- HistoryRequestDTO.CommentWrite requestDto = HistoryRequestDTO.CommentWrite.builder()
- .commentId(1L)
- .content("a".repeat(51))
- .build();
-
- assertThatThrownBy(() -> historyRestController.writeComments(historyToWriteComment, commentWriter, requestDto))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.COMMENT_LENGTH_OUT_OF_RANGE.name())
- );
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Service단에서 에러를 던진다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 댓글_작성_예외5(Long parentCommentId) {
-
- // given
- Long historyToWriteComment = 1L;
- Long commentWriter = 1L;
- String content = "테스트 댓글";
-
- // then
- assertThatThrownBy(() -> historyService.writeComment(historyToWriteComment, parentCommentId, commentWriter, content))
- .isInstanceOf(HistoryException.class);
- }
-
- @DisplayName("부모 댓글과 대댓글로 작성하는 댓글의 historyId가 다른 경우 Service단에서 에러를 던진다.")
- @Test
- void 댓글_작성_예외6() {
-
- //given
- Long historyToWriteComment = 2L; // 거짓 : 1번 댓글은 1번 history에 작성되었습니다.
- Long parentComment = 1L;
- Long commentWriter = 1L;
- String content = "테스트댓글";
-
- //then
- assertThatThrownBy(() -> historyService.writeComment(historyToWriteComment, parentComment, commentWriter, content))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.PARENT_COMMENT_HISTORY_ERROR)
- );
- }
-}
-
diff --git a/src/test/java/com/clokey/server/domain/history/application/HistoryDeleteTest.java b/src/test/java/com/clokey/server/domain/history/application/HistoryDeleteTest.java
deleted file mode 100644
index e844c972..00000000
--- a/src/test/java/com/clokey/server/domain/history/application/HistoryDeleteTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package com.clokey.server.domain.history.application;
-
-import com.clokey.server.domain.cloth.domain.repository.ClothRepository;
-import com.clokey.server.domain.history.api.HistoryRestController;
-import com.clokey.server.domain.history.domain.entity.History;
-import com.clokey.server.domain.history.domain.repository.*;
-import com.clokey.server.domain.history.exception.HistoryException;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.search.application.SearchRepositoryService;
-import com.clokey.server.global.error.code.status.ErrorStatus;
-import jakarta.validation.ConstraintViolationException;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.*;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.io.IOException;
-
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-
-@Disabled
-@SpringBootTest
-@Transactional
-@ActiveProfiles("local")
-public class HistoryDeleteTest {
-
- @Autowired
- private HistoryService historyService;
-
- @Autowired
- private HistoryRepository historyRepository;
-
- @Autowired
- private CommentRepository commentRepository;
-
- @Autowired
- private HistoryClothRepository historyClothRepository;
-
- @Autowired
- private MemberLikeRepository memberLikeRepository;
-
- @Autowired
- private HistoryImageRepository historyImageRepository;
-
- @Autowired
- private SearchRepositoryService searchRepositoryService;
-
- @Autowired
- private HistoryRestController historyRestController;
-
- @Autowired
- private MemberRepository memberRepository;
-
- @Autowired
- private ClothRepository clothRepository;
-
- /**
- * 기록 삭제 API TEST
- */
-
- @DisplayName("기록을 삭제하며 관련된 모든 것들을 삭제할 수 있다.")
- @Test
- @Order(1)
- void 기록_삭제_성공1() throws IOException {
-
- //given
- History history = historyRepository.findById(1L).get();
-
- // 부모 댓글과 대댓글이 존재한다
- assertThat(commentRepository.existsByHistoryIdAndCommentIsNull(1L)).isTrue();
- assertThat(commentRepository.existsByHistoryIdAndCommentIsNotNull(1L)).isTrue();
-
- // 옷과 기록의 매핑 테이블에 데이터가 존재한다
- assertThat(historyClothRepository.existsByHistoryId(1L)).isTrue();
-
- // 좋아요 기록을 확인한다.
- assertThat(memberLikeRepository.existsByHistoryId(1L)).isTrue();
-
- // 기록과 관련된 사진이 존재합니다.
- assertThat(historyImageRepository.existsByHistoryId(1L)).isTrue();
-
- //옷의 착용 횟수 확인 (삭제전)
- assertThat(clothRepository.findById(1L).get().getWearNum()).isEqualTo(6);
-
- // when
- // 1번 Member의 1번 기록을 지웁니다.
- historyService.deleteHistory(1L, 1L);
-
- // then
- // 부모 댓글과 대댓글이 존재하지 않는다
- assertThat(commentRepository.existsByHistoryIdAndCommentIsNull(1L)).isFalse();
- assertThat(commentRepository.existsByHistoryIdAndCommentIsNotNull(1L)).isFalse();
-
- // 옷과 기록의 매핑 테이블에 데이터가 존재한다
- assertThat(historyClothRepository.existsByHistoryId(1L)).isFalse();
-
- // 좋아요 기록을 확인한다.
- assertThat(memberLikeRepository.existsByHistoryId(1L)).isFalse();
-
- // 기록과 관련된 사진이 존재합니다.
- assertThat(historyImageRepository.existsByHistoryId(1L)).isFalse();
-
- //옷의 착용 횟수 확인 (삭제 후)
- assertThat(clothRepository.findById(1L).get().getWearNum()).isEqualTo(5);
-
- }
-
- @DisplayName("ES 복구")
- @Test
- @Order(2)
- void ES_Recovery() throws IOException {
-
- History history = historyRepository.findById(1L).get();
-
- searchRepositoryService.updateHistoryDataToElasticsearch(history);
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 기록_삭제_예외1(Long historyId) {
-
- // given
- Member member = memberRepository.findById(1L).get();
-
- // then
- assertThatThrownBy(() -> historyRestController.deleteHistory(member, historyId))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- Assertions.assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_HISTORY.name())
- );
- }
-
- @DisplayName("나의 기록이 아닌 기록을 삭제하려는 경우 Service단에서 에러가 발생합니다.")
- @Test
- void 기록_삭제_예외2() {
-
- // given
- // 거짓 : 1번 history는 1번 Member의 기록입니다.
- Member member = memberRepository.findById(2L).get();
- Long historyId = 1L;
-
- // then
- assertThatThrownBy(() -> historyRestController.deleteHistory(member, historyId))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- Assertions.assertThat(ex.getCode()).isEqualTo(ErrorStatus.NOT_MY_HISTORY)
- );
- }
-
- @DisplayName("댓글을 지우고 대댓글도 모두 삭제됩니다.")
- @Test
- void 댓글_삭제_성공1() {
-
- //given
- Long targetCommentId = 1L;
- Long commentWriterId = 1L;
-
- // 1번 댓글이 존재하고 1번 댓글에는 대댓글이 달려있다.
- assertThat(commentRepository.existsById(1L)).isTrue();
- assertThat(commentRepository.existsByComment_Id(1L)).isTrue();
-
- // when
- historyService.deleteComment(targetCommentId, commentWriterId);
-
- // then
- // 댓글과 대댓글이 모두 삭제됨.
- assertThat(commentRepository.existsById(1L)).isFalse();
- assertThat(commentRepository.existsByComment_Id(1L)).isFalse();
- }
-
- @DisplayName("본인이 작성하지 않은 댓글을 삭제 시도할 경우 Service단에서 에러가납니다.")
- @Test
- void 댓글_삭제_예외1() {
-
- //given
- // 거짓 : 1번 댓글은 1번 Member가 작성하였습니다.
- Long targetCommentId = 1L;
- Long commentWriterId = 2L;
-
- // then
- assertThatThrownBy(() -> historyService.deleteComment(targetCommentId, commentWriterId))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- Assertions.assertThat(ex.getCode()).isEqualTo(ErrorStatus.NOT_MY_COMMENT)
- );
- }
-
-}
diff --git a/src/test/java/com/clokey/server/domain/history/application/HistoryReadTest.java b/src/test/java/com/clokey/server/domain/history/application/HistoryReadTest.java
deleted file mode 100644
index 16a1e47a..00000000
--- a/src/test/java/com/clokey/server/domain/history/application/HistoryReadTest.java
+++ /dev/null
@@ -1,557 +0,0 @@
-package com.clokey.server.domain.history.application;
-
-
-import com.clokey.server.domain.history.api.HistoryRestController;
-import com.clokey.server.domain.history.dto.HistoryResponseDTO;
-import com.clokey.server.domain.history.exception.HistoryException;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.member.exception.MemberException;
-import com.clokey.server.global.error.code.status.ErrorStatus;
-import jakarta.validation.ConstraintViolationException;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.time.LocalDate;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-
-@Disabled
-@SpringBootTest
-@Transactional
-@ActiveProfiles("local")
-class HistoryReadTest {
-
- @Autowired
- private HistoryService historyService;
-
- @Autowired
- private HistoryRestController historyRestController;
-
- @Autowired
- private MemberRepository memberRepository;
-
- /**
- * 월별 기록 조회 API TEST
- */
-
- @DisplayName("나와 타인의 월별 기록의 개수를 정확하게 반환한다.")
- @ParameterizedTest(name = "clokeyId={0}, 기대 기록 수={1}, 조회 월={2}")
- @CsvSource(
- nullValues = "null",
- value = {
- "null, 2, 2025-01", // 자기 자신
- "clokey3, 1, 2024-12" // 타인
- }
- )
- void 월별_기록_조회_성공_1(String clokeyId, int expectedSize, String month) {
- // given
- Long myMemberId = 1L;
-
- // when
- HistoryResponseDTO.MonthViewResult result = historyService.getMonthlyHistories(myMemberId, clokeyId, month);
-
- // then
- assertThat(result.getHistories().size()).isEqualTo(expectedSize);
- }
-
- @DisplayName("기록의 내용을 정확하게 반환한다.")
- @Test
- void 월별_기록_조회_성공_2() {
- // given
- Long myMemberId = 1L;
- String target = null;
- String month = "2025-01";
-
- // when
- HistoryResponseDTO.MonthViewResult monthViewResult = historyService.getMonthlyHistories(myMemberId, target, month);
- HistoryResponseDTO.HistoryResult result1 = monthViewResult.getHistories().get(0);
- HistoryResponseDTO.HistoryResult result2 = monthViewResult.getHistories().get(1);
-
- // then
- assertThat(result1)
- .extracting("historyId", "date", "imageUrl")
- .containsExactly(1L, LocalDate.of(2025, 1, 1), "https://example.com/images/new_year.jpg");
-
- assertThat(result2)
- .extracting("historyId", "date", "imageUrl")
- .containsExactly(2L, LocalDate.of(2025, 1, 2), "https://example.com/images/reading.jpg");
- }
-
-
- @DisplayName("비공개 기록의 url은 주인이 볼경우 보이고 아닌 경우 '비공개입니다'로 표시됩니다.")
- @ParameterizedTest(name = "myMemberId={0}, targetClokeyId={1}, 조회 월={2}, 결과 url={3}")
- @CsvSource(
- nullValues = "null",
- value = {
- "1, clokey3, 2025-01, 비공개입니다", //1이 3번 Member의 비공개 history 조회
- "3, null, 2025-01, https://example.com/imagefor6.jpg" //3번 Member가 자신의 비공개 history 조회
- }
- )
- void 월별_기록_조회_성공_3(Long myMemberId, String targetClokeyId, String month, String expectedUrl) {
- // given
- HistoryResponseDTO.MonthViewResult result = historyService.getMonthlyHistories(myMemberId, targetClokeyId, month);
-
- // when
- String historyImageUrl = result.getHistories()
- .get(0)
- .getImageUrl();
-
- // then
- assertThat(historyImageUrl).isEqualTo(expectedUrl);
- }
-
- @DisplayName("비공개 계정에서 본인은 본인의 기록을 열람할 수 있어야 한다.")
- @Test
- void 월별_기록_조회_성공_4() {
- // given
- Long myMemberId = 2L;
- String targetClokeyId = null;
- String month = "2025-01";
-
- //then
- assertThatCode(() ->
- historyService.getMonthlyHistories(myMemberId, targetClokeyId, month)
- ).doesNotThrowAnyException();
- }
-
- @DisplayName("존재하지 않는 clokeyId를 입력하면 Service단에서 예외가 발생합니다.")
- @ParameterizedTest
- @ValueSource(strings = {"없는ClokeyId", "예외", "", " "})
- void 월별_기록_조회_예외_1(String targetClokeyId) {
- // given
- Long myId = 1L;
- String month = "2025-01";
-
- // then
- assertThatThrownBy(() -> historyService.getMonthlyHistories(myId, targetClokeyId, month))
- .isInstanceOfSatisfying(MemberException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.NO_SUCH_MEMBER)
- );
- }
-
- @DisplayName("존재하지 않는 clokeyId를 입력하면 Controller단에서 예외가 발생합니다.")
- @ParameterizedTest
- @ValueSource(strings = {"없는ClokeyId", "예외", "", " "})
- void 월별_기록_조회_예외_2(String targetClokeyId) {
- // given
- Member currentMember = memberRepository.findById(1L).get();
- String month = "2025-01";
-
- // then
- assertThatThrownBy(() -> historyRestController.getMonthlyHistories(currentMember, targetClokeyId, month))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_MEMBER.name())
- );
- }
-
- @DisplayName("날짜 형식이 'YYYY-MM'에 맞지 않으면 Controller단에서 예외가 발생합니다.")
- @ParameterizedTest
- @ValueSource(strings = {"2025-1", "2025년 1월", "2025/1", "2025-11-01"})
- void 월별_기록_조회_예외_3(String month) {
- // given
- Member currentMember = memberRepository.findById(1L).get();
- String targetMember = null; // 자기 자신의 기록을 본다.
-
- // then
- assertThatThrownBy(() -> historyRestController.getMonthlyHistories(currentMember, targetMember, month))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.DATE_INVALID.name())
- );
- }
-
- @DisplayName("비공개 멤버를 타인이 조회하려고 시도하는 경우 service단에서 에러가 발생합니다.")
- @Test
- void 월별_기록_조회_예외_4() {
- // given
- Long myMemberId = 1L;
- String targetMemberClokeyId = "clokey2";
- String month = "2025-01";
-
- // then
- assertThatThrownBy(() -> historyService.getMonthlyHistories(myMemberId, targetMemberClokeyId, month))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.NO_PERMISSION_TO_ACCESS_HISTORY)
- );
- }
-
- /**
- * 일별 기록 조회 API TEST
- */
-
- @DisplayName("비공개 유저가 자신의 비공개 기록을 열람하는 케이스, 모든 정보가 정확하게 보인다. (기본 기능 + 열람 권한 테스트)")
- @Test
- void 일별_기록_조회_성공_1() {
- // given
- Long memberId = 2L; // 비공개인 2번 멤버
- Long historyId = 3L; // 2번 멤버의 비공개 기록
-
- // when
- HistoryResponseDTO.DailyHistoryResult result = historyService.getDaily(historyId, memberId);
-
- // then
- // 단일 필드값 검증
- assertThat(result)
- .extracting("memberId", "historyId", "memberImageUrl", "nickName", "clokeyId", "contents", "visibility", "likeCount", "date", "commentCount", "isLiked")
- .containsExactly(2L, 3L, "https://example.com/user2.png", "User2", "clokey2", "새해를 맞아 여행을 다녀왔습니다.", false, 1, LocalDate.of(2025, 1, 1), 4L, true);
-
- // 컬랙션 필드 순차적 검증
- assertThat(result.getImageUrl().size()).isEqualTo(1);
- assertThat(result.getImageUrl().get(0)).isEqualTo("https://example.com/images/travel.jpg");
-
- assertThat(result.getHashtags().size()).isEqualTo(0);
-
- assertThat(result.getCloths().size()).isEqualTo(1);
- assertThat(result.getCloths().get(0))
- .extracting("clothId", "clothImageUrl", "clothName")
- .containsExactly(3L, "https://example.com/images/cloth3_1.jpg", "검은색 셔츠");
- }
-
- @DisplayName("공개 유저인 타인의 공개 기록은 볼 수 있지만, 비공개 옷은 보이지 않는다.")
- @Test
- void 일별_기록_조회_성공_2() {
- // given
- Long memberId = 1L;
- Long historyId = 7L; // 공개 유저인 4번 멤버의 공개인 7번 기록.
-
- // when
- HistoryResponseDTO.DailyHistoryResult result = historyService.getDaily(historyId, memberId);
-
- // then
- assertThat(result.getCloths().size()).isEqualTo(0);
- }
-
- @DisplayName("비공개인 유저의 게시물 또는 공개인 유저의 비공개 게시물을 조회할 경우 서비스단에서 에러가 발생합니다.")
- @ParameterizedTest(name = "memberId={0}, targetHistoryID={1}")
- @CsvSource(
- nullValues = "null",
- value = {
- "1, 4", // 1번 Member가 2번 Member(비공개)가 작성한 공개 기록을 조회하려는 경우
- "1, 8" // 1번 Member가 공개 Member인 4번의 비공개 기록 8번을 조회하려는 경우
- }
- )
- void 일별_기록_조회_예외_2(Long memberId, Long historyId) {
-
- // then
- assertThatThrownBy(() -> historyService.getDaily(historyId, memberId))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.NO_PERMISSION_TO_ACCESS_HISTORY)
- );
- }
-
- /**
- * 나의 기록인지 확인하기 API TEST
- */
-
- @DisplayName("나와 타인의 기록을 정확하게 판정한다.")
- @ParameterizedTest(name = "memberId={0}, historyId={1}, expected={2}")
- @CsvSource(
- nullValues = "null",
- value = {
- "1, 1, true",
- "1, 2, true",
- "1, 3, false",
- "1, 5, false"
- }
- )
- void 나의_기록인지_확인하기_성공_1(Long memberId, Long historyId, boolean expected) {
-
- //when
- boolean result = historyService.checkIfHistoryIsMine(historyId, memberId).getIsMyHistory();
-
- // then
- assertThat(result).isEqualTo(expected);
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 나의_기록인지_확인하기_에외_1(Long historyId) {
-
- // given
- Member member = memberRepository.findById(1L).get();
-
- // then
- assertThatThrownBy(() -> historyRestController.checkIfHistoryIsMine(historyId, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_HISTORY.name())
- );
- }
-
- /**
- * 좋아요 누른 사람들 정보 확인하기 API TEST
- */
-
- @DisplayName("좋아요 누른 사람들 정보를 정확하게 반환합니다.")
- @Test
- void 좋아요_누른_사람들_확인하기_성공_1() {
-
- // given
- Long checkingMemberId = 1L;
- Long historyId = 2L;
-
- // when
- List result = historyService.getLikedUsers(checkingMemberId, historyId).getLikedUsers();
-
- //then
- // 결과와 내용을 순차적으로 확인
- assertThat(result.size()).isEqualTo(3);
-
- HistoryResponseDTO.LikedUserResult result1 = result.get(0);
- HistoryResponseDTO.LikedUserResult result2 = result.get(1);
- HistoryResponseDTO.LikedUserResult result3 = result.get(2);
-
- assertThat(result1)
- .extracting("memberId", "clokeyId", "ImageUrl", "nickname", "followStatus", "isMe")
- .containsExactly(1L, "clokey1", "https://example.com/user1.png", "User1", false, true);
-
- assertThat(result2)
- .extracting("memberId", "clokeyId", "ImageUrl", "nickname", "followStatus", "isMe")
- .containsExactly(2L, "clokey2", "https://example.com/user2.png", "User2", true, false);
-
- assertThat(result3)
- .extracting("memberId", "clokeyId", "ImageUrl", "nickname", "followStatus", "isMe")
- .containsExactly(4L, "clokey4", "https://example.com/user4.png", "User4", true, false);
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 좋아요_누른_사람들_확인하기_예외_1(Long historyId) {
-
- // given
- Member member = memberRepository.findById(1L).get();
-
- // then
- assertThatThrownBy(() -> historyRestController.getLikedUsers(historyId, member))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_HISTORY.name())
- );
- }
-
- @DisplayName("비공개인 유저의 게시물 또는 공개인 유저의 비공개 게시물의 좋아요 목록을 조회할 경우 서비스단에서 에러가 발생합니다.")
- @ParameterizedTest(name = "memberId={0}, targetHistoryID={1}")
- @CsvSource(
- nullValues = "null",
- value = {
- "1, 4", // 1번 Member가 2번 Member(비공개)가 작성한 공개 기록을 조회하려는 경우
- "1, 8" // 1번 Member가 공개 Member인 4번의 비공개 기록 8번을 조회하려는 경우
- }
- )
- void 좋아요_누른_사람들_확인하기_예외_2(Long memberId, Long historyId) {
-
- // then
- assertThatThrownBy(() -> historyService.getLikedUsers(memberId, historyId))
- .isInstanceOfSatisfying(HistoryException.class, ex ->
- assertThat(ex.getCode()).isEqualTo(ErrorStatus.NO_PERMISSION_TO_ACCESS_HISTORY)
- );
- }
-
- /**
- * 댓글 조회 API TEST
- */
-
- @DisplayName("정확한 댓글 조회 기능을 수행한다.")
- @Test
- void 댓글_조회_성공_1() {
-
- // given
- Long historyId = 1L;
- int page = 0;
-
- // when
- HistoryResponseDTO.HistoryCommentResult result = historyService.getComments(historyId, page);
-
- // then
- // 결과 내용을 순차적으로 확인
- // HistoryResponseDTO.HistoryCommentResult 내용 확인
- assertThat(result)
- .extracting("totalPage", "totalElements", "isFirst", "isLast")
- .containsExactly(1, 4, true, true);
- assertThat(result.getComments().size()).isEqualTo(2);
-
- // HistoryResponseDTO.CommentResult (각각 댓글의 내용 확인)
- HistoryResponseDTO.CommentResult commentResult1 = result.getComments().get(0);
- HistoryResponseDTO.CommentResult commentResult2 = result.getComments().get(1);
-
- assertThat(commentResult1)
- .extracting("commentId", "clokeyId", "nickName", "userImageUrl", "content")
- .containsExactly(1L, "clokey1", "User1", "https://example.com/user1.png", "첫 번째 댓글");
- assertThat(commentResult1.getReplyResults().size()).isEqualTo(2);
-
- assertThat(commentResult2)
- .extracting("commentId", "clokeyId", "nickName", "userImageUrl", "content")
- .containsExactly(11L, "clokey1", "User1", "https://example.com/user1.png", "첫 번째 댓글");
- assertThat(commentResult2.getReplyResults().size()).isEqualTo(0);
-
- // HistoryResponseDTO.ReplyResult (각각 댓글의 대댓글 확인)
- HistoryResponseDTO.ReplyResult replyResult1 = commentResult1.getReplyResults().get(0);
- HistoryResponseDTO.ReplyResult replyResult2 = commentResult1.getReplyResults().get(1);
-
- assertThat(replyResult1)
- .extracting("commentId", "clokeyId", "nickName", "userImageUrl", "content")
- .containsExactly(6L, "clokey2", "User2", "https://example.com/user2.png", "첫 번째 댓글에 대한 대댓글");
-
- assertThat(replyResult2)
- .extracting("commentId", "clokeyId", "nickName", "userImageUrl", "content")
- .containsExactly(16L, "clokey2", "User2", "https://example.com/user2.png", "첫 번째 댓글에 대한 대댓글");
-
- }
-
- @DisplayName("존재하지 않는 historyId를 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(longs = {100L, 2000L, 1234L})
- void 댓글_조회_예외_1(Long historyId) {
-
- // given
- int page = 1;
-
- // then
- assertThatThrownBy(() -> historyRestController.getComments(historyId, page))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.NO_SUCH_HISTORY.name())
- );
- }
-
- @DisplayName("0보다 작은 페이지 값을 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(ints = {-1000, -10, 0})
- void 댓글_조회_예외_2(int page) {
-
- // given
- Long historyId = 1L;
-
- // then
- assertThatThrownBy(() -> historyRestController.getComments(historyId, page))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.PAGE_UNDER_ONE.name())
- );
- }
-
- /**
- * 내가 좋아요한 기록 조회 API TEST
- */
-
- @DisplayName("내가 좋아요한 기록을 정확하게 조회한다.")
- @Test
- void 내가_좋아요한_기록_조회_성공1() {
-
- // given
- Long memberId = 1L;
- int page = 0;
-
- // when
- HistoryResponseDTO.HistoryLikedListResult result = historyService.getLikedHistories(memberId, page);
-
- // then
- // HistoryLikedListResult 내용 확인
- assertThat(result)
- .extracting("totalPage", "totalElements", "isFirst", "isLast")
- .containsExactly(1, 3L, true, true);
- assertThat(result.getHistoryPreviews().size()).isEqualTo(3);
-
- // HistoryLikedPreview 내용 확인
- HistoryResponseDTO.HistoryLikedPreview preview1 = result.getHistoryPreviews().get(0);
- HistoryResponseDTO.HistoryLikedPreview preview2 = result.getHistoryPreviews().get(1);
- HistoryResponseDTO.HistoryLikedPreview preview3 = result.getHistoryPreviews().get(2);
-
- assertThat(preview1)
- .extracting("id", "imageUrl", "isMine")
- .containsExactly(1L,"https://example.com/images/new_year.jpg",true);
-
- assertThat(preview2)
- .extracting("id", "imageUrl", "isMine")
- .containsExactly(2L,"https://example.com/images/reading.jpg",true);
-
- assertThat(preview3)
- .extracting("id", "imageUrl", "isMine")
- .containsExactly(10L,"https://example.com/images/bookclub.jpg",false);
-
- }
-
- @DisplayName("0보다 작은 페이지 값을 입력할 경우 Controller단에서 에러가 발생한다.")
- @ParameterizedTest
- @ValueSource(ints = {-1000, -10, 0})
- void 내가_좋아요한_기록_조회_예외1(int page) {
-
- // given
- Member member = memberRepository.findById(1L).get();
-
- // then
- assertThatThrownBy(() -> historyRestController.getLikedHistories(member, page))
- .isInstanceOfSatisfying(ConstraintViolationException.class, ex ->
- assertThat(ex.getMessage()).contains(ErrorStatus.PAGE_UNDER_ONE.name())
- );
- }
-
- /**
- * 내가 남긴 댓글 조회 API TEST
- */
-
- @DisplayName("내가 남긴 댓글을 정확하게 조회한다.")
- @Test
- void 내가_남긴_댓글_조회_성공1(){
-
- // given
- Long memberId = 1L;
- int page = 0;
-
- // when
- HistoryResponseDTO.HistoryMyCommentListResult result = historyService.getMyComments(memberId,page);
-
- //then
- // HistoryMyCommentListResult 내용 확인
- assertThat(result)
- .extracting("totalPage","totalElements","isFirst","isLast")
- .containsExactly(1,5L,true,true);
- assertThat(result.getHistories().size()).isEqualTo(3);
-
- // HistoryMyCommentResult 내용 확인
- HistoryResponseDTO.HistoryMyCommentResult historyCommentResult1 = result.getHistories().get(0);
- HistoryResponseDTO.HistoryMyCommentResult historyCommentResult2 = result.getHistories().get(1);
- HistoryResponseDTO.HistoryMyCommentResult historyCommentResult3 = result.getHistories().get(2);
-
- assertThat(historyCommentResult1)
- .extracting("historyId","nickname","imageUrl","date")
- .containsExactly(1L,"User1", "https://example.com/images/new_year.jpg", LocalDate.of(2025,1,1));
- assertThat(historyCommentResult1.getComments().size()).isEqualTo(2);
-
- assertThat(historyCommentResult2)
- .extracting("historyId","nickname","imageUrl","date")
- .containsExactly(2L,"User1", "https://example.com/images/reading.jpg", LocalDate.of(2025,1,2));
- assertThat(historyCommentResult2.getComments().size()).isEqualTo(1);
-
- assertThat(historyCommentResult3)
- .extracting("historyId","nickname","imageUrl","date")
- .containsExactly(5L,"User3", "https://example.com/images/christmas.jpg", LocalDate.of(2024,12,25));
- assertThat(historyCommentResult3.getComments().size()).isEqualTo(2);
-
- // MyCommentResult 확인
- HistoryResponseDTO.MyCommentResult history1Comment1 = historyCommentResult1.getComments().get(0);
- assertThat(history1Comment1.getContent()).isEqualTo("첫 번째 댓글");
-
- HistoryResponseDTO.MyCommentResult history1Comment2 = historyCommentResult1.getComments().get(1);
- assertThat(history1Comment2.getContent()).isEqualTo("첫 번째 댓글");
-
- HistoryResponseDTO.MyCommentResult history2Comment1 = historyCommentResult2.getComments().get(0);
- assertThat(history2Comment1.getContent()).isEqualTo("hi");
-
- HistoryResponseDTO.MyCommentResult history3Comment1 = historyCommentResult3.getComments().get(0);
- assertThat(history3Comment1.getContent()).isEqualTo("다섯 번째 댓글에 대한 대댓글");
-
- HistoryResponseDTO.MyCommentResult history3Comment2 = historyCommentResult3.getComments().get(1);
- assertThat(history3Comment2.getContent()).isEqualTo("다섯 번째 댓글에 대한 대댓글");
- }
-
-}
diff --git a/src/test/java/com/clokey/server/domain/history/domain/repository/CommentRepositoryTest.java b/src/test/java/com/clokey/server/domain/history/domain/repository/CommentRepositoryTest.java
deleted file mode 100644
index 8920a641..00000000
--- a/src/test/java/com/clokey/server/domain/history/domain/repository/CommentRepositoryTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-package com.clokey.server.domain.history.domain.repository;
-
-import com.clokey.server.domain.JpaIntegrationTestSupport;
-import com.clokey.server.domain.history.domain.entity.Comment;
-import com.clokey.server.domain.history.domain.entity.History;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.model.entity.enums.MemberStatus;
-import com.clokey.server.domain.model.entity.enums.SocialType;
-import com.clokey.server.domain.model.entity.enums.Visibility;
-import org.junit.jupiter.api.*;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-
-
-import java.time.LocalDate;
-
-import static org.assertj.core.api.Assertions.assertThat;
-/*
-
-class CommentRepositoryTest extends JpaIntegrationTestSupport {
-
- @Autowired
- private MemberRepository memberRepository;
- @Autowired
- private HistoryRepository historyRepository;
- @Autowired
- private CommentRepository commentRepository;
-*/
-/*
- @BeforeAll
- void setup() {
-
- Member member1 = memberRepository.save(Member.builder()
- .email("user1@example.com")
- .nickname("User1")
- .clokeyId("clokey1")
- .bio("첫 번째 사용자")
- .profileImageUrl("https://example.com/user1.png")
- .socialType(SocialType.KAKAO)
- .status(MemberStatus.ACTIVE)
- .visibility(Visibility.PUBLIC)
- .build());
-
- Member member2 = memberRepository.save(Member.builder()
- .email("user2@example.com")
- .nickname("User2")
- .clokeyId("clokey2")
- .bio("두 번째 사용자")
- .profileImageUrl("https://example.com/user2.png")
- .socialType(SocialType.APPLE)
- .status(MemberStatus.ACTIVE)
- .visibility(Visibility.PUBLIC)
- .build());
-
- Member member3 = memberRepository.save(Member.builder()
- .email("user3@example.com")
- .nickname("User3")
- .clokeyId("clokey3")
- .bio("세 번째 사용자")
- .profileImageUrl("https://example.com/user3.png")
- .socialType(SocialType.KAKAO)
- .status(MemberStatus.ACTIVE)
- .visibility(Visibility.PUBLIC)
- .build());
-
- History history1 = historyRepository.save(History.builder()
- .historyDate(LocalDate.of(2025, 1, 1))
- .likes(3)
- .visibility(Visibility.PUBLIC)
- .content("새해 첫 기록")
- .member(member1)
- .banned(false)
- .build());
-
- History history2 = historyRepository.save(History.builder()
- .historyDate(LocalDate.of(2025, 1, 2))
- .likes(1)
- .visibility(Visibility.PUBLIC)
- .content("두 번째 기록")
- .member(member2)
- .banned(false)
- .build());
-
-
- Comment root1 = commentRepository.save(Comment.builder()
- .content("좋은 글이네요!")
- .member(member2)
- .history(history1)
- .build());
-
- Comment root2 = commentRepository.save(Comment.builder()
- .content("정말 공감합니다.")
- .member(member3)
- .history(history1)
- .build());
-
- Comment root3 = commentRepository.save(Comment.builder()
- .content("저도 비슷한 경험이 있어요.")
- .member(member1)
- .history(history2)
- .banned(true)
- .build());
-
-
- Comment reply1 = commentRepository.save(Comment.builder()
- .content("감사합니다!")
- .member(member1)
- .history(history1)
- .comment(root1)
- .build());
-
- Comment reply2 = commentRepository.save(Comment.builder()
- .content("맞아요. 저도 공감돼요.")
- .member(member2)
- .history(history1)
- .comment(root2)
- .build());
-
- Comment reply3 = commentRepository.save(Comment.builder()
- .content("혹시 어떤 경험이셨는지 공유해 주실 수 있나요?")
- .member(member3)
- .history(history2)
- .comment(root3)
- .build());
-
- Comment reply4 = commentRepository.save(Comment.builder()
- .content("댓글이 도움이 되었어요.")
- .member(member1)
- .history(history2)
- .comment(root3)
- .banned(true)
- .build());
- }*//*
-
-
- @DisplayName("특정 기록에 신고 당하지 않은 root 댓글 개수를 반환합니다")
- @Test
- void 신고당하지_않은_root_댓글_조회() {
-
- // given & when
- int count = commentRepository.countActiveRootComments(1L);
-
- // then
- assertThat(count).isEqualTo(2);
- }
-
- @DisplayName("특정 댓글의 소유권을 확인합니다")
- @ParameterizedTest(name = "commentId={0}, memberId={1}, expected={2}")
- @CsvSource(
- value = {
- "1,2,true",
- "2,3,true",
- "10,1,false",
- "10,2,false"
- }
- )
- void 특정_댓글의_소유권_확인(Long commentId, Long memberId, boolean expected) {
-
- // given & when
- boolean answer = commentRepository.existsByIdAndMemberId(commentId, memberId);
-
- // then
- assertThat(answer).isEqualTo(expected);
- }
-
- @DisplayName("특정 댓글이 특정 기록의 댓글인지 확인합니다")
- @ParameterizedTest(name = "commentId={0}, historyId={1}, expected={2}")
- @CsvSource(
- value = {
- "1,1,true",
- "2,1,true",
- "3,10,false",
- "4,10,false"
- }
- )
- void 특정_댓글이_특정_기록의_댓글(Long commentId, Long historyId, boolean expected) {
-
- // given & when
- boolean answer = commentRepository.existsByIdAndHistoryId(commentId, historyId);
-
- // then
- assertThat(answer).isEqualTo(expected);
- }
-
- @DisplayName("특정 기록의 댓글수를 반환합니다")
- @ParameterizedTest(name = "historyId={0}, expected={1}")
- @CsvSource(
- value = {
- "1,4",
- "2,3",
- }
- )
- void 특정_기록의_댓글수_조회(Long historyId, Long expected) {
-
- // given & when
- Long answer = commentRepository.countByHistoryId(historyId);
-
- // then
- assertThat(answer).isEqualTo(expected);
- }
-
- @DisplayName("특정 유저가 작성한 댓글을 history와 함께 가져옵니다.")
- @Test
- void 작성_댓글_기록_JOIN() {
- // given
- Long memberId = 1L;
-
- // when
- Page comments = commentRepository.findByMember_Id(memberId, Pageable.ofSize(10));
-
- // then
- assertThat(comments.getTotalElements()).isEqualTo(3);
- }
-
-}
-
-*/
diff --git a/src/test/java/com/clokey/server/domain/history/domain/repository/HashtagHistoryRepositoryTest.java b/src/test/java/com/clokey/server/domain/history/domain/repository/HashtagHistoryRepositoryTest.java
deleted file mode 100644
index 9bb17f42..00000000
--- a/src/test/java/com/clokey/server/domain/history/domain/repository/HashtagHistoryRepositoryTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-package com.clokey.server.domain.history.domain.repository;
-
-import com.clokey.server.domain.JpaIntegrationTestSupport;
-import com.clokey.server.domain.history.domain.entity.Hashtag;
-import com.clokey.server.domain.history.domain.entity.HashtagHistory;
-import com.clokey.server.domain.history.domain.entity.History;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.model.entity.enums.MemberStatus;
-import com.clokey.server.domain.model.entity.enums.SocialType;
-import com.clokey.server.domain.model.entity.enums.Visibility;
-import com.clokey.server.global.config.QuerydslConfig;
-import org.junit.jupiter.api.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.context.annotation.Import;
-import org.springframework.test.context.ActiveProfiles;
-
-import java.time.LocalDate;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class HashtagHistoryRepositoryTest extends JpaIntegrationTestSupport {
-
-
- @Autowired
- private MemberRepository memberRepository;
- @Autowired
- private HistoryRepository historyRepository;
- @Autowired
- private HashtagRepository hashtagRepository;
- @Autowired
- private HashtagHistoryRepository hashtagHistoryRepository;
-*/
-/*
- @BeforeAll
- void setup() {
-
-
- Member member1 = memberRepository.save(
- Member.builder()
- .email("user1@example.com")
- .nickname("User1")
- .clokeyId("clokey1")
- .bio("안녕하세요, User1입니다.")
- .socialType(SocialType.APPLE)
- .profileImageUrl("https://example.com/user1.png")
- .status(MemberStatus.ACTIVE)
- .visibility(Visibility.PUBLIC)
- .build()
- );
-
- History history1 = historyRepository.save(
- History.builder()
- .historyDate(LocalDate.of(2025, 1, 1))
- .likes(5)
- .visibility(Visibility.PUBLIC)
- .content("새해 첫 기록입니다.")
- .member(member1)
- .banned(false)
- .build()
- );
-
- History history2 = historyRepository.save(
- History.builder()
- .historyDate(LocalDate.of(2025, 1, 2))
- .likes(2)
- .visibility(Visibility.PUBLIC)
- .content("여행을 다녀왔어요.")
- .member(member1)
- .banned(false)
- .build()
- );
-
- Hashtag tagSpring = hashtagRepository.save(
- Hashtag.builder().name("봄").build()
- );
-
- Hashtag tagTravel = hashtagRepository.save(
- Hashtag.builder().name("여행").build()
- );
-
- hashtagHistoryRepository.saveAll(List.of(
- HashtagHistory.builder().hashtag(tagSpring).history(history1).build(),
- HashtagHistory.builder().hashtag(tagTravel).history(history1).build(),
- HashtagHistory.builder().hashtag(tagTravel).history(history2).build()
- ));
- }*//*
-
-
- @DisplayName("기록의 ID를 기준으로 HashtagHistory를 모두 가져옵니다")
- @Test
- void 특정_기록에_기록된_해시태그_기록_조회() {
-
- // given & when
- List hashtags = hashtagHistoryRepository.findByHistory_Id(1L);
-
- // then
- assertThat(hashtags.size()).isEqualTo(2);
- assertThat(hashtags.get(0).getHashtag().getName()).isEqualTo("봄");
- assertThat(hashtags.get(1).getHashtag().getName()).isEqualTo("여행");
- }
-
- @DisplayName("기록의 ID를 기준으로 Hashtag 이름들을 모두 가져옵니다")
- @Test
- void 특정_기록에_등록된_해시태그_이름_조회() {
-
- // given & when
- List hashtags = hashtagHistoryRepository.findHashtagNamesByHistoryId(1L);
-
- // then
- assertThat(hashtags.size()).isEqualTo(2);
- assertThat(hashtags.get(0)).isEqualTo("봄");
- assertThat(hashtags.get(1)).isEqualTo("여행");
- }
-}
-*/
diff --git a/src/test/java/com/clokey/server/domain/history/domain/repository/HashtagRepositoryTest.java b/src/test/java/com/clokey/server/domain/history/domain/repository/HashtagRepositoryTest.java
deleted file mode 100644
index 3e30fbab..00000000
--- a/src/test/java/com/clokey/server/domain/history/domain/repository/HashtagRepositoryTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-package com.clokey.server.domain.history.domain.repository;
-
-import com.clokey.server.domain.JpaIntegrationTestSupport;
-import com.clokey.server.domain.history.domain.entity.Hashtag;
-import com.clokey.server.domain.history.domain.entity.HashtagHistory;
-import com.clokey.server.domain.history.domain.entity.History;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.model.entity.enums.MemberStatus;
-import com.clokey.server.domain.model.entity.enums.SocialType;
-import com.clokey.server.domain.model.entity.enums.Visibility;
-import org.junit.jupiter.api.*;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.time.LocalDate;
-import java.util.List;
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-
-class HashtagRepositoryTest extends JpaIntegrationTestSupport {
-
- @Autowired private MemberRepository memberRepository;
- @Autowired private HistoryRepository historyRepository;
- @Autowired private HashtagRepository hashtagRepository;
- @Autowired private HashtagHistoryRepository hashtagHistoryRepository;
-*/
-/*
- @BeforeAll
- void setup() {
-
-
- Member member1 = memberRepository.save(
- Member.builder()
- .email("user1@example.com")
- .nickname("User1")
- .clokeyId("clokey1")
- .bio("안녕하세요, User1입니다.")
- .socialType(SocialType.APPLE)
- .profileImageUrl("https://example.com/user1.png")
- .status(MemberStatus.ACTIVE)
- .visibility(Visibility.PUBLIC)
- .build()
- );
-
- History history1 = historyRepository.save(
- History.builder()
- .historyDate(LocalDate.of(2025, 1, 1))
- .likes(5)
- .visibility(Visibility.PUBLIC)
- .content("새해 첫 기록입니다.")
- .member(member1)
- .banned(false)
- .build()
- );
-
- History history2 = historyRepository.save(
- History.builder()
- .historyDate(LocalDate.of(2025, 1, 2))
- .likes(2)
- .visibility(Visibility.PUBLIC)
- .content("여행을 다녀왔어요.")
- .member(member1)
- .banned(false)
- .build()
- );
-
- Hashtag tagSpring = hashtagRepository.save(
- Hashtag.builder().name("봄").build()
- );
-
- Hashtag tagTravel = hashtagRepository.save(
- Hashtag.builder().name("여행").build()
- );
-
- hashtagHistoryRepository.saveAll(List.of(
- HashtagHistory.builder().hashtag(tagSpring).history(history1).build(),
- HashtagHistory.builder().hashtag(tagTravel).history(history1).build(),
- HashtagHistory.builder().hashtag(tagTravel).history(history2).build()
- ));
- }*//*
-
-
- @DisplayName("특정 해시태그를 이름을 기준으로 조회가 가능합니다.")
- @Test
- void 특정_해시태그_이름_기준_조회() {
-
- // given & when
- Optional hashtag = hashtagRepository.findByName("봄");
-
- // then
- assertThat(hashtag.get().getName()).isEqualTo("봄");
- }
-
- @DisplayName("다수의 해시태그를 이름으로 조회할 수 있다.")
- @Test
- void 해시태그들_이름_기준_조회() {
-
- // given & when
- List hashtags = hashtagRepository.findHashtagsByNames(List.of("봄","여행"));
-
- // then
- assertThat(hashtags.size()).isEqualTo(2);
- assertThat(hashtags.get(0).getId()).isEqualTo(1L);
- assertThat(hashtags.get(1).getId()).isEqualTo(2L);
- }
-
- @DisplayName("존재하는 해시태그들의 존재 여부를 확인할 수 있다.")
- @ParameterizedTest(name = "hashtagName={0}, answer={1}")
- @CsvSource(
- value = {
- "봄,true",
- "여행,true",
- "없는 예시1,false",
- "없는 예시2,false"
- }
- )
- void 해시태그_존재_여부_확인(String hashtagName, boolean answer) {
-
- // given & when
- boolean exists = hashtagRepository.existsByName(hashtagName);
-
- // then
- assertThat(exists).isEqualTo(answer);
- }
-
-}
-*/
diff --git a/src/test/java/com/clokey/server/domain/history/domain/repository/HistoryClothRepositoryTest.java b/src/test/java/com/clokey/server/domain/history/domain/repository/HistoryClothRepositoryTest.java
deleted file mode 100644
index 09e8beb5..00000000
--- a/src/test/java/com/clokey/server/domain/history/domain/repository/HistoryClothRepositoryTest.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-package com.clokey.server.domain.history.domain.repository;
-
-import com.clokey.server.domain.JpaIntegrationTestSupport;
-import com.clokey.server.domain.category.domain.entity.Category;
-import com.clokey.server.domain.category.domain.repostiory.CategoryRepository;
-import com.clokey.server.domain.cloth.domain.entity.Cloth;
-import com.clokey.server.domain.cloth.domain.entity.ClothImage;
-import com.clokey.server.domain.cloth.domain.repository.ClothImageRepository;
-import com.clokey.server.domain.cloth.domain.repository.ClothRepository;
-import com.clokey.server.domain.history.domain.entity.*;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.model.entity.enums.MemberStatus;
-import com.clokey.server.domain.model.entity.enums.SocialType;
-import com.clokey.server.domain.model.entity.enums.ThicknessLevel;
-import com.clokey.server.domain.model.entity.enums.Visibility;
-import com.clokey.server.global.config.QuerydslConfig;
-import org.junit.jupiter.api.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.context.annotation.Import;
-import org.springframework.test.context.ActiveProfiles;
-
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class HistoryClothRepositoryTest extends JpaIntegrationTestSupport {
-
- @Autowired
- private MemberRepository memberRepository;
-
- @Autowired
- private HistoryRepository historyRepository;
-
- @Autowired
- private HistoryClothRepository historyClothRepository;
-
- @Autowired
- private MemberLikeRepository memberLikeRepository;
-
- @Autowired
- private ClothRepository clothRepository;
-
- @Autowired
- private ClothImageRepository clothImageRepository;
-
- @Autowired
- private HistoryImageRepository historyImageRepository;
-
- @Autowired
- private CategoryRepository categoryRepository;
-*/
-/*
- @BeforeAll
- void setup() {
-
- Category topCategory = new Category(null, "상의", null);
- categoryRepository.save(topCategory);
-
- Member member1 = memberRepository.save(Member.builder().email("user1@example.com").nickname("User1").clokeyId("clokey1").bio("안녕하세요, User1입니다.").socialType(SocialType.KAKAO).profileImageUrl("https://example.com/user1.png").status(MemberStatus.ACTIVE).inactiveDate(null).visibility(Visibility.PUBLIC).build());
- Member member2 = memberRepository.save(Member.builder().email("user2@example.com").nickname("User2").clokeyId("clokey2").bio("여행을 좋아하는 User2입니다.").socialType(SocialType.KAKAO).profileImageUrl("https://example.com/user2.png").status(MemberStatus.ACTIVE).visibility(Visibility.PRIVATE).build());
- Member member3 = memberRepository.save(Member.builder().email("user3@example.com").nickname("User3").clokeyId("clokey3").bio("개발자가 되고 싶은 User3입니다.").socialType(SocialType.APPLE).profileImageUrl("https://example.com/user3.png").status(MemberStatus.INACTIVE).inactiveDate(LocalDate.now()).visibility(Visibility.PUBLIC).build());
- Member member4 = memberRepository.save(Member.builder().email("user4@example.com").nickname("User4").clokeyId("clokey4").bio("영화를 좋아하는 User4입니다.").socialType(SocialType.APPLE).profileImageUrl("https://example.com/user4.png").status(MemberStatus.ACTIVE).visibility(Visibility.PUBLIC).build());
- Member member5 = memberRepository.save(Member.builder().email("user5@example.com").nickname("User5").clokeyId("clokey5").bio("독서를 즐기는 User5입니다.").socialType(SocialType.KAKAO).profileImageUrl("https://example.com/user5.png").status(MemberStatus.INACTIVE).inactiveDate(LocalDate.now()).visibility(Visibility.PRIVATE).build());
-
- History h1 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 1)).likes(5).visibility(Visibility.PUBLIC).content("새해 첫 기록입니다.").member(member1).banned(false).build());
- History h2 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 2)).likes(2).visibility(Visibility.PUBLIC).content("오늘은 책을 읽었습니다.").member(member1).banned(false).build());
- History h3 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 1)).likes(1).visibility(Visibility.PRIVATE).content("새해를 맞아 여행을 다녀왔습니다.").member(member2).banned(false).build());
- History h4 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 3)).likes(3).visibility(Visibility.PUBLIC).content("맛집을 다녀왔어요!").member(member2).banned(false).build());
- History h5 = historyRepository.save(History.builder().historyDate(LocalDate.of(2024, 12, 25)).likes(0).visibility(Visibility.PUBLIC).content("크리스마스에 쉬는 날을 보냈습니다.").member(member3).banned(false).build());
- History h6 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 5)).likes(1).visibility(Visibility.PRIVATE).content("새해 목표를 세웠습니다.").member(member3).banned(false).build());
- History h7 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 1)).likes(7).visibility(Visibility.PUBLIC).content("영화를 한 편 봤어요.").member(member4).banned(false).build());
- History h8 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 6)).likes(4).visibility(Visibility.PRIVATE).content("운동을 시작했습니다.").member(member4).banned(false).build());
- History h9 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 3)).likes(2).visibility(Visibility.PRIVATE).content("오늘은 도서관에서 시간을 보냈습니다.").member(member5).banned(false).build());
- History h10 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 4)).likes(1).visibility(Visibility.PUBLIC).content("독서 클럽에 참여했습니다.").member(member5).banned(false).build());
-
- memberLikeRepository.saveAll(List.of(
- new MemberLike(null, member1, h1),
- new MemberLike(null, member1, h2),
- new MemberLike(null, member2, h3),
- new MemberLike(null, member3, h4),
- new MemberLike(null, member3, h5),
- new MemberLike(null, member3, h6),
- new MemberLike(null, member4, h7),
- new MemberLike(null, member4, h8),
- new MemberLike(null, member5, h9),
- new MemberLike(null, member2, h2),
- new MemberLike(null, member4, h2),
- new MemberLike(null, member1, h10)
- ));
-
- List cloths = new ArrayList<>();
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("흰색 맨투맨")
- .wearNum(5)
- .visibility(Visibility.PUBLIC)
- .tempUpperBound(20)
- .tempLowerBound(10)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member1)
- .clothUrl("https://example.com/images/cloth1.jpg")
- .brand("브랜드A")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("청바지")
- .wearNum(15)
- .visibility(Visibility.PRIVATE)
- .tempUpperBound(15)
- .tempLowerBound(5)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member1)
- .clothUrl("https://example.com/images/cloth2.jpg")
- .brand("브랜드B")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("검은색 셔츠")
- .wearNum(10)
- .visibility(Visibility.PUBLIC)
- .tempUpperBound(25)
- .tempLowerBound(15)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member2)
- .clothUrl("https://example.com/images/cloth3.jpg")
- .brand("브랜드C")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("회색 코트")
- .wearNum(3)
- .visibility(Visibility.PUBLIC)
- .tempUpperBound(15)
- .tempLowerBound(0)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member2)
- .clothUrl("https://example.com/images/cloth4.jpg")
- .brand("브랜드D")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("검은색 슬랙스")
- .wearNum(8)
- .visibility(Visibility.PUBLIC)
- .tempUpperBound(20)
- .tempLowerBound(10)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member3)
- .clothUrl("https://example.com/images/cloth5.jpg")
- .brand("브랜드E")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("검은색 패딩")
- .wearNum(2)
- .visibility(Visibility.PRIVATE)
- .tempUpperBound(5)
- .tempLowerBound(-5)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member3)
- .clothUrl("https://example.com/images/cloth6.jpg")
- .brand("브랜드F")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("빨간색 니트")
- .wearNum(4)
- .visibility(Visibility.PRIVATE)
- .tempUpperBound(18)
- .tempLowerBound(8)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member4)
- .clothUrl("https://example.com/images/cloth7.jpg")
- .brand("브랜드G")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("파란색 청바지")
- .wearNum(12)
- .visibility(Visibility.PRIVATE)
- .tempUpperBound(15)
- .tempLowerBound(5)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member4)
- .clothUrl("https://example.com/images/cloth8.jpg")
- .brand("브랜드H")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("흰색 후드티")
- .wearNum(6)
- .visibility(Visibility.PUBLIC)
- .tempUpperBound(22)
- .tempLowerBound(12)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member5)
- .clothUrl("https://example.com/images/cloth9.jpg")
- .brand("브랜드I")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("검은색 자켓")
- .wearNum(5)
- .visibility(Visibility.PRIVATE)
- .tempUpperBound(10)
- .tempLowerBound(0)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member5)
- .clothUrl("https://example.com/images/cloth10.jpg")
- .brand("브랜드J")
- .build()));
-
- cloths.add(clothRepository.save(Cloth.builder()
- .name("흑청바지")
- .wearNum(0)
- .visibility(Visibility.PUBLIC)
- .tempUpperBound(15)
- .tempLowerBound(5)
- .thicknessLevel(ThicknessLevel.LEVEL_0)
- .category(topCategory)
- .member(member1)
- .clothUrl("https://example.com/images/cloth11.jpg")
- .brand("브랜드B")
- .build()));
-
-
- clothImageRepository.saveAll(List.of(
- new ClothImage(null, "https://example.com/images/cloth1_1.jpg", cloths.get(0)),
- new ClothImage(null, "https://example.com/images/cloth2_1.jpg", cloths.get(1)),
- new ClothImage(null, "https://example.com/images/cloth3_1.jpg", cloths.get(2)),
- new ClothImage(null, "https://example.com/images/cloth4_1.jpg", cloths.get(3)),
- new ClothImage(null, "https://example.com/images/cloth5_1.jpg", cloths.get(4)),
- new ClothImage(null, "https://example.com/images/cloth6_1.jpg", cloths.get(5)),
- new ClothImage(null, "https://example.com/images/cloth7_1.jpg", cloths.get(6)),
- new ClothImage(null, "https://example.com/images/cloth8_1.jpg", cloths.get(7))
- ));
-
- historyClothRepository.saveAll(List.of(
- HistoryCloth.builder().history(h1).cloth(cloths.get(0)).build(),
- HistoryCloth.builder().history(h2).cloth(cloths.get(1)).build(),
- HistoryCloth.builder().history(h3).cloth(cloths.get(2)).build(),
- HistoryCloth.builder().history(h4).cloth(cloths.get(3)).build(),
- HistoryCloth.builder().history(h5).cloth(cloths.get(4)).build(),
- HistoryCloth.builder().history(h6).cloth(cloths.get(5)).build(),
- HistoryCloth.builder().history(h7).cloth(cloths.get(6)).build(),
- HistoryCloth.builder().history(h8).cloth(cloths.get(7)).build(),
- HistoryCloth.builder().history(h9).cloth(cloths.get(8)).build(),
- HistoryCloth.builder().history(h10).cloth(cloths.get(9)).build()
- ));
-
- historyImageRepository.saveAll(List.of(
- HistoryImage.builder().imageUrl("https://example.com/images/new_year.jpg").history(h1).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/reading.jpg").history(h2).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/travel.jpg").history(h3).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/food.jpg").history(h4).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/christmas.jpg").history(h5).build(),
- HistoryImage.builder().imageUrl("https://example.com/imagefor6.jpg").history(h6).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/movie.jpg").history(h7).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/library.jpg").history(h9).build(),
- HistoryImage.builder().imageUrl("https://example.com/images/bookclub.jpg").history(h10).build()
- ));
-
- }*//*
-
-
- @DisplayName("특정 옷 ID를 기준으로 모든 기록-옷을 삭제합니다.")
- @Test
- void 특정_옷_기록_옷_삭제() {
- // given
- Long clothId = 1L;
-
- boolean existCheck = historyClothRepository.existsByClothId(clothId);
- assertThat(existCheck).isTrue();
-
- // when
- historyClothRepository.deleteAllByClothId(clothId);
-
- // then
- boolean newExistCheck = historyClothRepository.existsByClothId(clothId);
- assertThat(newExistCheck).isFalse();
- }
-
- @DisplayName("특정 기록과 옷을 기준으로 삭제합니다")
- @Test
- void 특정_기록_옷_기준_삭제() {
- // given
- History history = historyRepository.findById(1L).get();
- Cloth cloth = clothRepository.findById(1L).get();
-
- boolean existCheck = historyClothRepository.existsByHistoryIdAndClothId(1L, 1L);
- assertThat(existCheck).isTrue();
-
- // when
- historyClothRepository.deleteByHistoryAndCloth(history, cloth);
-
- // then
- boolean newExistCheck = historyClothRepository.existsByHistoryIdAndClothId(1L, 1L);
- assertThat(newExistCheck).isFalse();
- }
-
- @DisplayName("기록 Id를 기준으로 옷들의 Id를 찾을 수 있다.")
- @Test
- void 기록에_등록된_옷_ID_찿기() {
- // given
- Long historyId = 1L;
-
- // when
- List ids = historyClothRepository.findClothIdsByHistoryId(historyId);
-
- // then
- assertThat(ids).isEqualTo(List.of(1L));
- }
-
- @DisplayName("기록 Id를 기준으로 옷들을 찾을 수 있다.")
- @Test
- void 기록에_등록된_옷__찿기() {
- // given
- Long historyId = 1L;
-
- // when
- List cloths = historyClothRepository.findAllClothsByHistoryId(historyId);
-
- // then
- assertThat(cloths.size()).isEqualTo(1);
- assertThat(cloths.get(0).getId()).isEqualTo(1L);
- }
-
- @DisplayName("특정 기록에 등록된 기록-옷 전부 삭제")
- @Test
- void 특정_기록의_기록_옷_전부_삭제() {
- // given
- Long historyId = 1L;
-
- boolean existCheck = historyClothRepository.existsByHistoryId(historyId);
- assertThat(existCheck).isTrue();
-
- // when
- historyClothRepository.deleteAllByHistoryId(historyId);
-
- // then
- boolean newExistCheck = historyClothRepository.existsByHistoryId(historyId);
- assertThat(newExistCheck).isFalse();
- }
-
- @DisplayName("기록들에 등록된 기록-옷 전부 삭제")
- @Test
- void 기록들에_등록된_기록_옷_전부_삭제() {
- // given
- List ids = List.of(1L, 2L);
-
- boolean existCheck1 = historyClothRepository.existsByHistoryId(1L);
- boolean existCheck2 = historyClothRepository.existsByHistoryId(2L);
- assertThat(existCheck1).isTrue();
- assertThat(existCheck2).isTrue();
-
- // when
- historyClothRepository.deleteAllByHistoryIds(ids);
-
- // then
- boolean newExistCheck1 = historyClothRepository.existsByHistoryId(1L);
- boolean newExistCheck2 = historyClothRepository.existsByHistoryId(2L);
- assertThat(newExistCheck1).isFalse();
- assertThat(newExistCheck2).isFalse();
-
- }
-}
-
-*/
diff --git a/src/test/java/com/clokey/server/domain/history/domain/repository/HistoryImageRepositoryTest.java b/src/test/java/com/clokey/server/domain/history/domain/repository/HistoryImageRepositoryTest.java
deleted file mode 100644
index aa572c8b..00000000
--- a/src/test/java/com/clokey/server/domain/history/domain/repository/HistoryImageRepositoryTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
-package com.clokey.server.domain.history.domain.repository;
-
-import com.clokey.server.domain.JpaIntegrationTestSupport;
-import com.clokey.server.domain.history.domain.entity.History;
-import com.clokey.server.domain.history.domain.entity.HistoryImage;
-import com.clokey.server.domain.member.domain.entity.Member;
-import com.clokey.server.domain.member.domain.repository.MemberRepository;
-import com.clokey.server.domain.model.entity.enums.MemberStatus;
-import com.clokey.server.domain.model.entity.enums.SocialType;
-import com.clokey.server.domain.model.entity.enums.Visibility;
-import com.clokey.server.global.config.QuerydslConfig;
-import org.junit.jupiter.api.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.context.annotation.Import;
-import org.springframework.test.context.ActiveProfiles;
-
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class HistoryImageRepositoryTest extends JpaIntegrationTestSupport {
-
- @Autowired
- HistoryImageRepository historyImageRepository;
-
- @Autowired
- HistoryRepository historyRepository;
-
- @Autowired
- MemberRepository memberRepository;
-*/
-/*
- @BeforeAll
- void setUp() {
- Member member1 = memberRepository.save(Member.builder().email("user1@example.com").nickname("User1").clokeyId("clokey1").bio("안녕하세요, User1입니다.").socialType(SocialType.KAKAO).profileImageUrl("https://example.com/user1.png").status(MemberStatus.ACTIVE).inactiveDate(null).visibility(Visibility.PUBLIC).build());
-
- History h1 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 1)).likes(5).visibility(Visibility.PUBLIC).content("새해 첫 기록입니다.").member(member1).banned(false).build());
- History h2 = historyRepository.save(History.builder().historyDate(LocalDate.of(2025, 1, 2)).likes(2).visibility(Visibility.PUBLIC).content("오늘은 책을 읽었습니다.").member(member1).banned(false).build());
-
-
- List h1Images = IntStream.range(1, 4)
- .mapToObj(i -> HistoryImage.builder()
- .imageUrl("https://example.com/h1-img" + i + ".png")
- .history(h1)
- .build())
- .toList();
-
- List h2Images = IntStream.range(1, 4)
- .mapToObj(i -> HistoryImage.builder()
- .imageUrl("https://example.com/h2-img" + i + ".png")
- .history(h2)
- .build())
- .toList();
-
- historyImageRepository.saveAll(h1Images);
- historyImageRepository.saveAll(h2Images);
- }*//*
-
-
- @DisplayName("기록 Id를 기준으로 기록 사진 List를 반환할 수 있다")
- @Test
- void 기록의_사진_반환() {
- // given
- Long historyId = 1L;
-
- // when
- List historyImages = historyImageRepository.findByHistory_Id(historyId);
-
- // then
- assertThat(historyImages.stream()
- .map(HistoryImage::getId)
- .toList()).isEqualTo(List.of(1L, 2L, 3L));
- }
-
-
- @DisplayName("특정 기록의 사진을 만들어진 순서로 받아올 수 있다.")
- @Test
- void 특정_기록_사진_생성순() {
- // given
- Long historyId = 1L;
-
- // when
- List urls = historyImageRepository.getImageUrlsByHistoryIdOrderByCreatedAtAsc(historyId);
-
- // then
- assertThat(urls).isEqualTo(List.of("https://example.com/h1-img1.png", "https://example.com/h1-img2.png", "https://example.com/h1-img3.png"));
- }
-
- @DisplayName("특정 기록의 사진을 모두 지운다.")
- @Test
- void 특정_기록의_사진_모두_지우기() {
- // given
- Long historyId = 1L;
- List historyImages = historyImageRepository.findByHistory_Id(historyId);
-
- assertThat(historyImages.size()).isEqualTo(3);
-
- // when
- historyImageRepository.deleteAllByHistoryIds(List.of(historyId));
-
- // then
- List newHistoryImages = historyImageRepository.findByHistory_Id(historyId);
- assertThat(newHistoryImages.size()).isEqualTo(0);
- }
-
- @DisplayName("특정 기록들의 historyImage를 모두 가져온다")
- @Test
- void 기록들의_사진_모두_가져오기() {
- // given
- List historyIds = List.of(1L, 2L);
-
- // when
- List images = historyImageRepository.findByHistoryIdIn(historyIds);
-
- // then
- Set imageIds = images.stream()
- .map(HistoryImage::getId)
- .collect(Collectors.toSet());
- assertThat(imageIds).isEqualTo(Set.of(1L, 2L, 3L, 4L, 5L, 6L));
- }
-
- @DisplayName("기록들의 첫 번째 사진(대표사진)을 가져온다")
- @Test
- void 기록들의_대표사진_가져오기() {
- // given
- List ids = List.of(1L, 2L);
- List