use of io.gravitee.rest.api.portal.rest.model.RatingInput in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingResourceTest method shouldUpdateApiRating.
@Test
public void shouldUpdateApiRating() {
RatingInput ratingInput = new RatingInput().comment(RATING).value(2);
Rating rating = new Rating();
rating.setId(RATING);
rating.setValue(2);
doReturn(rating).when(ratingMapper).convert(any(), any());
final Response response = target(API).path("ratings").path(RATING).request().put(Entity.json(ratingInput));
Rating updatedRatingResponse = response.readEntity(Rating.class);
assertNotNull(updatedRatingResponse);
assertEquals(rating.getValue(), updatedRatingResponse.getValue());
}
use of io.gravitee.rest.api.portal.rest.model.RatingInput in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingResourceTest method shouldHaveRatingNotFoundWhenUpdateWithFakeRatingId.
@Test
public void shouldHaveRatingNotFoundWhenUpdateWithFakeRatingId() {
RatingInput ratingInput = new RatingInput().comment(RATING).value(2);
final String fakeId = "fake";
final Response response = target(API).path("ratings").path(fakeId).request().put(Entity.json(ratingInput));
assertEquals(NOT_FOUND_404, response.getStatus());
ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
List<Error> errors = errorResponse.getErrors();
assertNotNull(errors);
assertEquals(1, errors.size());
Error error = errors.get(0);
assertNotNull(error);
assertEquals("errors.rating.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Rating [" + fakeId + "] can not be found on the api [" + API + "]", error.getMessage());
}
use of io.gravitee.rest.api.portal.rest.model.RatingInput in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingResourceTest method shouldHaveApiNotFoundWhenUpdateWithFakeApiId.
@Test
public void shouldHaveApiNotFoundWhenUpdateWithFakeApiId() {
RatingInput ratingInput = new RatingInput().comment(RATING).value(2);
final String fakeId = "fake";
final Response response = target(fakeId).path("ratings").path(RATING).request().put(Entity.json(ratingInput));
assertEquals(NOT_FOUND_404, response.getStatus());
ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
List<Error> errors = errorResponse.getErrors();
assertNotNull(errors);
assertEquals(1, errors.size());
Error error = errors.get(0);
assertNotNull(error);
assertEquals("errors.api.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Api [" + fakeId + "] can not be found.", error.getMessage());
}
Aggregations