### Question:
JpaWidgetRepository implements WidgetRepository { @Override public WidgetRating updateWidgetRating(String widgetId, WidgetRating rating) { JpaWidgetRating jpaItem = ratingConverter.convert(rating, widgetId); return saveOrUpdate(jpaItem.getEntityId(), manager, jpaItem); }  @Override List<Widget> getAll(); @Override List<Widget> getLimitedList(int offset, int pageSize); @Override int getCountAll(); @Override List<Widget> getByFreeTextSearch(String searchTerm, int offset, int pageSize); @Override int getCountFreeTextSearch(String searchTerm); @Override List<Widget> getByStatus(WidgetStatus widgetStatus, int offset, int pageSize); @Override int getCountByStatus(WidgetStatus widgetStatus); @Override List<Widget> getByStatusAndTypeAndFreeTextSearch(WidgetStatus widgetStatus, String type, String searchTerm,
                                                            int offset, int pageSize); @Override int getCountByStatusAndTypeAndFreeText(WidgetStatus widgetStatus, String type, String searchTerm); @Override List<Widget> getByOwner(User owner, int offset, int pageSize); @Override int getCountByOwner(User owner, int offset, int pageSize); @Override JpaWidget getByUrl(String widgetUrl); @Override WidgetStatistics getWidgetStatistics(String widget_id, String user_id); @Override Map<String, WidgetRating> getUsersWidgetRatings(String user_id); @SuppressWarnings("unchecked") @Override Map<String, WidgetStatistics> getAllWidgetStatistics(String userId); @Override List<Widget> getWidgetsByTag(String tagKeyword, int offset, int pageSize); @Override int getCountByTag(String tagKeyword); @Override int unassignWidgetOwner(String userId); @Override Class<? extends Widget> getType(); @Override Widget get(String id); @Override Widget save(Widget item); @Override void delete(Widget item); @Override WidgetTag getTagByWidgetIdAndKeyword(String widgetId, String keyword); @Override WidgetTag getTagById(String widgetTagId); @Override WidgetTag saveWidgetTag(String widgetId, WidgetTag tag); @Override void deleteWidgetTag(WidgetTag tag); @Override WidgetComment getCommentById(String widgetId, String widgetCommentId); @Override WidgetComment createWidgetComment(String widgetId, WidgetComment comment); @Override WidgetComment updateWidgetComment(String widgetId, WidgetComment comment); @Override void deleteWidgetComment(String widgetId, WidgetComment comment); @Override int deleteAllWidgetComments(String userId); @Override WidgetRating getRatingById(String widgetId, String widgetRatingId); @Override WidgetRating createWidgetRating(String widgetId, WidgetRating rating); @Override WidgetRating updateWidgetRating(String widgetId, WidgetRating rating); @Override void deleteWidgetRating(String widgetId, WidgetRating rating); @Override WidgetRating getWidgetRatingsByWidgetIdAndUserId(String widgetId, String userId); @Override int deleteAllWidgetRatings(String userId);  }### Answer:
@Test @Ignore @Transactional(readOnly = false) @Rollback public void updateWidgetRating() { Widget widget = repository.get("4"); assertNotNull(widget.getRatings()); WidgetRating widgetRating = new JpaWidgetRating(); widgetRating.setScore(10); widgetRating.setUserId("1"); widget.getRatings().add(widgetRating); repository.save(widget); Widget reloadedWidget = repository.get("4"); List<WidgetRating> widgetRatings = reloadedWidget.getRatings(); assertNotNull(widgetRatings); assertEquals(1, widgetRatings.size()); WidgetRating reloadedWidgetRating = widgetRatings.get(0); assertNotNull(reloadedWidgetRating); assertEquals(widgetRating.getScore(), reloadedWidgetRating.getScore()); assertEquals(widgetRating.getUserId(), reloadedWidgetRating.getUserId()); reloadedWidgetRating.setScore(0); repository.save(reloadedWidget); reloadedWidget = repository.get("4"); widgetRatings = reloadedWidget.getRatings(); assertNotNull(widgetRatings); assertEquals(1, widgetRatings.size()); reloadedWidgetRating = widgetRatings.get(0); assertNotNull(reloadedWidgetRating); assertEquals(widgetRating.getScore(), reloadedWidgetRating.getScore()); assertEquals(widgetRating.getUserId(), reloadedWidgetRating.getUserId()); }