@Test public void testStoreResponseContextForSearchRequest() throws Exception { Configuration config = new SystemPropertiesConfiguration(); RequestCountingContextLookup contextLookup = new RequestCountingContextLookup(new MultiMapSearchResponseContextLookup(config),1,1); ResponseEventHandler responseHandler = mock(ResponseEventHandler.class); gateway = new DisruptorRelatedItemSearchResultsToResponseGateway(new SystemPropertiesConfiguration(), new RequestSearchEventProcessor(contextLookup), new ResponseSearchEventProcessor(contextLookup,responseHandler)); SearchResponseContext[] holder = new SearchResponseContext[] { LogDebuggingSearchResponseContext.INSTANCE}; gateway.storeResponseContextForSearchRequest(new SipHashSearchRequestLookupKey("1"),holder); boolean added = contextLookup.waitOnAddContexts(1000); assertTrue(added); List<SearchResponseContext> holders = contextLookup.removeContexts(new SipHashSearchRequestLookupKey("1")); assertEquals(1, holders.size()); assertSame(holders.get(0),holder[0]); contextLookup.reset(1,3); gateway.storeResponseContextForSearchRequest(new SipHashSearchRequestLookupKey("1"),holder); gateway.storeResponseContextForSearchRequest(new SipHashSearchRequestLookupKey("1"),holder); gateway.storeResponseContextForSearchRequest(new SipHashSearchRequestLookupKey("1"),holder); added = contextLookup.waitOnAddContexts(1000); assertTrue(added); holders = contextLookup.removeContexts(new SipHashSearchRequestLookupKey("1")); assertEquals(3, holders.size()); }
@Override public void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context) { ringBuffer.publishEvent(storeResponseContextTranslator,key,context); }
DisruptorRelatedItemSearchResultsToResponseGateway implements RelatedItemSearchResultsToResponseGateway { @Override public void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context) { ringBuffer.publishEvent(storeResponseContextTranslator,key,context); } }
DisruptorRelatedItemSearchResultsToResponseGateway implements RelatedItemSearchResultsToResponseGateway { @Override public void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context) { ringBuffer.publishEvent(storeResponseContextTranslator,key,context); } DisruptorRelatedItemSearchResultsToResponseGateway(Configuration configuration,
                                                              SearchEventProcessor requestProcessor,
                                                              SearchEventProcessor responseProcessor
    ); }
DisruptorRelatedItemSearchResultsToResponseGateway implements RelatedItemSearchResultsToResponseGateway { @Override public void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context) { ringBuffer.publishEvent(storeResponseContextTranslator,key,context); } DisruptorRelatedItemSearchResultsToResponseGateway(Configuration configuration,
                                                              SearchEventProcessor requestProcessor,
                                                              SearchEventProcessor responseProcessor
    ); @Override void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context); @Override void sendSearchResultsToResponseContexts(SearchResultEventWithSearchRequestKey[] multipleSearchResults); @Override void shutdown(); }
DisruptorRelatedItemSearchResultsToResponseGateway implements RelatedItemSearchResultsToResponseGateway { @Override public void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context) { ringBuffer.publishEvent(storeResponseContextTranslator,key,context); } DisruptorRelatedItemSearchResultsToResponseGateway(Configuration configuration,
                                                              SearchEventProcessor requestProcessor,
                                                              SearchEventProcessor responseProcessor
    ); @Override void storeResponseContextForSearchRequest(SearchRequestLookupKey key, SearchResponseContext[] context); @Override void sendSearchResultsToResponseContexts(SearchResultEventWithSearchRequestKey[] multipleSearchResults); @Override void shutdown();  }