Пример #1
0
 @Override
 public void run() {
   try {
     threadResult.set(searchServiceComponent.search(sessionIdentifier, query, maxResults));
   } catch (final Exception e) {
     logger.error(e.getClass().getSimpleName(), e);
   }
 }
  @Test
  public void testSearchSpecial() throws Exception {
    final Logger logger = EasyMock.createNiceMock(Logger.class);
    EasyMock.replay(logger);

    final SessionIdentifier sessionIdentifier = new SessionIdentifier("sessionId");
    final int maxResults = 1337;

    final SearchQueryHistoryDao searchQueryHistoryDao = null;
    final IdGeneratorUUID idGeneratorUUID = null;

    final List<SearchResult> list = Arrays.asList();
    final SearchServiceComponent searchServiceComponent =
        EasyMock.createMock(SearchServiceComponent.class);
    EasyMock.expect(searchServiceComponent.search(sessionIdentifier, "bar", maxResults))
        .andReturn(list);
    EasyMock.replay(searchServiceComponent);

    final SearchServiceComponentRegistry searchServiceComponentRegistry =
        EasyMock.createNiceMock(SearchServiceComponentRegistry.class);
    EasyMock.expect(searchServiceComponentRegistry.get("foo")).andReturn(searchServiceComponent);
    EasyMock.replay(searchServiceComponentRegistry);

    final ThreadRunner threadRunner = new ThreadRunnerMock();

    final SearchServiceSearchResultComparator searchServiceComponentComparator = null;

    final AuthenticationService authenticationService =
        EasyMock.createNiceMock(AuthenticationService.class);
    EasyMock.expect(authenticationService.getCurrentUser(sessionIdentifier)).andReturn(null);
    EasyMock.replay(authenticationService);

    final SearchService searchService =
        new SearchServiceImpl(
            logger,
            authenticationService,
            searchQueryHistoryDao,
            idGeneratorUUID,
            searchServiceComponentRegistry,
            threadRunner,
            searchServiceComponentComparator);
    searchService.search(sessionIdentifier, "foo: bar", maxResults);

    EasyMock.verify(searchServiceComponentRegistry, searchServiceComponent);
  }