Skip to content

Commit

Permalink
Merge pull request #377 from Sunagatov/bug/default-review-filter
Browse files Browse the repository at this point in the history
Removed null check for GetReviewsRequestValidator
  • Loading branch information
Sunagatov authored Sep 12, 2024
2 parents e1e16d0 + b26edc7 commit 5397a30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public void validate(final Integer pageNumber,

private StringBuilder validateProductRatingsParameter(final List<Integer> productRatings) {
final StringBuilder errorMessages = new StringBuilder();
if (productRatings == null) {
String errorMessage = String.format("product's rating is required. Allowed 'productRating' values are '%s'.", ALLOWED_PRODUCT_RATING_VALUES);
errorMessages.append(createErrorMessage(errorMessage));
}
if ((productRatings != null && productRatings.stream().anyMatch(Objects::isNull))
|| (productRatings != null && !ALLOWED_PRODUCT_RATING_VALUES.containsAll(productRatings))) {
String errorMessage = String.format("Some values of this product's rating list = '%s' are incorrect. Allowed 'productRating' values are '%s'.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.zufar.icedlatte.test.config.RestAssertion.assertRestApiBadRequestResponse;
import static com.zufar.icedlatte.test.config.RestAssertion.assertRestApiBodySchemaResponse;
import static com.zufar.icedlatte.test.config.RestAssertion.assertRestApiNotFoundResponse;
import static com.zufar.icedlatte.test.config.RestAssertion.assertRestApiOkResponse;
import static com.zufar.icedlatte.test.config.RestUtils.getJwtToken;
import static com.zufar.icedlatte.test.config.RestUtils.getRequestBody;
import static io.restassured.RestAssured.given;
Expand Down Expand Up @@ -159,8 +160,8 @@ void shouldFetchReviewStatsSuccessfully() {


@Test
@DisplayName("Reviews and ratings with default pagination and sorting for unauthorized user. Should return 400 Bad Request")
void shouldReturnBadRequestForDefaultPaginationAndSortingForAnonymous() {
@DisplayName("Reviews and ratings with default pagination and sorting for unauthorized user. Should return 200 OK")
void shouldSuccessfullyReturnReviewsForDefaultPaginationAndSortingForAnonymous() {
// No authorization is required
specification = given()
.log().all(true)
Expand All @@ -172,7 +173,7 @@ void shouldReturnBadRequestForDefaultPaginationAndSortingForAnonymous() {
Response response = given(specification)
.get("/{productId}/reviews", AMERICANO_ID);

assertRestApiBadRequestResponse(response, FAILED_REVIEW_SCHEMA);
assertRestApiOkResponse(response, REVIEWS_WITH_RATINGS_RESPONSE_SCHEMA);
}

@Test
Expand Down

0 comments on commit 5397a30

Please sign in to comment.