Search in sources :

Example 1 with Task

use of uk.nhs.digital.intranet.beans.Task in project hippo by NHS-digital-website.

the class TaskHubComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    final ComponentList bean = (ComponentList) request.getRequestContext().getContentBean();
    List<?> priorityTaskList = getTasksFromLinkBlocks(bean.getBlocks()).filter(task -> ((Task) task).getPriorityAction()).collect(Collectors.toList());
    request.setAttribute("priorityTasks", priorityTaskList);
    List<?> alternativeTaskList = getTasksFromLinkBlocks(bean.getBlocks()).flatMap(task -> addAlternativeNameEntries((Task) task)).collect(Collectors.toList());
    request.setAttribute("alternativeTasks", alternativeTaskList);
}
Also used : Task(uk.nhs.digital.intranet.beans.Task) Arrays(java.util.Arrays) List(java.util.List) Stream(java.util.stream.Stream) HstRequest(org.hippoecm.hst.core.component.HstRequest) ComponentList(uk.nhs.digital.website.beans.ComponentList) HstResponse(org.hippoecm.hst.core.component.HstResponse) uk.nhs.digital.common.components(uk.nhs.digital.common.components) Internallink(uk.nhs.digital.website.beans.Internallink) Collectors(java.util.stream.Collectors) Task(uk.nhs.digital.intranet.beans.Task) ComponentList(uk.nhs.digital.website.beans.ComponentList)

Example 2 with Task

use of uk.nhs.digital.intranet.beans.Task in project hippo by NHS-digital-website.

the class SearchPageComponentTest method blankQueryReturnsDocumentsForAllDocTypes.

@Test
public void blankQueryReturnsDocumentsForAllDocTypes() {
    MockHstRequest request = new MockHstRequest();
    request.setParameterMap("", Collections.emptyMap());
    Pageable<HippoBean> documentResults = new DefaultPagination<>(Collections.singletonList(new Task()));
    Mockito.when(bloomreachSearchProvider.getBloomreachResults(Mockito.nullable(String.class), anyInt(), anyInt(), eq(SearchArea.ALL))).thenReturn(documentResults);
    underTest.doBeforeRender(request, new MockHstResponse());
    assertEquals(documentResults, request.getAttribute(REQUEST_ATTR_PAGEABLE));
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) Task(uk.nhs.digital.intranet.beans.Task) MockHstRequest(org.hippoecm.hst.mock.core.component.MockHstRequest) MockHstResponse(org.hippoecm.hst.mock.core.component.MockHstResponse) DefaultPagination(org.onehippo.cms7.essentials.components.paging.DefaultPagination) Test(org.junit.Test)

Example 3 with Task

use of uk.nhs.digital.intranet.beans.Task in project hippo by NHS-digital-website.

the class SearchPageComponentTest method newsQueryLimitsSearchAreaAndPopulatesTabs.

@Test
public void newsQueryLimitsSearchAreaAndPopulatesTabs() {
    MockHstRequest request = new MockHstRequest();
    request.setParameterMap("", Collections.emptyMap());
    request.addParameter(REQUEST_ATTR_AREA, "news");
    int newsResults = 53;
    int tasksResults = 5;
    int teamsResults = 2;
    Pageable<HippoBean> documentResults = new DefaultPagination<>(Collections.singletonList(new Task()), newsResults);
    Mockito.when(bloomreachSearchProvider.getBloomreachResults(Mockito.nullable(String.class), anyInt(), anyInt(), eq(SearchArea.NEWS))).thenReturn(documentResults);
    Mockito.when(bloomreachSearchProvider.getBloomreachResultsCount(null, SearchArea.TASKS)).thenReturn(tasksResults);
    Mockito.when(bloomreachSearchProvider.getBloomreachResultsCount(null, SearchArea.TEAMS)).thenReturn(teamsResults);
    underTest.doBeforeRender(request, new MockHstResponse());
    assertEquals(documentResults, request.getAttribute(REQUEST_ATTR_PAGEABLE));
    Mockito.verify(bloomreachSearchProvider, Mockito.never()).getBloomreachResultsCount(Mockito.nullable(String.class), eq(SearchArea.NEWS));
    List<SearchResultTab> tabs = (List<SearchResultTab>) request.getAttribute(REQUEST_ATTR_SEARCH_TABS);
    assertTrue(tabs.contains(new SearchResultTab(SearchArea.NEWS, newsResults)));
    assertTrue(tabs.contains(new SearchResultTab(SearchArea.TASKS, tasksResults)));
    assertTrue(tabs.contains(new SearchResultTab(SearchArea.TEAMS, teamsResults)));
    assertTrue(tabs.contains(new SearchResultTab(SearchArea.PEOPLE, 0)));
    assertTrue(tabs.contains(new SearchResultTab(SearchArea.ALL, newsResults + tasksResults + teamsResults)));
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) Task(uk.nhs.digital.intranet.beans.Task) MockHstRequest(org.hippoecm.hst.mock.core.component.MockHstRequest) MockHstResponse(org.hippoecm.hst.mock.core.component.MockHstResponse) SearchResultTab(uk.nhs.digital.intranet.model.SearchResultTab) DefaultPagination(org.onehippo.cms7.essentials.components.paging.DefaultPagination) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

Task (uk.nhs.digital.intranet.beans.Task)3 List (java.util.List)2 HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)2 MockHstRequest (org.hippoecm.hst.mock.core.component.MockHstRequest)2 MockHstResponse (org.hippoecm.hst.mock.core.component.MockHstResponse)2 Test (org.junit.Test)2 DefaultPagination (org.onehippo.cms7.essentials.components.paging.DefaultPagination)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 HstRequest (org.hippoecm.hst.core.component.HstRequest)1 HstResponse (org.hippoecm.hst.core.component.HstResponse)1 uk.nhs.digital.common.components (uk.nhs.digital.common.components)1 SearchResultTab (uk.nhs.digital.intranet.model.SearchResultTab)1 ComponentList (uk.nhs.digital.website.beans.ComponentList)1 Internallink (uk.nhs.digital.website.beans.Internallink)1