use of io.gravitee.rest.api.model.TopApiEntity in project gravitee-management-rest-api by gravitee-io.
the class FilteringServiceTest method shouldGetFeaturedApis.
@Test
public void shouldGetFeaturedApis() {
TopApiEntity topApi5 = new TopApiEntity();
topApi5.setApi("5");
topApi5.setOrder(2);
TopApiEntity topApi6 = new TopApiEntity();
topApi6.setApi("6");
topApi6.setOrder(1);
doReturn(Arrays.asList(topApi5, topApi6)).when(topApiService).findAll();
FilteredEntities<ApiEntity> apiEntityFilteredEntities = filteringService.filterApis(mockApis, FilteringService.FilterType.FEATURED, null);
List<ApiEntity> filteredItems = apiEntityFilteredEntities.getFilteredItems();
assertEquals(2, filteredItems.size());
assertEquals("6", filteredItems.get(0).getId());
assertEquals("5", filteredItems.get(1).getId());
}
use of io.gravitee.rest.api.model.TopApiEntity in project gravitee-management-rest-api by gravitee-io.
the class TopApiServiceImpl method findAll.
@Override
public List<TopApiEntity> findAll() {
LOGGER.debug("Find all top APIs");
final List<ApiEntity> apis = parameterService.findAll(PORTAL_TOP_APIS, apiId -> apiService.findById(apiId), apiService::exists, ParameterReferenceType.ENVIRONMENT);
if (!apis.isEmpty()) {
final List<TopApiEntity> topApis = new ArrayList<>(apis.size());
for (int i = 0; i < apis.size(); i++) {
final ApiEntity api = apis.get(i);
final TopApiEntity topApiEntity = new TopApiEntity();
topApiEntity.setApi(api.getId());
topApiEntity.setName(api.getName());
topApiEntity.setVersion(api.getVersion());
topApiEntity.setDescription(api.getDescription());
topApiEntity.setOrder(i);
topApis.add(topApiEntity);
}
return topApis;
}
return emptyList();
}
use of io.gravitee.rest.api.model.TopApiEntity in project gravitee-management-rest-api by gravitee-io.
the class TopApiServiceTest method shouldFindAll.
@Test
public void shouldFindAll() {
final ApiEntity api1 = new ApiEntity();
api1.setId("1");
api1.setName("name");
api1.setVersion("version");
api1.setDescription("description");
final ApiEntity api2 = new ApiEntity();
api2.setId("2");
when(parameterService.findAll(eq(PORTAL_TOP_APIS), any(Function.class), any(Predicate.class), any(ParameterReferenceType.class))).thenReturn(asList(api1, api2, api1));
final List<TopApiEntity> topApis = topApiService.findAll();
assertEquals("1", topApis.get(0).getApi());
assertEquals("name", topApis.get(0).getName());
assertEquals("version", topApis.get(0).getVersion());
assertEquals("description", topApis.get(0).getDescription());
assertEquals(0, topApis.get(0).getOrder());
assertEquals("2", topApis.get(1).getApi());
assertEquals(1, topApis.get(1).getOrder());
assertEquals("1", topApis.get(2).getApi());
assertEquals(2, topApis.get(2).getOrder());
}
Aggregations