@Test public void testTranslateTo() throws Exception { Configuration config = new SystemPropertiesConfiguration(); RelatedItemSearchRequest request = new RelatedItemSearchRequest(config); Map<String,String> properties = new HashMap<String,String>(); properties.put(config.getRequestParameterForId(),"id1"); properties.put("channel","com"); SearchResponseContext[] contexts = new SearchResponseContext[] {new AsyncServletSearchResponseContext(mock(AsyncContext.class))}; RelatedItemSearchRequestTranslator translator = new RelatedItemSearchRequestTranslator( new RelatedItemSearchFactoryWithSearchLookupKeyFactory(config,new KeyFactoryBasedRelatedItemSearchLookupKeyGenerator(config,new SipHashSearchRequestLookupKeyFactory()))); translator.translateTo(request, 1, RelatedItemSearchType.FREQUENTLY_RELATED_WITH,properties,contexts); assertSame(request.getRequestContexts(), contexts); assertEquals(request.getSearchRequest().getRelatedItemId(),"id1"); assertEquals(1,request.getSearchRequest().getAdditionalSearchCriteria().getNumberOfProperties()); assertEquals("channel",request.getSearchRequest().getAdditionalSearchCriteria().getPropertyName(0)); assertEquals("com",request.getSearchRequest().getAdditionalSearchCriteria().getPropertyValue(0)); }
@Override public void translateTo(RelatedItemSearchRequest event, long sequence, RelatedItemSearchType type, Map<String,String> params, SearchResponseContext[] contexts) { log.debug("Creating Related Product Search Request {}, {}",event.getSearchRequest().getLookupKey(),params); event.setRequestContexts(contexts); relatedItemSearchFactory.populateSearchObject(event.getSearchRequest(), type,params); }
RelatedItemSearchRequestTranslator implements IncomingSearchRequestTranslator { @Override public void translateTo(RelatedItemSearchRequest event, long sequence, RelatedItemSearchType type, Map<String,String> params, SearchResponseContext[] contexts) { log.debug("Creating Related Product Search Request {}, {}",event.getSearchRequest().getLookupKey(),params); event.setRequestContexts(contexts); relatedItemSearchFactory.populateSearchObject(event.getSearchRequest(), type,params); } }
RelatedItemSearchRequestTranslator implements IncomingSearchRequestTranslator { @Override public void translateTo(RelatedItemSearchRequest event, long sequence, RelatedItemSearchType type, Map<String,String> params, SearchResponseContext[] contexts) { log.debug("Creating Related Product Search Request {}, {}",event.getSearchRequest().getLookupKey(),params); event.setRequestContexts(contexts); relatedItemSearchFactory.populateSearchObject(event.getSearchRequest(), type,params); } RelatedItemSearchRequestTranslator(RelatedItemSearchFactory relatedItemSearchFactory); }
RelatedItemSearchRequestTranslator implements IncomingSearchRequestTranslator { @Override public void translateTo(RelatedItemSearchRequest event, long sequence, RelatedItemSearchType type, Map<String,String> params, SearchResponseContext[] contexts) { log.debug("Creating Related Product Search Request {}, {}",event.getSearchRequest().getLookupKey(),params); event.setRequestContexts(contexts); relatedItemSearchFactory.populateSearchObject(event.getSearchRequest(), type,params); } RelatedItemSearchRequestTranslator(RelatedItemSearchFactory relatedItemSearchFactory); @Override void translateTo(RelatedItemSearchRequest event, long sequence,
                            RelatedItemSearchType type, Map<String,String> params,
                            SearchResponseContext[] contexts); }
RelatedItemSearchRequestTranslator implements IncomingSearchRequestTranslator { @Override public void translateTo(RelatedItemSearchRequest event, long sequence, RelatedItemSearchType type, Map<String,String> params, SearchResponseContext[] contexts) { log.debug("Creating Related Product Search Request {}, {}",event.getSearchRequest().getLookupKey(),params); event.setRequestContexts(contexts); relatedItemSearchFactory.populateSearchObject(event.getSearchRequest(), type,params); } RelatedItemSearchRequestTranslator(RelatedItemSearchFactory relatedItemSearchFactory); @Override void translateTo(RelatedItemSearchRequest event, long sequence,
                            RelatedItemSearchType type, Map<String,String> params,
                            SearchResponseContext[] contexts);  }