Skip to content

Commit

Permalink
fix flashcard deletion (#58)
Browse files Browse the repository at this point in the history
* fix flashcard deletion

Signed-off-by: PaulBredl <[email protected]>

* fix test

Signed-off-by: PaulBredl <[email protected]>

---------

Signed-off-by: PaulBredl <[email protected]>
  • Loading branch information
PaulBredl authored Oct 13, 2023
1 parent 58744a3 commit bdd1a26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void deleteFlashcardSetIfContentIsDeleted(final ContentChangeEvent dto) t
return;
}

flashcardSetRepository.deleteAllByIdInBatch(dto.getContentIds());
flashcardSetRepository.deleteAllById(dto.getContentIds());
}
/**
* helper function to make sure received event message is complete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void removeContentIds() {

// invoke method under test
assertDoesNotThrow(() -> flashcardService.deleteFlashcardSetIfContentIsDeleted(contentChangeEvent));
verify(flashcardSetRepository, times(1)).deleteAllByIdInBatch(any());
verify(flashcardSetRepository, times(1)).deleteAllById(any());
}
@Test
void removeContentIdsWithNoIdsToBeRemovedTest() {
Expand All @@ -65,7 +65,7 @@ void removeContentIdsWithNoIdsToBeRemovedTest() {
// invoke method under test
assertDoesNotThrow(() -> flashcardService.deleteFlashcardSetIfContentIsDeleted(contentChangeEvent));

verify(flashcardSetRepository, times(1)).deleteAllByIdInBatch(any());
verify(flashcardSetRepository, times(1)).deleteAllById(any());
}

@Test
Expand Down Expand Up @@ -105,14 +105,14 @@ void removeContentIdsInvalidInputTest() {
//invoke method under test
assertDoesNotThrow(() -> flashcardService.deleteFlashcardSetIfContentIsDeleted(event));
verify(flashcardSetRepository, never()).findAllById(any());
verify(flashcardSetRepository, never()).deleteAllInBatch(any());
verify(flashcardSetRepository, never()).deleteAllById(any());
}

for (ContentChangeEvent errorEvent : errorEvents) {
//invoke method under test
assertThrows(IncompleteEventMessageException.class, () -> flashcardService.deleteFlashcardSetIfContentIsDeleted(errorEvent));
verify(flashcardSetRepository, never()).findAllById(any());
verify(flashcardSetRepository, never()).deleteAllInBatch(any());
verify(flashcardSetRepository, never()).deleteAllById(any());
}

}
Expand Down

0 comments on commit bdd1a26

Please sign in to comment.