lab-3 #2

Merged
Zakharov_Rostislav merged 22 commits from lab-3 into main 2024-05-23 12:01:06 +04:00
2 changed files with 0 additions and 19 deletions
Showing only changes of commit 04fe7c7610 - Show all commits

View File

@ -97,13 +97,6 @@ public class UserService {
return existsUser.addBook(book);
}
@Transactional
public boolean removeFavorite(long userId, long bookId) {
final UserEntity existsUser = get(userId);
final BookEntity book = bookService.get(bookId);
return existsUser.removeBook(book);
}
@Transactional(readOnly = true)
public List<BookEntity> getUserFavorities (long userId) {
return repository.getUserFavorities(userId);

View File

@ -61,17 +61,5 @@ class FavoritesTests {
book2 = bookService.get(book2.getId());
Assertions.assertEquals(2, userService.getUserFavorities(user.getId()).size());
Assertions.assertEquals(1, bookService.getBookSubscribersNumber(book2.getId()));
userService.removeFavorite(user.getId(), book1.getId());
user = userService.get(user.getId());
book1 = bookService.get(book1.getId());
Assertions.assertEquals(1, userService.getUserFavorities(user.getId()).size());
Assertions.assertEquals(0, bookService.getBookSubscribersNumber(book1.getId()));
userService.removeFavorite(user.getId(), book2.getId());
user = userService.get(user.getId());
book2 = bookService.get(book2.getId());
Assertions.assertEquals(0, userService.getUserFavorities(user.getId()).size());
Assertions.assertEquals(0, bookService.getBookSubscribersNumber(book2.getId()));
}
}