Skip to content

Commit

Permalink
refactor(repository): thumbnailRepository.deleteAllByTemplateIds 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
kyum-q committed Oct 15, 2024
1 parent 2a7128f commit 2a04042
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ default Thumbnail fetchByTemplate(Template template) {

@Modifying(clearAutomatically = true)
@Query("DELETE FROM Thumbnail t WHERE t.template.id in :templateIds")
void deleteByTemplateIds(List<Long> templateIds);
void deleteAllByTemplateIds(List<Long> templateIds);

@Query("""
SELECT t, sc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public interface ThumbnailRepository {

Thumbnail save(Thumbnail thumbnail);

void deleteByTemplateIds(List<Long> ids);
void deleteAllByTemplateIds(List<Long> ids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public ExploreTemplatesResponse findAll() {

@Transactional
public void deleteAllByTemplateIds(List<Long> templateIds) {
thumbnailRepository.deleteByTemplateIds(templateIds);
thumbnailRepository.deleteAllByTemplateIds(templateIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Thumbnail save(Thumbnail entity) {
}

@Override
public void deleteByTemplateIds(List<Long> templateIds) {
public void deleteAllByTemplateIds(List<Long> templateIds) {
templateIds.forEach(id ->
thumbnails.removeIf(thumbnail -> Objects.equals(thumbnail.getId(), id)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void deleteByTemplateIdSuccess() {
sut.save(new Thumbnail(template, sourceCode));

// when
sut.deleteByTemplateIds(List.of(template.getId()));
sut.deleteAllByTemplateIds(List.of(template.getId()));

// then
assertThatThrownBy(() -> sut.fetchByTemplate(template))
Expand All @@ -136,7 +136,7 @@ void deleteByTemplateIdSuccess() {
@Test
@DisplayName("템플릿 id로 썸네일 삭제 성공: 존재하지 않는 템플릿의 id로 삭제해도 예외로 처리하지 않는다.")
void deleteByNotExistTemplateId() {
assertThatCode(() -> sut.deleteByTemplateIds(List.of(100L)))
assertThatCode(() -> sut.deleteAllByTemplateIds(List.of(100L)))
.doesNotThrowAnyException();
}
}
Expand Down

0 comments on commit 2a04042

Please sign in to comment.