public final class SetRating extends UpdateActionImpl<Review>
See also ReviewUpdateCommand.
withChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY, channel -> { withUpdateableReview(client(),builder -> builder.target(channel), (Review review) -> { final int rating = 44; final Review updatedReview = client().executeBlocking(ReviewUpdateCommand.of(review, SetRating.of(rating))); assertThat(updatedReview.getRating()).isEqualTo(rating); //you can observe a message assertEventually(() -> { final Query<ReviewRatingSetMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(review)) .forMessageType(ReviewRatingSetMessage.MESSAGE_HINT); final PagedQueryResult<ReviewRatingSetMessage> messages = client().executeBlocking(messageQuery); assertThat(messages.head()).isPresent(); final ReviewRatingSetMessage reviewRatingSetMessage = messages.head().get(); assertThat(reviewRatingSetMessage.getNewRating()).isEqualTo(rating); assertThat(reviewRatingSetMessage.getOldRating()).isEqualTo(100); assertThat(reviewRatingSetMessage.isIncludedInStatistics()).isTrue(); assertThat(reviewRatingSetMessage.getTarget()).isEqualTo(channel.toReference()); }); return updatedReview; }); });
See the test code.
Modifier and Type | Method and Description |
---|---|
Integer |
getRating() |
static SetRating |
of(Integer rating) |
getAction