assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
}
@Test
public void searchWidgets() throws Exception {
Model model = new ExtendedModelMap();
String searchTerm = "widget";
String type = "OpenSocial";
String status = "published";
PortalPreferenceService preferenceService = createMock(PortalPreferenceService.class);
expect(preferenceService.getPreference(PortalPreferenceKeys.PAGE_SIZE)).andReturn(null);
replay(preferenceService);
SearchResult<Widget> widgetSearchResult = populateWidgetSearchResult();
expect(service.getWidgetsBySearchCriteria(searchTerm, type, status, DEFAULT_OFFSET, DEFAULT_PAGESIZE)).andReturn(widgetSearchResult);
replay(service);
String searchView = controller.searchWidgets(searchTerm, type, status, DEFAULT_OFFSET,REFERRER_ID, model);
verify(service);
assertEquals(ViewNames.ADMIN_WIDGETS, searchView);
assertEquals(searchTerm, model.asMap().get(ModelKeys.SEARCH_TERM));
assertEquals(type, model.asMap().get("selectedWidgetType"));
assertEquals(status, model.asMap().get("selectedWidgetStatus"));
assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
}