lab-3 delete removeFavorite method
This commit is contained in:
parent
8e13c1654e
commit
04fe7c7610
@ -97,13 +97,6 @@ public class UserService {
|
|||||||
return existsUser.addBook(book);
|
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)
|
@Transactional(readOnly = true)
|
||||||
public List<BookEntity> getUserFavorities (long userId) {
|
public List<BookEntity> getUserFavorities (long userId) {
|
||||||
return repository.getUserFavorities(userId);
|
return repository.getUserFavorities(userId);
|
||||||
|
@ -61,17 +61,5 @@ class FavoritesTests {
|
|||||||
book2 = bookService.get(book2.getId());
|
book2 = bookService.get(book2.getId());
|
||||||
Assertions.assertEquals(2, userService.getUserFavorities(user.getId()).size());
|
Assertions.assertEquals(2, userService.getUserFavorities(user.getId()).size());
|
||||||
Assertions.assertEquals(1, bookService.getBookSubscribersNumber(book2.getId()));
|
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()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user