### Question:
ImapFolder extends Folder<ImapMessage> { @Override public String getNewPushState(String oldSerializedPushState, Message message) { try { String uid = message.getUid(); long messageUid = Long.parseLong(uid); ImapPushState oldPushState = ImapPushState.parse(oldSerializedPushState); if (messageUid >= oldPushState.uidNext) { long uidNext = messageUid + 1; ImapPushState newPushState = new ImapPushState(uidNext); return newPushState.toString(); } else { return null; } } catch (Exception e) { Timber.e(e, "Exception while updated push state for %s", getLogId()); return null; } } ImapFolder(ImapStore store, String id);   ImapFolder(ImapStore store, String id, FolderNameCodec folderNameCodec); @Override void open(int mode); @Override boolean isOpen(); @Override int getMode(); @Override void close(); @Override String getId(); @Override String getParentId(); @Override String getName(); @Override boolean exists(); @Override boolean canHaveSubFolders(); @Override boolean create(FolderType type); @Override Map<String, String> copyMessages(List<? extends Message> messages, Folder folder); @Override Map<String, String> moveMessages(List<? extends Message> messages, Folder folder); @Override void delete(List<? extends Message> messages, String trashFolderName); @Override int getMessageCount(); @Override int getUnreadMessageCount(); @Override int getFlaggedMessageCount(); @Override void delete(boolean recurse); @Override ImapMessage getMessage(String uid); @Override List<ImapMessage> getMessages(int start, int end, Date earliestDate,
            MessageRetrievalListener<ImapMessage> listener); @Override boolean areMoreMessagesAvailable(int indexOfOldestMessage, Date earliestDate); @Override void fetch(List<ImapMessage> messages, FetchProfile fetchProfile,
            MessageRetrievalListener<ImapMessage> listener); @Override void fetchPart(Message message, Part part, MessageRetrievalListener<Message> listener,
            BodyFactory bodyFactory); @Override Map<String, String> appendMessages(List<? extends Message> messages); @Override String getUidFromMessageId(Message message); @Override void expunge(); @Override void setFlags(Set<Flag> flags, boolean value); @Override String getNewPushState(String oldSerializedPushState, Message message); @Override void setFlags(List<? extends Message> messages, final Set<Flag> flags, boolean value); @Override boolean equals(Object other); @Override int hashCode(); @Override List<ImapMessage> search(final String queryString, final Set<Flag> requiredFlags,
            final Set<Flag> forbiddenFlags);  }### Answer:
@Test public void getNewPushState_withNewerUid_shouldReturnNewPushState() throws Exception { ImapFolder folder = createFolder("Folder"); prepareImapFolderForOpen(OPEN_MODE_RW); ImapMessage message = createImapMessage("2"); String newPushState = folder.getNewPushState("uidNext=2", message); assertEquals("uidNext=3", newPushState); }
@Test public void getNewPushState_withoutNewerUid_shouldReturnNull() throws Exception { ImapFolder folder = createFolder("Folder"); prepareImapFolderForOpen(OPEN_MODE_RW); ImapMessage message = createImapMessage("1"); String newPushState = folder.getNewPushState("uidNext=2", message); assertNull(newPushState); }