PurgeOldMessagesWorker extends AbstractWorkerTask { @Override public void setParameters(final Map<String, ?> parameters) { if (Utils.isNullOrEmpty(parameters)) purgeAfterDays = 30; else { final Object pPurgeDays = parameters.get(P_PURGE_AFTER_DAYS); if (pPurgeDays == null) purgeAfterDays = 30; else { try { purgeAfterDays = Integer.parseInt(pPurgeDays.toString()); } catch (final NumberFormatException NaN) { log.warn("Illegal value [" + pPurgeDays.toString() + "] used for \"" + P_PURGE_AFTER_DAYS + "\" parameter! Using default."); purgeAfterDays = 30; } } } log.info("Message information will be deleted after " + purgeAfterDays + " days."); }  @Override void doProcessing(); @Override void setParameters(final Map<String, ?> parameters); static final String P_PURGE_AFTER_DAYS; }
@Test public void test0_NaNPurgeDelay() { final PurgeOldMessagesWorker worker = new PurgeOldMessagesWorker(); final HashMap<String, Object> parameters = new HashMap<>(); parameters.put(PurgeOldMessagesWorker.P_PURGE_AFTER_DAYS, "NaN"); try { worker.setParameters(parameters); } catch (final Exception e) { fail("Worker did not accept wrong delay value"); } }