diff --git a/src/main/java/doore/study/domain/Study.java b/src/main/java/doore/study/domain/Study.java index 923570a7..86aa9458 100644 --- a/src/main/java/doore/study/domain/Study.java +++ b/src/main/java/doore/study/domain/Study.java @@ -19,10 +19,12 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@SQLRestriction("is_deleted = false") @SQLDelete(sql = "UPDATE study SET is_deleted = true where id = ?") public class Study extends BaseEntity { diff --git a/src/test/java/doore/study/application/StudyCommandServiceTest.java b/src/test/java/doore/study/application/StudyCommandServiceTest.java index d8f63531..aa3853f6 100644 --- a/src/test/java/doore/study/application/StudyCommandServiceTest.java +++ b/src/test/java/doore/study/application/StudyCommandServiceTest.java @@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import doore.helper.IntegrationTest; @@ -240,7 +239,7 @@ void setUp() { void deleteStudy_정상적으로_스터디를_삭제할_수_있다_성공() throws Exception { studyCommandService.deleteStudy(study.getId(), memberId); final List studies = studyRepository.findAll(); - assertTrue(studies.get(0).getIsDeleted()); + assertThat(studies.size()).isEqualTo(0); } @Test @@ -254,8 +253,7 @@ void setUp() { study.getId()); assertThat(beforeCurriculumItems.size()).isEqualTo(2); - assertThat(afterCurriculumItems.get(0).getIsDeleted()).isEqualTo(true); - assertThat(afterCurriculumItems.get(1).getIsDeleted()).isEqualTo(true); + assertThat(afterCurriculumItems.size()).isEqualTo(0); } @Test