@Test public void testDoEncode() throws Exception { final Long messages = 2L; final Long recent = 3L; final MessageUid uidNext = MessageUid.of(5); final UidValidity uidValidity = UidValidity.of(7L); final Long unseen = 11L; final String mailbox = "A mailbox named desire"; encoder.encode(new MailboxStatusResponse(messages, recent, uidNext, null, uidValidity, unseen, mailbox), composer); assertThat(writer.getString()).isEqualTo("* STATUS \"A mailbox named desire\" (MESSAGES 2 RECENT 3 UIDNEXT 5 UIDVALIDITY 7 UNSEEN 11)\r\n"); }
@Override public void encode(MailboxStatusResponse response, ImapResponseComposer composer) throws IOException { Long messages = response.getMessages(); Long recent = response.getRecent(); MessageUid uidNext = response.getUidNext(); ModSeq highestModSeq = response.getHighestModSeq(); UidValidity uidValidity = response.getUidValidity(); Long unseen = response.getUnseen(); String mailboxName = response.getMailbox(); composer.untagged(); composer.message(STATUS_COMMAND.getName()); composer.quote(mailboxName); composer.openParen(); if (messages != null) { composer.message(STATUS_MESSAGES); final long messagesValue = messages; composer.message(messagesValue); } if (recent != null) { composer.message(STATUS_RECENT); final long recentValue = recent; composer.message(recentValue); } if (uidNext != null) { composer.message(STATUS_UIDNEXT); final long uidNextValue = uidNext.asLong(); composer.message(uidNextValue); } if (highestModSeq != null) { composer.message(STATUS_HIGHESTMODSEQ); composer.message(highestModSeq.asLong()); } if (uidValidity != null) { composer.message(STATUS_UIDVALIDITY); final UidValidity uidValidityValue = uidValidity; composer.message(uidValidityValue.asLong()); } if (unseen != null) { composer.message(STATUS_UNSEEN); final long unseenValue = unseen; composer.message(unseenValue); } composer.closeParen(); composer.end(); }
MailboxStatusResponseEncoder implements ImapConstants, ImapResponseEncoder<MailboxStatusResponse> { @Override public void encode(MailboxStatusResponse response, ImapResponseComposer composer) throws IOException { Long messages = response.getMessages(); Long recent = response.getRecent(); MessageUid uidNext = response.getUidNext(); ModSeq highestModSeq = response.getHighestModSeq(); UidValidity uidValidity = response.getUidValidity(); Long unseen = response.getUnseen(); String mailboxName = response.getMailbox(); composer.untagged(); composer.message(STATUS_COMMAND.getName()); composer.quote(mailboxName); composer.openParen(); if (messages != null) { composer.message(STATUS_MESSAGES); final long messagesValue = messages; composer.message(messagesValue); } if (recent != null) { composer.message(STATUS_RECENT); final long recentValue = recent; composer.message(recentValue); } if (uidNext != null) { composer.message(STATUS_UIDNEXT); final long uidNextValue = uidNext.asLong(); composer.message(uidNextValue); } if (highestModSeq != null) { composer.message(STATUS_HIGHESTMODSEQ); composer.message(highestModSeq.asLong()); } if (uidValidity != null) { composer.message(STATUS_UIDVALIDITY); final UidValidity uidValidityValue = uidValidity; composer.message(uidValidityValue.asLong()); } if (unseen != null) { composer.message(STATUS_UNSEEN); final long unseenValue = unseen; composer.message(unseenValue); } composer.closeParen(); composer.end(); } }
MailboxStatusResponseEncoder implements ImapConstants, ImapResponseEncoder<MailboxStatusResponse> { @Override public void encode(MailboxStatusResponse response, ImapResponseComposer composer) throws IOException { Long messages = response.getMessages(); Long recent = response.getRecent(); MessageUid uidNext = response.getUidNext(); ModSeq highestModSeq = response.getHighestModSeq(); UidValidity uidValidity = response.getUidValidity(); Long unseen = response.getUnseen(); String mailboxName = response.getMailbox(); composer.untagged(); composer.message(STATUS_COMMAND.getName()); composer.quote(mailboxName); composer.openParen(); if (messages != null) { composer.message(STATUS_MESSAGES); final long messagesValue = messages; composer.message(messagesValue); } if (recent != null) { composer.message(STATUS_RECENT); final long recentValue = recent; composer.message(recentValue); } if (uidNext != null) { composer.message(STATUS_UIDNEXT); final long uidNextValue = uidNext.asLong(); composer.message(uidNextValue); } if (highestModSeq != null) { composer.message(STATUS_HIGHESTMODSEQ); composer.message(highestModSeq.asLong()); } if (uidValidity != null) { composer.message(STATUS_UIDVALIDITY); final UidValidity uidValidityValue = uidValidity; composer.message(uidValidityValue.asLong()); } if (unseen != null) { composer.message(STATUS_UNSEEN); final long unseenValue = unseen; composer.message(unseenValue); } composer.closeParen(); composer.end(); }  }
MailboxStatusResponseEncoder implements ImapConstants, ImapResponseEncoder<MailboxStatusResponse> { @Override public void encode(MailboxStatusResponse response, ImapResponseComposer composer) throws IOException { Long messages = response.getMessages(); Long recent = response.getRecent(); MessageUid uidNext = response.getUidNext(); ModSeq highestModSeq = response.getHighestModSeq(); UidValidity uidValidity = response.getUidValidity(); Long unseen = response.getUnseen(); String mailboxName = response.getMailbox(); composer.untagged(); composer.message(STATUS_COMMAND.getName()); composer.quote(mailboxName); composer.openParen(); if (messages != null) { composer.message(STATUS_MESSAGES); final long messagesValue = messages; composer.message(messagesValue); } if (recent != null) { composer.message(STATUS_RECENT); final long recentValue = recent; composer.message(recentValue); } if (uidNext != null) { composer.message(STATUS_UIDNEXT); final long uidNextValue = uidNext.asLong(); composer.message(uidNextValue); } if (highestModSeq != null) { composer.message(STATUS_HIGHESTMODSEQ); composer.message(highestModSeq.asLong()); } if (uidValidity != null) { composer.message(STATUS_UIDVALIDITY); final UidValidity uidValidityValue = uidValidity; composer.message(uidValidityValue.asLong()); } if (unseen != null) { composer.message(STATUS_UNSEEN); final long unseenValue = unseen; composer.message(unseenValue); } composer.closeParen(); composer.end(); }  @Override Class<MailboxStatusResponse> acceptableMessages(); @Override void encode(MailboxStatusResponse response, ImapResponseComposer composer); }
MailboxStatusResponseEncoder implements ImapConstants, ImapResponseEncoder<MailboxStatusResponse> { @Override public void encode(MailboxStatusResponse response, ImapResponseComposer composer) throws IOException { Long messages = response.getMessages(); Long recent = response.getRecent(); MessageUid uidNext = response.getUidNext(); ModSeq highestModSeq = response.getHighestModSeq(); UidValidity uidValidity = response.getUidValidity(); Long unseen = response.getUnseen(); String mailboxName = response.getMailbox(); composer.untagged(); composer.message(STATUS_COMMAND.getName()); composer.quote(mailboxName); composer.openParen(); if (messages != null) { composer.message(STATUS_MESSAGES); final long messagesValue = messages; composer.message(messagesValue); } if (recent != null) { composer.message(STATUS_RECENT); final long recentValue = recent; composer.message(recentValue); } if (uidNext != null) { composer.message(STATUS_UIDNEXT); final long uidNextValue = uidNext.asLong(); composer.message(uidNextValue); } if (highestModSeq != null) { composer.message(STATUS_HIGHESTMODSEQ); composer.message(highestModSeq.asLong()); } if (uidValidity != null) { composer.message(STATUS_UIDVALIDITY); final UidValidity uidValidityValue = uidValidity; composer.message(uidValidityValue.asLong()); } if (unseen != null) { composer.message(STATUS_UNSEEN); final long unseenValue = unseen; composer.message(unseenValue); } composer.closeParen(); composer.end(); }  @Override Class<MailboxStatusResponse> acceptableMessages(); @Override void encode(MailboxStatusResponse response, ImapResponseComposer composer);  }