}
@Test public void updateWidgetRating() {
Widget widget = repository.get(4L);
assertNotNull(widget.getRatings());
WidgetRating widgetRating = new WidgetRating();
widgetRating.setScore(10);
widgetRating.setUserId(1L);
widgetRating.setWidgetId(widget.getEntityId());
widget.getRatings().add(widgetRating);
repository.save(widget);
Widget reloadedWidget = repository.get(4L);
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());
assertEquals(widget.getEntityId(), reloadedWidgetRating.getWidgetId());
reloadedWidgetRating.setScore(0);
repository.save(reloadedWidget);
reloadedWidget = repository.get(4L);
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());
assertEquals(widget.getEntityId(), reloadedWidgetRating.getWidgetId());
}