File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/test/java/com/codesungrape/hmcts/bookapi Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -319,4 +319,20 @@ void testDeleteBookById_Success() {
319319 verify (testBookRepository , times (1 )).findById (testId );
320320 verify (testBookRepository , times (1 )).save (persistedBook );
321321 }
322+
323+ @ Test
324+ void testDeleteBookById_ShouldDoNothing_WhenAlreadyDeleted () {
325+
326+ // Arrange:
327+ persistedBook .setDeleted (true ); // ensure starting state
328+ when (testBookRepository .findById (testId ))
329+ .thenReturn (Optional .of (persistedBook ));
330+
331+ // Act: call the service method we are testing
332+ testBookService .deleteBookById (testId );
333+
334+ // Assert
335+ // Verify save was NEVER called (it entered the 'false' branch of if)
336+ verify (testBookRepository , never ()).save (any (Book .class ));
337+ }
322338}
You can’t perform that action at this time.
0 commit comments