Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] 방과 연관된 정보 삭제 테스트 활성화 #398

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
@@ -1,6 +1,5 @@
package ddangkong.domain.support;

import java.time.LocalDateTime;
import org.springframework.test.util.ReflectionTestUtils;

public class EntityTestUtils {
Expand All @@ -11,8 +10,4 @@ private EntityTestUtils() {
public static <T> void setId(T entity, Long id) {
ReflectionTestUtils.setField(entity, "id", id);
}

public static <T> void setLastModifiedAt(T entity, LocalDateTime lastModifiedAt) {
ReflectionTestUtils.setField(entity, "lastModifiedAt", lastModifiedAt);
}
}
14 changes: 5 additions & 9 deletions backend/src/test/java/ddangkong/facade/room/RoomFacadeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import ddangkong.domain.room.balance.roomcontent.RoomContent;
import ddangkong.domain.room.balance.roomvote.RoomBalanceVote;
import ddangkong.domain.room.member.Member;
import ddangkong.domain.support.EntityTestUtils;
import ddangkong.exception.room.NotFinishedRoomException;
import ddangkong.exception.room.NotFoundRoomException;
import ddangkong.exception.room.member.InvalidMemberIdException;
Expand All @@ -35,7 +34,6 @@
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -585,19 +583,17 @@ class 변경_시간이_특정_시각_이전_방_삭제 {
}

@Test
@Disabled
// TODO @LastModifiedDate 비활성화 후 테스트
void 해당_방과_연관된_모든_정보를_삭제할_수_있다() {
// given
LocalDateTime standardModified = LocalDateTime.of(2020, 1, 1, 0, 0, 0);
Room room = getSavedRoom(standardModified.minusSeconds(1));
Room room = getSavedRoom();
Member master = memberRepository.save(EDEN.master(room));
Member common = memberRepository.save(KEOCHAN.common(room));

BalanceContent balanceContent = balanceContentRepository.findById(1L).get();
RoomContent roomContent = getSavedRoomContent(room, balanceContent);
RoomBalanceVote roomVote = getSavedRoomBalanceVote(master, balanceContent);
long countOfTotalVotes = totalBalanceVoteRepository.count();
LocalDateTime standardModified = LocalDateTime.now();

// when
roomFacade.migrateExpiredRooms(standardModified);
Expand All @@ -613,13 +609,13 @@ class 변경_시간이_특정_시각_이전_방_삭제 {
() -> assertThat(deletedMember).isEmpty(),
() -> assertThat(deletedRoomContent).isEmpty(),
() -> assertThat(deletedRoomVote).isEmpty(),
() -> assertThat(afterCountOfTotalVotes).isEqualTo(countOfTotalVotes + 1)
() -> assertThat(afterCountOfTotalVotes).isGreaterThanOrEqualTo(countOfTotalVotes + 1)
// TODO init.sql 제거 후 isEqualTo로 변경 (현재 다른 방들의 표까지 이관되어 1표 이상으로 더 늘어남)
);
}

private Room getSavedRoom(LocalDateTime lastModifiedAt) {
private Room getSavedRoom() {
Room room = Room.createNewRoom();
EntityTestUtils.setLastModifiedAt(room, lastModifiedAt);
return roomRepository.save(room);
}

Expand Down