@Test public void getPersonalNamespaces_shouldSetSpecialFolderNames() throws Exception { StoreConfig storeConfig = createStoreConfig("webdav: WebDavStore webDavStore = new WebDavStore(storeConfig, mockHttpClientFactory); configureHttpResponses(UNAUTHORIZED_401_RESPONSE, OK_200_RESPONSE, createOkPropfindResponse(), createOkSearchResponse()); webDavStore.getFolders(true); verify(storeConfig).setInboxFolderId("Inbox"); }
@Override @NonNull public List<? extends Folder> getFolders(boolean forceListAll) throws MessagingException { List<Folder> folderList = new LinkedList<>(); getHttpClient(); Map<String, String> headers = new HashMap<>(); headers.put("Depth", "0"); headers.put("Brief", "t"); DataSet dataset = processRequest(this.baseUrl, "PROPFIND", getSpecialFoldersList(), headers); Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl(); String folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_INBOX_FOLDER)); if (folderId != null) { mStoreConfig.setAutoExpandFolderId(folderId); mStoreConfig.setInboxFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_DRAFTS_FOLDER)); if (folderId != null) { mStoreConfig.setDraftsFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_TRASH_FOLDER)); if (folderId != null) { mStoreConfig.setTrashFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SPAM_FOLDER)); if (folderId != null) { mStoreConfig.setSpamFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SENT_FOLDER)); if (folderId != null) { mStoreConfig.setSentFolderId(folderId); } headers = new HashMap<>(); headers.put("Brief", "t"); dataset = processRequest(this.baseUrl, "SEARCH", getFolderListXml(), headers); String[] folderUrls = dataset.getHrefs(); for (String tempUrl : folderUrls) { WebDavFolder folder = createFolder(tempUrl); if (folder != null) { folderList.add(folder); } } return folderList; }
WebDavStore extends RemoteStore { @Override @NonNull public List<? extends Folder> getFolders(boolean forceListAll) throws MessagingException { List<Folder> folderList = new LinkedList<>(); getHttpClient(); Map<String, String> headers = new HashMap<>(); headers.put("Depth", "0"); headers.put("Brief", "t"); DataSet dataset = processRequest(this.baseUrl, "PROPFIND", getSpecialFoldersList(), headers); Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl(); String folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_INBOX_FOLDER)); if (folderId != null) { mStoreConfig.setAutoExpandFolderId(folderId); mStoreConfig.setInboxFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_DRAFTS_FOLDER)); if (folderId != null) { mStoreConfig.setDraftsFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_TRASH_FOLDER)); if (folderId != null) { mStoreConfig.setTrashFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SPAM_FOLDER)); if (folderId != null) { mStoreConfig.setSpamFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SENT_FOLDER)); if (folderId != null) { mStoreConfig.setSentFolderId(folderId); } headers = new HashMap<>(); headers.put("Brief", "t"); dataset = processRequest(this.baseUrl, "SEARCH", getFolderListXml(), headers); String[] folderUrls = dataset.getHrefs(); for (String tempUrl : folderUrls) { WebDavFolder folder = createFolder(tempUrl); if (folder != null) { folderList.add(folder); } } return folderList; } }
WebDavStore extends RemoteStore { @Override @NonNull public List<? extends Folder> getFolders(boolean forceListAll) throws MessagingException { List<Folder> folderList = new LinkedList<>(); getHttpClient(); Map<String, String> headers = new HashMap<>(); headers.put("Depth", "0"); headers.put("Brief", "t"); DataSet dataset = processRequest(this.baseUrl, "PROPFIND", getSpecialFoldersList(), headers); Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl(); String folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_INBOX_FOLDER)); if (folderId != null) { mStoreConfig.setAutoExpandFolderId(folderId); mStoreConfig.setInboxFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_DRAFTS_FOLDER)); if (folderId != null) { mStoreConfig.setDraftsFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_TRASH_FOLDER)); if (folderId != null) { mStoreConfig.setTrashFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SPAM_FOLDER)); if (folderId != null) { mStoreConfig.setSpamFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SENT_FOLDER)); if (folderId != null) { mStoreConfig.setSentFolderId(folderId); } headers = new HashMap<>(); headers.put("Brief", "t"); dataset = processRequest(this.baseUrl, "SEARCH", getFolderListXml(), headers); String[] folderUrls = dataset.getHrefs(); for (String tempUrl : folderUrls) { WebDavFolder folder = createFolder(tempUrl); if (folder != null) { folderList.add(folder); } } return folderList; } WebDavStore(StoreConfig storeConfig, QMailHttpClientFactory clientFactory); }
WebDavStore extends RemoteStore { @Override @NonNull public List<? extends Folder> getFolders(boolean forceListAll) throws MessagingException { List<Folder> folderList = new LinkedList<>(); getHttpClient(); Map<String, String> headers = new HashMap<>(); headers.put("Depth", "0"); headers.put("Brief", "t"); DataSet dataset = processRequest(this.baseUrl, "PROPFIND", getSpecialFoldersList(), headers); Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl(); String folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_INBOX_FOLDER)); if (folderId != null) { mStoreConfig.setAutoExpandFolderId(folderId); mStoreConfig.setInboxFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_DRAFTS_FOLDER)); if (folderId != null) { mStoreConfig.setDraftsFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_TRASH_FOLDER)); if (folderId != null) { mStoreConfig.setTrashFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SPAM_FOLDER)); if (folderId != null) { mStoreConfig.setSpamFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SENT_FOLDER)); if (folderId != null) { mStoreConfig.setSentFolderId(folderId); } headers = new HashMap<>(); headers.put("Brief", "t"); dataset = processRequest(this.baseUrl, "SEARCH", getFolderListXml(), headers); String[] folderUrls = dataset.getHrefs(); for (String tempUrl : folderUrls) { WebDavFolder folder = createFolder(tempUrl); if (folder != null) { folderList.add(folder); } } return folderList; } WebDavStore(StoreConfig storeConfig, QMailHttpClientFactory clientFactory); static WebDavStoreSettings decodeUri(String uri); static String createUri(ServerSettings server); @Override void checkSettings(); @Override @NonNull List<? extends Folder> getFolders(boolean forceListAll); @NonNull @Override List<? extends Folder> getSubFolders(String parentFolderId, boolean forceListAll); @Override @NonNull WebDavFolder getFolder(String name); @Override boolean isMoveCapable(); @Override boolean isCopyCapable(); CookieStore getAuthCookies(); String getAlias(); String getUrl(); QMailHttpClient getHttpClient(); String getAuthString(); @Override boolean isSendCapable(); @Override void sendMessages(List<? extends Message> messages); }
WebDavStore extends RemoteStore { @Override @NonNull public List<? extends Folder> getFolders(boolean forceListAll) throws MessagingException { List<Folder> folderList = new LinkedList<>(); getHttpClient(); Map<String, String> headers = new HashMap<>(); headers.put("Depth", "0"); headers.put("Brief", "t"); DataSet dataset = processRequest(this.baseUrl, "PROPFIND", getSpecialFoldersList(), headers); Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl(); String folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_INBOX_FOLDER)); if (folderId != null) { mStoreConfig.setAutoExpandFolderId(folderId); mStoreConfig.setInboxFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_DRAFTS_FOLDER)); if (folderId != null) { mStoreConfig.setDraftsFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_TRASH_FOLDER)); if (folderId != null) { mStoreConfig.setTrashFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SPAM_FOLDER)); if (folderId != null) { mStoreConfig.setSpamFolderId(folderId); } folderId = getFolderId(specialFoldersMap.get(WebDavConstants.DAV_MAIL_SENT_FOLDER)); if (folderId != null) { mStoreConfig.setSentFolderId(folderId); } headers = new HashMap<>(); headers.put("Brief", "t"); dataset = processRequest(this.baseUrl, "SEARCH", getFolderListXml(), headers); String[] folderUrls = dataset.getHrefs(); for (String tempUrl : folderUrls) { WebDavFolder folder = createFolder(tempUrl); if (folder != null) { folderList.add(folder); } } return folderList; } WebDavStore(StoreConfig storeConfig, QMailHttpClientFactory clientFactory); static WebDavStoreSettings decodeUri(String uri); static String createUri(ServerSettings server); @Override void checkSettings(); @Override @NonNull List<? extends Folder> getFolders(boolean forceListAll); @NonNull @Override List<? extends Folder> getSubFolders(String parentFolderId, boolean forceListAll); @Override @NonNull WebDavFolder getFolder(String name); @Override boolean isMoveCapable(); @Override boolean isCopyCapable(); CookieStore getAuthCookies(); String getAlias(); String getUrl(); QMailHttpClient getHttpClient(); String getAuthString(); @Override boolean isSendCapable(); @Override void sendMessages(List<? extends Message> messages);  }