@Override protected void setUp() { MockitoAnnotations.initMocks(this); when(operation.getParameter(ParamsProperty.QUERY)).thenReturn("in:inbox"); service = new SearchService(searchProvider); }
public void testSearchThrowsOnMissingQueryParameter() { when(operation.getParameter(ParamsProperty.QUERY)).thenReturn(null); try { service.execute(operation, context, USER); fail("Should have thrown an invalid request exception"); } catch (InvalidRequestException e) { // pass. } }
@Override public void execute( OperationRequest operation, OperationContext context, ParticipantId participant) throws InvalidRequestException { String query = OperationUtil.getRequiredParameter(operation, ParamsProperty.QUERY); int index = OperationUtil.getOptionalParameter(operation, ParamsProperty.INDEX, 0); int numResults = OperationUtil.getOptionalParameter( operation, ParamsProperty.NUM_RESULTS, DEFAULT_NUMBER_SEARCH_RESULTS); SearchResult result = search(participant, query, index, numResults); Map<ParamsProperty, Object> data = ImmutableMap.<ParamsProperty, Object> of(ParamsProperty.SEARCH_RESULTS, result); context.constructResponse(operation, data); }
public void testSearchThrowsOnMissingQueryParameter() { when(operation.getParameter(ParamsProperty.QUERY)).thenReturn(null); try { service.execute(operation, context, USER); fail("Should have thrown an invalid request exception"); } catch (InvalidRequestException e) { // pass. } }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); when(operation.getParameter(ParamsProperty.QUERY)).thenReturn("in:inbox"); service = new SearchService(searchProvider); }
public void testDefaultFieldsMatchSpec() throws InvalidRequestException { String query = "in:inbox"; when(searchProvider.search(USER, query, 0, 10)).thenReturn(new SearchResult(query)); service.execute(operation, context, USER); verify(searchProvider).search(USER, query, 0, 10); }
public void testDefaultFieldsMatchSpec() throws InvalidRequestException { String query = "in:inbox"; when(searchProvider.search(USER, query, 0, 10)).thenReturn(new SearchResult(query)); service.execute(operation, context, USER); verify(searchProvider).search(USER, query, 0, 10); }
public void testSearchWrapsSearchProvidersResult() throws InvalidRequestException { String title = "title"; SearchResult.Digest digest = new Digest(title, "", WAVE_ID.serialise(), ImmutableList.of(PARTICIPANT.getAddress(), OTHER_PARTICIPANT.getAddress()), -1L, -1L, 1, 1); String query = "in:inbox"; SearchResult searchResult = new SearchResult(query); searchResult.addDigest(digest); when(searchProvider.search(USER, query, 0, 10)).thenReturn(searchResult); service.execute(operation, context, USER); verify(context).constructResponse( eq(operation), argThat(matchesSearchResult("in:inbox", WAVE_ID, "title", PARTICIPANT, ImmutableSet.of( PARTICIPANT, OTHER_PARTICIPANT), 1, 1))); }
public void testSearchWrapsSearchProvidersResult() throws InvalidRequestException { String title = "title"; SearchResult.Digest digest = new Digest(title, "", WAVE_ID.serialise(), ImmutableList.of(PARTICIPANT.getAddress(), OTHER_PARTICIPANT.getAddress()), -1L, -1L, 1, 1); String query = "in:inbox"; SearchResult searchResult = new SearchResult(query); searchResult.addDigest(digest); when(searchProvider.search(USER, query, 0, 10)).thenReturn(searchResult); service.execute(operation, context, USER); verify(context).constructResponse( eq(operation), argThat(matchesSearchResult("in:inbox", WAVE_ID, "title", PARTICIPANT, ImmutableSet.of( PARTICIPANT, OTHER_PARTICIPANT), 1, 1))); }
searchResult.addDigest(digest); when(searchProvider.search(USER, query, 0, 10)).thenReturn(searchResult); service.execute(operation, context, USER);
searchResult.addDigest(digest); when(searchProvider.search(USER, query, 0, 10)).thenReturn(searchResult); service.execute(operation, context, USER);