use of io.gravitee.rest.api.model.api.ApiEntity 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.model.api.ApiEntity 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.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiPageResourceTest method init.
@Before
public void init() {
resetAllMocks();
ApiEntity mockApi = new ApiEntity();
mockApi.setId(API);
doReturn(mockApi).when(apiService).findById(API);
Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(mockApi));
doReturn(mockApis).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
doReturn(true).when(accessControlService).canAccessApiFromPortal(API);
PageEntity page1 = new PageEntity();
page1.setPublished(true);
page1.setVisibility(Visibility.PUBLIC);
page1.setContent(PAGE_CONTENT);
doReturn(page1).when(pageService).findById(PAGE, null);
doReturn(true).when(accessControlService).canAccessPageFromPortal(API, page1);
doReturn(new Page()).when(pageMapper).convert(any(), any(), any());
doReturn(new PageLinks()).when(pageMapper).computePageLinks(any(), any());
}
use of io.gravitee.rest.api.model.api.ApiEntity 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.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingAnswersResourceTest method init.
@Before
public void init() {
resetAllMocks();
ApiEntity mockApi = new ApiEntity();
mockApi.setId(API);
Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(mockApi));
doReturn(mockApis).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
RatingEntity ratingEntity = new RatingEntity();
ratingEntity.setId(RATING);
ratingEntity.setApi(API);
ratingEntity.setComment(RATING);
ratingEntity.setRate(Integer.valueOf(1).byteValue());
doReturn(ratingEntity).when(ratingService).findById(eq(RATING));
doReturn(ratingEntity).when(ratingService).createAnswer(any());
}
Aggregations