@Test public void testDoService_NullValueTranslator() throws Exception { AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(SRC_METADATA_KEY, LOOKUP_VALUE) })); Cache cache = createCacheInstanceForTests(); RetrieveFromCacheService service = createServiceForTests(); CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0); eval.setValueTranslator(new StaticCacheValueTranslator("dummy value")); try { service.setConnection(new CacheConnection(cache)); start(service); cache.put(LOOKUP_VALUE, LOOKED_UP_VALUE); service.doService(msg); fail("Expected a ServiceException"); } catch (ServiceException expected) { } finally { stop(service); } }
@Override public void doService(AdaptrisMessage msg) throws ServiceException { try { for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null value for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }
RetrieveFromCacheService extends CacheServiceBase { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null value for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } }
RetrieveFromCacheService extends CacheServiceBase { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null value for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } RetrieveFromCacheService(); }
RetrieveFromCacheService extends CacheServiceBase { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null value for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } RetrieveFromCacheService(); @Override void doService(AdaptrisMessage msg); Boolean getExceptionIfNotFound(); void setExceptionIfNotFound(Boolean b); }
RetrieveFromCacheService extends CacheServiceBase { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { for (CacheEntryEvaluator ceg : getCacheEntryEvaluators()) { String key = ceg.getKey(msg); if (isEmpty(key)) { log.warn("{} generated null value for the key, nothing to do", ceg.friendlyName()); continue; } addCacheValueToMessage(msg, key, ceg.valueTranslator(), !exceptionIfNotFound()); } } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } RetrieveFromCacheService(); @Override void doService(AdaptrisMessage msg); Boolean getExceptionIfNotFound(); void setExceptionIfNotFound(Boolean b);  }