use of com.ctrip.framework.apollo.common.dto.PageDTO in project apollo by ctripcorp.
the class SearchControllerTest method testSearchItem.
@Test
public void testSearchItem() {
String query = "timeout";
PageRequest request = PageRequest.of(0, 20);
PageDTO<App> apps = new PageDTO<>(Lists.newLinkedList(), request, 0);
PageDTO<NamespaceDTO> devNamespaces = genPageNamespace(10, request, 20);
PageDTO<NamespaceDTO> fatNamespaces = genPageNamespace(15, request, 30);
when(appService.searchByAppIdOrAppName(query, request)).thenReturn(apps);
when(portalConfig.supportSearchByItem()).thenReturn(true);
when(portalSettings.getActiveEnvs()).thenReturn(Lists.newArrayList(Env.DEV, Env.FAT));
when(namespaceService.findNamespacesByItem(Env.DEV, query, request)).thenReturn(devNamespaces);
when(namespaceService.findNamespacesByItem(Env.FAT, query, request)).thenReturn(fatNamespaces);
PageDTO<App> result = searchController.search(query, request);
Assert.assertTrue(result.hasContent());
Assert.assertEquals(25, result.getContent().size());
Assert.assertEquals(30, result.getTotal());
verify(appService, times(0)).findAll(request);
verify(appService, times(1)).searchByAppIdOrAppName(query, request);
verify(namespaceService).findNamespacesByItem(Env.DEV, query, request);
verify(namespaceService).findNamespacesByItem(Env.FAT, query, request);
}
use of com.ctrip.framework.apollo.common.dto.PageDTO in project apollo by ctripcorp.
the class SearchControllerTest method genPageNamespace.
private PageDTO<NamespaceDTO> genPageNamespace(int size, Pageable pageable, int total) {
List<NamespaceDTO> result = Lists.newLinkedList();
for (int i = 0; i < size; i++) {
NamespaceDTO namespaceDTO = new NamespaceDTO();
result.add(namespaceDTO);
}
return new PageDTO<>(result, pageable, total);
}
Aggregations