use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiMetricsResourceTest method shouldNotFoundApiWhileGettingApiMetrics.
@Test
public void shouldNotFoundApiWhileGettingApiMetrics() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
doReturn(emptySet()).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
// test
final Response response = target(API).path("metrics").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.api.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Api [" + API + "] 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 ApiPageResourceTest method shouldNotFoundApiWhileGettingApiPage.
@Test
public void shouldNotFoundApiWhileGettingApiPage() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
doReturn(false).when(accessControlService).canAccessApiFromPortal(API);
// test
final Response response = target(API).path("pages").path(PAGE).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.api.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Api [" + API + "] 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 ApiPageResourceTest method shouldNotFoundPageWhileGettingApiPageContent.
@Test
public void shouldNotFoundPageWhileGettingApiPageContent() {
doThrow(new PageNotFoundException(UNKNOWN_PAGE)).when(pageService).findById(UNKNOWN_PAGE, null);
final Response response = target(API).path("pages").path(UNKNOWN_PAGE).path("content").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);
assertEquals("errors.page.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Page [" + UNKNOWN_PAGE + "] 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 ApiPlansResourceTest method shouldHaveNotFoundWhileGettingApiPlans.
@Test
public void shouldHaveNotFoundWhileGettingApiPlans() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
doReturn(emptySet()).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
// test
final Response response = target(API).path("plans").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.api.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Api [" + API + "] 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 ApiRatingAnswersResourceTest method shouldHaveRatingNotFoundWhenCreateApiRatingAnswerWithFakeRatingId.
@Test
public void shouldHaveRatingNotFoundWhenCreateApiRatingAnswerWithFakeRatingId() {
RatingAnswerInput ratingAnswerInput = new RatingAnswerInput().comment(RATING);
final String fakeId = "fake";
final Response response = target(API).path("ratings").path(fakeId).path("answers").request().post(Entity.json(ratingAnswerInput));
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());
}
Aggregations