Mail m = mView.getMail(); Optional<ZonedDateTime> nextDelivery = mView.getNextDelivery(); Map<String, Object> map = new HashMap<>(); map.put(names[0], m.getName());
@Override public boolean hasNext() { if (item != null) { return true; } while (items.hasNext()) { try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(items.next().getObjectFile()))) { final Mail mail = (Mail) in.readObject(); item = new MailQueueItemView(mail, getNextDelivery(mail)); return true; } catch (IOException | ClassNotFoundException e) { LOGGER.info("Unable to load mail", e); } } return false; }
public static MailProjection from(ManageableMailQueue.MailQueueItemView item) { return from(item.getMail()); }
@Test public void reprocessingShouldEnqueueAllMails() throws Exception { MailRepository repository = mailRepositoryStore.select(MailRepositoryUrl.fromPathAndProtocol(PATH, MEMORY_PROTOCOL)); repository.store(mail1); repository.store(mail2); repository.store(mail3); reprocessingService.reprocessAll(PATH, NO_TARGET_PROCESSOR, SPOOL, NOOP_CONSUMER); assertThat(queueFactory.getQueue(SPOOL).get() .browse()) .extracting(item -> item.getMail().getName()) .containsOnly(NAME_1, NAME_2, NAME_3); }
@Test public void reprocessingOneShouldEnqueueMail() throws Exception { MailRepository repository = mailRepositoryStore.select(MailRepositoryUrl.fromPathAndProtocol(PATH, MEMORY_PROTOCOL)); repository.store(mail1); repository.store(mail2); repository.store(mail3); reprocessingService.reprocess(PATH, KEY_2, NO_TARGET_PROCESSOR, SPOOL); assertThat(queueFactory.getQueue(SPOOL).get() .browse()) .extracting(item -> item.getMail().getName()) .containsOnly(NAME_2); }
@Override public MailQueueItemView next() { while (hasNext()) { try { Message m = messages.nextElement(); return new MailQueueItemView(createMail(m), nextDeliveryDate(m)); } catch (MessagingException | JMSException e) { LOGGER.error("Unable to browse queue", e); } } throw new NoSuchElementException(); }
public static MailQueueItemDTO from(ManageableMailQueue.MailQueueItemView mailQueueItemView) { return builder() .name(mailQueueItemView.getMail().getName()) .sender(mailQueueItemView.getMail().getMaybeSender().asOptional()) .recipients(mailQueueItemView.getMail().getRecipients()) .nextDelivery(mailQueueItemView.getNextDelivery()) .build(); }