use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class PermissionsResourceTest method shouldHaveApplicationNotFoundExceptionWithFakeApplicationId.
@Test
public void shouldHaveApplicationNotFoundExceptionWithFakeApplicationId() {
final Response response = target().queryParam("applicationId", "fake").request().get();
assertEquals(NOT_FOUND_404, response.getStatus());
List<Error> errors = response.readEntity(ErrorResponse.class).getErrors();
Error error = errors.get(0);
assertNotNull(error);
assertEquals("errors.application.notFound", error.getCode());
assertEquals("Application [fake] can not be found.", error.getMessage());
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingResourceTest method shouldHaveApiNotFoundWhenDeleteWithFakeApiId.
@Test
public void shouldHaveApiNotFoundWhenDeleteWithFakeApiId() {
final String fakeId = "fake";
final Response response = target(fakeId).path("ratings").path(RATING).request().delete();
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());
}
use of io.gravitee.rest.api.portal.rest.model.Error 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());
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingsResourceTest method shouldGetServiceUnavailable.
@Test
public void shouldGetServiceUnavailable() {
doThrow(ApiRatingUnavailableException.class).when(ratingService).create(any());
RatingInput ratingInput = new RatingInput().comment(RATING).value(1);
final Response response = target(API).path("ratings").request().post(Entity.json(ratingInput));
assertEquals(SERVICE_UNAVAILABLE_503, 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.disabled", error.getCode());
assertEquals("503", error.getStatus());
assertEquals("API rating service is unavailable.", error.getMessage());
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingsResourceTest method shouldNotFoundWhileCreatingApiRatings.
@Test
public void shouldNotFoundWhileCreatingApiRatings() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
doReturn(emptySet()).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
// test
RatingInput ratingInput = new RatingInput().comment(RATING).value(1);
final Response response = target(API).path("ratings").request().post(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 [" + API + "] can not be found.", error.getMessage());
}
Aggregations