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)));
}
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)));
}
Aggregations