Search in sources :

Example 6 with PageDTO

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);
}
Also used : App(com.ctrip.framework.apollo.common.entity.App) PageRequest(org.springframework.data.domain.PageRequest) NamespaceDTO(com.ctrip.framework.apollo.common.dto.NamespaceDTO) PageDTO(com.ctrip.framework.apollo.common.dto.PageDTO) Test(org.junit.Test)

Example 7 with PageDTO

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);
}
Also used : NamespaceDTO(com.ctrip.framework.apollo.common.dto.NamespaceDTO) PageDTO(com.ctrip.framework.apollo.common.dto.PageDTO)

Aggregations

PageDTO (com.ctrip.framework.apollo.common.dto.PageDTO)7 App (com.ctrip.framework.apollo.common.entity.App)4 NamespaceDTO (com.ctrip.framework.apollo.common.dto.NamespaceDTO)3 PageRequest (org.springframework.data.domain.PageRequest)3 Test (org.junit.Test)2 Instance (com.ctrip.framework.apollo.biz.entity.Instance)1 InstanceConfig (com.ctrip.framework.apollo.biz.entity.InstanceConfig)1 Release (com.ctrip.framework.apollo.biz.entity.Release)1 ReleaseHistory (com.ctrip.framework.apollo.biz.entity.ReleaseHistory)1 InstanceService (com.ctrip.framework.apollo.biz.service.InstanceService)1 ReleaseService (com.ctrip.framework.apollo.biz.service.ReleaseService)1 InstanceConfigDTO (com.ctrip.framework.apollo.common.dto.InstanceConfigDTO)1 InstanceDTO (com.ctrip.framework.apollo.common.dto.InstanceDTO)1 ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)1 ReleaseHistoryDTO (com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO)1 NotFoundException (com.ctrip.framework.apollo.common.exception.NotFoundException)1 BeanUtils (com.ctrip.framework.apollo.common.utils.BeanUtils)1 Env (com.ctrip.framework.apollo.portal.environment.Env)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1