Search in sources :

Example 6 with ErrorResponse

use of io.gravitee.rest.api.portal.rest.model.ErrorResponse in project gravitee-management-rest-api by gravitee-io.

the class ApiRatingAnswerResourceTest method shouldHaveApiNotFoundWhenDeleteWithFakeApi.

@Test
public void shouldHaveApiNotFoundWhenDeleteWithFakeApi() {
    final String fakeId = "fake";
    final Response response = target(fakeId).path("ratings").path(RATING).path("answers").path(ANSWER).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());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) Error(io.gravitee.rest.api.portal.rest.model.Error) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Test(org.junit.Test)

Example 7 with ErrorResponse

use of io.gravitee.rest.api.portal.rest.model.ErrorResponse in project gravitee-management-rest-api by gravitee-io.

the class ApiRatingAnswerResourceTest method shouldHaveRatingAnswerNotFoundWhenDeleteWithFakeId.

@Test
public void shouldHaveRatingAnswerNotFoundWhenDeleteWithFakeId() {
    final String fakeId = "fake";
    final Response response = target(API).path("ratings").path(fakeId).path("answers").path(ANSWER).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.rating.notFound", error.getCode());
    assertEquals("404", error.getStatus());
    assertEquals("Rating [" + fakeId + "] can not be found on the api [" + API + "]", error.getMessage());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) Error(io.gravitee.rest.api.portal.rest.model.Error) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Test(org.junit.Test)

Example 8 with ErrorResponse

use of io.gravitee.rest.api.portal.rest.model.ErrorResponse in project gravitee-management-rest-api by gravitee-io.

the class ApiRatingAnswerResourceTest method shouldHaveRatingNotFoundWhenDeleteWithFakeRating.

@Test
public void shouldHaveRatingNotFoundWhenDeleteWithFakeRating() {
    final String fakeId = "fake";
    final Response response = target(API).path("ratings").path(fakeId).path("answers").path(ANSWER).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.rating.notFound", error.getCode());
    assertEquals("404", error.getStatus());
    assertEquals("Rating [" + fakeId + "] can not be found on the api [" + API + "]", error.getMessage());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) Error(io.gravitee.rest.api.portal.rest.model.Error) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Test(org.junit.Test)

Example 9 with ErrorResponse

use of io.gravitee.rest.api.portal.rest.model.ErrorResponse in project gravitee-management-rest-api by gravitee-io.

the class ApiRatingResourceTest method shouldHaveRatingNotFoundWhenUpdateWithFakeRatingId.

@Test
public void shouldHaveRatingNotFoundWhenUpdateWithFakeRatingId() {
    RatingInput ratingInput = new RatingInput().comment(RATING).value(2);
    final String fakeId = "fake";
    final Response response = target(API).path("ratings").path(fakeId).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.rating.notFound", error.getCode());
    assertEquals("404", error.getStatus());
    assertEquals("Rating [" + fakeId + "] can not be found on the api [" + API + "]", error.getMessage());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) RatingInput(io.gravitee.rest.api.portal.rest.model.RatingInput) Error(io.gravitee.rest.api.portal.rest.model.Error) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Test(org.junit.Test)

Example 10 with ErrorResponse

use of io.gravitee.rest.api.portal.rest.model.ErrorResponse in project gravitee-management-rest-api by gravitee-io.

the class ApiRatingResourceTest method shouldHaveRatingNotFoundWhenDeleteWithFakeRatingId.

@Test
public void shouldHaveRatingNotFoundWhenDeleteWithFakeRatingId() {
    final String fakeId = "fake";
    final Response response = target(API).path("ratings").path(fakeId).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.rating.notFound", error.getCode());
    assertEquals("404", error.getStatus());
    assertEquals("Rating [" + fakeId + "] can not be found on the api [" + API + "]", error.getMessage());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) Error(io.gravitee.rest.api.portal.rest.model.Error) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Test(org.junit.Test)

Aggregations

Error (io.gravitee.rest.api.portal.rest.model.Error)21 ErrorResponse (io.gravitee.rest.api.portal.rest.model.ErrorResponse)21 Response (javax.ws.rs.core.Response)19 Test (org.junit.Test)19 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)5 NOT_FOUND_404 (io.gravitee.common.http.HttpStatusCode.NOT_FOUND_404)3 OK_200 (io.gravitee.common.http.HttpStatusCode.OK_200)3 IOException (java.io.IOException)3 Collections.emptySet (java.util.Collections.emptySet)3 Collections.singletonList (java.util.Collections.singletonList)3 Before (org.junit.Before)3 Mockito.doReturn (org.mockito.Mockito.doReturn)3 SubscriptionEntity (io.gravitee.rest.api.model.SubscriptionEntity)2 RatingInput (io.gravitee.rest.api.portal.rest.model.RatingInput)2 PageNotFoundException (io.gravitee.rest.api.service.exceptions.PageNotFoundException)2 java.util (java.util)2 Assert (org.junit.Assert)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)2 io.gravitee.rest.api.model (io.gravitee.rest.api.model)1