use of io.gravitee.rest.api.model.analytics.query.StatsAnalytics in project gravitee-management-rest-api by gravitee-io.
the class EnvironmentAnalyticsResourceTest method shouldGetCountAnalyticsWhenNotAdminAndApi.
@Test
public void shouldGetCountAnalyticsWhenNotAdminAndApi() {
ApiEntity api = new ApiEntity();
api.setId("apiId");
when(apiService.findByUser(any(), any(), eq(false))).thenReturn(Collections.singleton(api));
when(permissionService.hasPermission(API_ANALYTICS, api.getId(), READ)).thenReturn(true);
Response response = envTarget().queryParam("type", "count").queryParam("field", "api").queryParam("interval", 1000).queryParam("to", 1000).request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
StatsAnalytics analytics = response.readEntity(StatsAnalytics.class);
assertThat(analytics.getAvg()).isNull();
assertThat(analytics.getCount()).isEqualTo(1);
}
use of io.gravitee.rest.api.model.analytics.query.StatsAnalytics in project gravitee-management-rest-api by gravitee-io.
the class EnvironmentAnalyticsResourceTest method shouldGetCountAnalyticsWhenNotAdminAndApp.
@Test
public void shouldGetCountAnalyticsWhenNotAdminAndApp() {
ApplicationListItem app = new ApplicationListItem();
app.setId("appId");
when(applicationService.findByUser(any())).thenReturn(Collections.singleton(app));
when(permissionService.hasPermission(APPLICATION_ANALYTICS, app.getId(), READ)).thenReturn(true);
Response response = envTarget().queryParam("type", "count").queryParam("field", "application").queryParam("interval", 1000).queryParam("to", 1000).request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
StatsAnalytics analytics = response.readEntity(StatsAnalytics.class);
assertThat(analytics.getAvg()).isNull();
assertThat(analytics.getCount()).isEqualTo(1);
}
use of io.gravitee.rest.api.model.analytics.query.StatsAnalytics in project gravitee-management-rest-api by gravitee-io.
the class EnvironmentAnalyticsResourceTest method shouldGetEmptyCountAnalyticsWhenNotAdminAndNoApi.
@Test
public void shouldGetEmptyCountAnalyticsWhenNotAdminAndNoApi() {
when(apiService.findByUser(any(), eq(null), eq(false))).thenReturn(Collections.emptySet());
Response response = envTarget().queryParam("type", "count").queryParam("field", "api").queryParam("interval", 1000).queryParam("to", 1000).request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
StatsAnalytics analytics = response.readEntity(StatsAnalytics.class);
assertThat(analytics.getCount()).isNull();
}
use of io.gravitee.rest.api.model.analytics.query.StatsAnalytics in project gravitee-management-rest-api by gravitee-io.
the class EnvironmentAnalyticsResourceTest method shouldGetEmptyStatsAnalyticsWhenNotAdminAndNoApp.
@Test
public void shouldGetEmptyStatsAnalyticsWhenNotAdminAndNoApp() {
when(applicationService.findByUser(any())).thenReturn(Collections.emptySet());
Response response = envTarget().queryParam("type", "stats").queryParam("field", "application").queryParam("interval", 1000).queryParam("to", 1000).request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
StatsAnalytics analytics = response.readEntity(StatsAnalytics.class);
assertThat(analytics.getAvg()).isNull();
assertThat(analytics.getCount()).isNull();
}
use of io.gravitee.rest.api.model.analytics.query.StatsAnalytics in project gravitee-management-rest-api by gravitee-io.
the class EnvironmentAnalyticsResourceTest method shouldGetEmptyCountAnalyticsWhenNotAdminAndNoApp.
@Test
public void shouldGetEmptyCountAnalyticsWhenNotAdminAndNoApp() {
when(applicationService.findByUser(any())).thenReturn(Collections.emptySet());
Response response = envTarget().queryParam("type", "count").queryParam("field", "application").queryParam("interval", 1000).queryParam("to", 1000).request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
StatsAnalytics analytics = response.readEntity(StatsAnalytics.class);
assertThat(analytics.getCount()).isNull();
}
Aggregations