use of io.gravitee.rest.api.portal.rest.model.Error in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingsResourceTest method shouldBadRequestWhileCreatingApiRatings.
@Test
public void shouldBadRequestWhileCreatingApiRatings() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(userApi));
doReturn(mockApis).when(apiService).findPublishedByUser(any());
// test
final Response response = target(API).path("ratings").request().post(Entity.json(null));
assertEquals(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);
assertNotNull(error);
assertEquals("errors.unexpected", error.getCode());
assertEquals("400", error.getStatus());
assertEquals("Input 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 ApiResourceTest method shouldHaveNotFoundWhileGettingApiPicture.
@Test
public void shouldHaveNotFoundWhileGettingApiPicture() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(userApi));
doReturn(mockApis).when(apiService).findByUser(any(), any(), eq(true));
// test
final Response response = target(API).path("picture").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 ApiResourceTest method shouldHaveNotFoundWhileGettingApi.
@Test
public void shouldHaveNotFoundWhileGettingApi() {
// init
ApiEntity userApi = new ApiEntity();
userApi.setId("1");
doReturn(false).when(accessControlService).canAccessApiFromPortal(API);
// test
final Response response = target(API).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 shouldHaveBadRequestWhileUpdatingMemberToPrimaryOwner.
@Test
public void shouldHaveBadRequestWhileUpdatingMemberToPrimaryOwner() {
MemberInput memberInput = new MemberInput().role("PRIMARY_OWNER").user(MEMBER_1);
final Response response = target(APPLICATION).path("members").path(MEMBER_1).request().put(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 ApplicationMembersResourceTest method shouldHaveBadRequestWhileTransferingOwnerShipToPrimaryOwner.
// 400 POST /members/_transfer_ownership
@Test
public void shouldHaveBadRequestWhileTransferingOwnerShipToPrimaryOwner() {
TransferOwnershipInput input = new TransferOwnershipInput().newPrimaryOwnerId(MEMBER_1).primaryOwnerNewrole("PRIMARY_OWNER");
final Response response = target(APPLICATION).path("members").path("_transfer_ownership").request().post(Entity.json(input));
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());
}
Aggregations