Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package app.bottlenote.common.fixture;

import app.bottlenote.alcohols.domain.Alcohol;
import app.bottlenote.history.constant.EventCategory;
import app.bottlenote.history.constant.EventType;
import app.bottlenote.history.domain.UserHistory;
import app.bottlenote.user.domain.User;
import java.util.List;

/**
* 히스토리 테스트용 복합 데이터 record
*
* <p>기존 init-user-history.sql 대체용
*/
public record HistoryTestData(
List<User> users, List<Alcohol> alcohols, List<UserHistory> histories) {

/**
* 특정 인덱스의 사용자 반환
*
* @param index 0-based index
* @return User 객체
*/
public User getUser(int index) {
return users.get(index);
}

/**
* 특정 인덱스의 알코올 반환
*
* @param index 0-based index
* @return Alcohol 객체
*/
public Alcohol getAlcohol(int index) {
return alcohols.get(index);
}

/**
* 특정 사용자의 히스토리 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자의 히스토리 목록
*/
public List<UserHistory> getHistoriesByUser(Long userId) {
return histories.stream().filter(h -> h.getUserId().equals(userId)).toList();
}

/**
* 특정 이벤트 카테고리의 히스토리 목록 반환
*
* @param category 이벤트 카테고리
* @return 해당 카테고리의 히스토리 목록
*/
public List<UserHistory> getHistoriesByCategory(EventCategory category) {
return histories.stream().filter(h -> h.getEventCategory() == category).toList();
}

/**
* 특정 이벤트 타입의 히스토리 목록 반환
*
* @param eventType 이벤트 타입
* @return 해당 타입의 히스토리 목록
*/
public List<UserHistory> getHistoriesByEventType(EventType eventType) {
return histories.stream().filter(h -> h.getEventType() == eventType).toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package app.bottlenote.common.fixture;

import app.bottlenote.alcohols.domain.Alcohol;
import app.bottlenote.picks.domain.Picks;
import app.bottlenote.rating.domain.Rating;
import app.bottlenote.user.domain.Follow;
import app.bottlenote.user.domain.User;
import java.util.List;

/**
* 마이보틀 테스트용 복합 데이터 record
*
* <p>기존 init-user-mybottle-query.sql 대체용
*/
public record MyBottleTestData(
List<User> users,
List<Alcohol> alcohols,
List<Follow> follows,
List<Picks> picks,
List<Rating> ratings) {

/**
* 특정 인덱스의 사용자 반환
*
* @param index 0-based index
* @return User 객체
*/
public User getUser(int index) {
return users.get(index);
}

/**
* 특정 인덱스의 알코올 반환
*
* @param index 0-based index
* @return Alcohol 객체
*/
public Alcohol getAlcohol(int index) {
return alcohols.get(index);
}

/**
* 특정 사용자의 찜 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자의 찜 목록
*/
public List<Picks> getPicksByUser(Long userId) {
return picks.stream().filter(p -> p.getUserId().equals(userId)).toList();
}

/**
* 특정 사용자의 별점 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자의 별점 목록
*/
public List<Rating> getRatingsByUser(Long userId) {
return ratings.stream().filter(r -> r.getId().getUserId().equals(userId)).toList();
}

/**
* 특정 사용자가 팔로우하는 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자가 팔로우하는 Follow 목록
*/
public List<Follow> getFollowingsByUser(Long userId) {
return follows.stream().filter(f -> f.getUserId().equals(userId)).toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package app.bottlenote.common.fixture;

import app.bottlenote.alcohols.domain.Alcohol;
import app.bottlenote.rating.domain.Rating;
import app.bottlenote.review.domain.Review;
import app.bottlenote.user.domain.Follow;
import app.bottlenote.user.domain.User;
import java.util.List;

/**
* 마이페이지 테스트용 복합 데이터 record
*
* <p>기존 init-user-mypage-query.sql 대체용
*/
public record MyPageTestData(
List<User> users,
List<Alcohol> alcohols,
List<Review> reviews,
List<Follow> follows,
List<Rating> ratings) {

/**
* 특정 인덱스의 사용자 반환
*
* @param index 0-based index
* @return User 객체
*/
public User getUser(int index) {
return users.get(index);
}

/**
* 특정 인덱스의 알코올 반환
*
* @param index 0-based index
* @return Alcohol 객체
*/
public Alcohol getAlcohol(int index) {
return alcohols.get(index);
}

/**
* 특정 사용자의 리뷰 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자의 리뷰 목록
*/
public List<Review> getReviewsByUser(Long userId) {
return reviews.stream().filter(r -> r.getUserId().equals(userId)).toList();
}

/**
* 특정 사용자가 팔로우하는 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자가 팔로우하는 Follow 목록
*/
public List<Follow> getFollowingsByUser(Long userId) {
return follows.stream().filter(f -> f.getUserId().equals(userId)).toList();
}

/**
* 특정 사용자의 팔로워 목록 반환
*
* @param userId 사용자 ID
* @return 해당 사용자를 팔로우하는 Follow 목록
*/
public List<Follow> getFollowersByUser(Long userId) {
return follows.stream().filter(f -> f.getTargetUserId().equals(userId)).toList();
}
}
Loading