use of io.gravitee.management.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.getKey()), any(), any())).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());
}
use of io.gravitee.management.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.getKey(), apiId -> apiService.findById(apiId), apiService::exists);
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();
}
Aggregations