use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingsResourceTest method shouldNotFoundWhileGettingApiRatings.
@Test
public void shouldNotFoundWhileGettingApiRatings() {
// 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("ratings").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 ApplicationMembersResourceTest method shouldHaveBadRequestWhileCreatingNewMemberAsPrimaryOwner.
// 400 POST /members
@Test
public void shouldHaveBadRequestWhileCreatingNewMemberAsPrimaryOwner() {
MemberInput memberInput = new MemberInput().role("PRIMARY_OWNER").user(MEMBER_1);
final Response response = target(APPLICATION).path("members").request().post(Entity.json(memberInput));
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("An APPLICATION must always have only one PRIMARY_OWNER !", error.getMessage());
}
use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiPagesResourceTest method shouldNotFoundWhileGettingApiPages.
@Test
public void shouldNotFoundWhileGettingApiPages() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
when(accessControlService.canAccessApiFromPortal(API)).thenReturn(false);
// test
final Response response = target(API).path("pages").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 shouldNotFoundApiWhileGettingApiPageContent.
@Test
public void shouldNotFoundApiWhileGettingApiPageContent() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
doReturn(false).when(accessControlService).canAccessApiFromPortal(API);
// test
final Response response = target(API).path("pages").path(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);
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 shouldNotFoundPageWhileGettingApiPage.
@Test
public void shouldNotFoundPageWhileGettingApiPage() {
doThrow(new PageNotFoundException(UNKNOWN_PAGE)).when(pageService).findById(UNKNOWN_PAGE, null);
final Response response = target(API).path("pages").path(UNKNOWN_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);
assertEquals("errors.page.notFound", error.getCode());
assertEquals("404", error.getStatus());
assertEquals("Page [" + UNKNOWN_PAGE + "] can not be found.", error.getMessage());
}
Aggregations