Search in sources :

Example 6 with MockHstResponse

use of org.hippoecm.hst.mock.core.component.MockHstResponse in project hippo by NHS-digital-website.

the class SearchPageComponentTest method peopleResultsEmptyIfQueryEmpty.

@Test
public void peopleResultsEmptyIfQueryEmpty() throws ProviderCommunicationException {
    MockHstRequest request = new MockHstRequest();
    request.setParameterMap("", Collections.emptyMap());
    request.addParameter(REQUEST_ATTR_QUERY, "");
    mockHstRequestContext.setAttribute(Constants.ACCESS_TOKEN_PROPERTY_NAME, "logged-into-microsoft-access-token");
    underTest.doBeforeRender(request, new MockHstResponse());
    Mockito.verify(graphProvider, Mockito.never()).getPeople(Mockito.nullable(String.class));
    assertNull(request.getAttribute(REQUEST_ATTR_PEOPLE_RESULTS));
    assertTrue(((List) request.getAttribute(REQUEST_ATTR_SEARCH_TABS)).contains(new SearchResultTab(SearchArea.PEOPLE, 0)));
}
Also used : MockHstRequest(org.hippoecm.hst.mock.core.component.MockHstRequest) MockHstResponse(org.hippoecm.hst.mock.core.component.MockHstResponse) SearchResultTab(uk.nhs.digital.intranet.model.SearchResultTab) Test(org.junit.Test)

Example 7 with MockHstResponse

use of org.hippoecm.hst.mock.core.component.MockHstResponse in project hippo by NHS-digital-website.

the class SearchPageComponentTest method peopleResultsEmptyIfNotLoggedIn.

@Test
public void peopleResultsEmptyIfNotLoggedIn() throws ProviderCommunicationException {
    MockHstRequest request = new MockHstRequest();
    request.setParameterMap("", Collections.emptyMap());
    request.addParameter(REQUEST_ATTR_QUERY, "queryString is here");
    mockHstRequestContext.setAttribute(Constants.ACCESS_TOKEN_PROPERTY_NAME, "");
    underTest.doBeforeRender(request, new MockHstResponse());
    Mockito.verify(graphProvider, Mockito.never()).getPeople(Mockito.nullable(String.class));
    assertNull(request.getAttribute(REQUEST_ATTR_PEOPLE_RESULTS));
    assertTrue(((List) request.getAttribute(REQUEST_ATTR_SEARCH_TABS)).contains(new SearchResultTab(SearchArea.PEOPLE, 0)));
}
Also used : MockHstRequest(org.hippoecm.hst.mock.core.component.MockHstRequest) MockHstResponse(org.hippoecm.hst.mock.core.component.MockHstResponse) SearchResultTab(uk.nhs.digital.intranet.model.SearchResultTab) Test(org.junit.Test)

Aggregations

MockHstResponse (org.hippoecm.hst.mock.core.component.MockHstResponse)7 MockHstRequest (org.hippoecm.hst.mock.core.component.MockHstRequest)6 Test (org.junit.Test)6 SearchResultTab (uk.nhs.digital.intranet.model.SearchResultTab)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)2 DefaultPagination (org.onehippo.cms7.essentials.components.paging.DefaultPagination)2 Task (uk.nhs.digital.intranet.beans.Task)2 Before (org.junit.Before)1 Person (uk.nhs.digital.intranet.model.Person)1