use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class CategoriesResourceTest method shouldGetNoCategory.
@Test
public void shouldGetNoCategory() {
final Response response = target().queryParam("page", 10).queryParam("size", 1).request().get();
assertEquals(HttpStatusCode.BAD_REQUEST_400, response.getStatus());
ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
List<Error> errors = errorResponse.getErrors();
assertNotNull(errors);
assertEquals(1, errors.size());
Error error = errors.get(0);
assertEquals("errors.pagination.invalid", error.getCode());
assertEquals("400", error.getStatus());
assertEquals("Pagination is not valid", error.getMessage());
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class CategoryResourceTest method shouldNotGetCategory.
@Test
public void shouldNotGetCategory() {
doThrow(new CategoryNotFoundException(UNKNOWN_CATEGORY)).when(categoryService).findNotHiddenById(UNKNOWN_CATEGORY);
final Response response = target(UNKNOWN_CATEGORY).request().get();
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.category.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Category [" + UNKNOWN_CATEGORY + "] 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 SubscriptionResourceTest method shouldNotGetSubscription.
@Test
public void shouldNotGetSubscription() {
final Response response = target(UNKNOWN_SUBSCRIPTION).request().get();
assertEquals(HttpStatusCode.NOT_FOUND_404, response.getStatus());
ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
List<Error> errors = errorResponse.getErrors();
assertNotNull(errors);
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class PermissionsResourceTest method shouldHaveBadRequestExceptionWithoutQueryParam.
@Test
public void shouldHaveBadRequestExceptionWithoutQueryParam() {
final Response response = target().request().get();
assertEquals(BAD_REQUEST_400, response.getStatus());
List<Error> errors = response.readEntity(ErrorResponse.class).getErrors();
Error error = errors.get(0);
assertNotNull(error);
assertEquals("errors.unexpected", error.getCode());
assertEquals("One of the two parameters appId or applicationId must not be null.", error.getMessage());
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class PermissionsResourceTest method shouldHaveApiNotFoundExceptionWithFakeApiId.
@Test
public void shouldHaveApiNotFoundExceptionWithFakeApiId() {
final Response response = target().queryParam("apiId", "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.api.notFound", error.getCode());
assertEquals("Api [fake] can not be found.", error.getMessage());
}
Aggregations