summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-10-17 11:46:33 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-10-17 11:46:33 (GMT)
commit43fb2f8088ac74c99f029644e5e3400af8e26035 (patch)
tree8825330a3fadbcf390cfd0db98ee778993d9decd
parent874ca245ef248cb1505e2f6e980a876e2fb2b340 (diff)
downloadkolab-utils-43fb2f8088ac74c99f029644e5e3400af8e26035.tar.gz
Subfolders are not needed (it's a list anyways), check that objects are actually migrated.
-rw-r--r--migrationutility/sourceaccount.cpp1
-rw-r--r--migrationutility/tests/migrationscenariotest.cpp70
2 files changed, 26 insertions, 45 deletions
diff --git a/migrationutility/sourceaccount.cpp b/migrationutility/sourceaccount.cpp
index f3074d2..8d61bfb 100644
--- a/migrationutility/sourceaccount.cpp
+++ b/migrationutility/sourceaccount.cpp
@@ -111,6 +111,7 @@ QStringList KolabSourceAccount::lookupFolderList()
{
// Debug() << "lookupFolderList" << mHost << mPort << mUsername << mPw;
init();
+ mMailboxes.clear();
KIMAP::ListJob *listJob = new KIMAP::ListJob(mSession);
listJob->setOption(KIMAP::ListJob::IncludeUnsubscribed);
diff --git a/migrationutility/tests/migrationscenariotest.cpp b/migrationutility/tests/migrationscenariotest.cpp
index bc0fc35..8f604a4 100644
--- a/migrationutility/tests/migrationscenariotest.cpp
+++ b/migrationutility/tests/migrationscenariotest.cpp
@@ -18,6 +18,7 @@
#include <QObject>
#include <QTest>
#include <QDebug>
+#include <kolabobject.h>
#include "migrationutility/coordinationjob.h"
#include "migrationutility/kolabserver.h"
#include "migrationutility/sourceserver.h"
@@ -26,8 +27,7 @@
struct Folder
{
- Folder(const QString &n, Kolab::FolderType type = Kolab::MailType, const QList<Object> &obj = QList<Object>(), const QList<Folder> &folders = QList<Folder>()): subfolders(folders), objects(obj), name(n), folderType(type){};
- QList<Folder> subfolders;
+ Folder(const QString &n, Kolab::FolderType type = Kolab::MailType, const QList<Object> &obj = QList<Object>()): objects(obj), name(n), folderType(type){};
QList<Object> objects;
QString name;
Kolab::FolderType folderType;
@@ -64,6 +64,12 @@ public:
{
folders << Folder("INBOX");
folders << Folder("Calendar", Kolab::EventType);
+ Object calObj1;
+ KCalCore::Event::Ptr event(new KCalCore::Event());
+ event->setUid("uid");
+ calObj1.message = Kolab::KolabObjectWriter::writeEvent(event, Kolab::KolabV2, "migrationtest");
+ calObj1.flags << QByteArray("\\Seen");
+ folders << Folder("Calendar/Personal Calendar", Kolab::EventType, QList<Object>() << calObj1);
folders << Folder("Configuration", Kolab::ConfigurationType);
folders << Folder("Contacts", Kolab::ContactType);
folders << Folder("Drafts");
@@ -93,7 +99,6 @@ private:
foreach(const Object &obj, folder.objects) {
account->appendObject(obj, folder.name);
}
- createFolders(account, folder.subfolders);
}
}
@@ -107,11 +112,6 @@ private:
// account->setupFolders();
// account->createFolder();
createFolders(account, folders);
- Object calObj1;
-// calObj1.message =
- calObj1.flags << QByteArray("\\Seen");
- account->appendObject(calObj1, "Calendar");
-
}
void setupTargetAccount()
@@ -135,36 +135,28 @@ private:
CoordinationJob *job = new CoordinationJob(kolabSourceServer, kolabServer, &obj);
job->exec();
}
-
- void checkFolder(const QString &folder, const QList<Object> &objects)
+
+ void checkFolders(SourceAccount *account, const QList<Folder> &folders)
{
- foreach(const Object &obj, objects) {
- qDebug() << "Object: " << obj.flags;
+ const QStringList &receivedFolders = account->lookupFolderList();
+ QStringList::const_iterator recIt = receivedFolders.constBegin();
+ QList<Folder>::const_iterator foldersIt = folders.constBegin();
+ for (;foldersIt != folders.constEnd() && recIt != receivedFolders.constEnd(); ++foldersIt, ++recIt) {
+ qDebug() << "Folder: " << *recIt;
+ QCOMPARE(*recIt, foldersIt->name);
+ //Check folder annotations
+
+ const QList<Object> &objects = account->getObjects(foldersIt->name);
+ QCOMPARE(objects.size(), foldersIt->objects.size());
+ //Check converted messages
+ foreach(const Object &obj, objects) {
+ qDebug() << "Object: " << obj.flags;
+ }
}
}
void checkTargetAccount()
{
- QStringList expectedFolders;
- expectedFolders << QLatin1String("INBOX");
-// expectedFolders << QLatin1String("Archive");
- expectedFolders << QLatin1String("Calendar");
-// expectedFolders << QLatin1String("Calendar/Personal Calendar");
-// expectedFolders << QLatin1String("Calendar/Personal Calendar/another Folder");
- expectedFolders << QLatin1String("Configuration");
- expectedFolders << QLatin1String("Contacts");
-// expectedFolders << QLatin1String("Contacts/Personal Contacts");
-// expectedFolders << QLatin1String("Contacts/Personal Contacts/contacts");
- expectedFolders << QLatin1String("Drafts");
-// expectedFolders << QLatin1String("Freebusy");
- expectedFolders << QLatin1String("Journal");
- expectedFolders << QLatin1String("Notes");
- expectedFolders << QLatin1String("Sent");
-// expectedFolders << QLatin1String("Spam");
- expectedFolders << QLatin1String("Tasks");
-// expectedFolders << QLatin1String("Tasks/aasdf");
-// expectedFolders << QLatin1String("Tasks/dfdslkjfdsljfs");
- expectedFolders << QLatin1String("Trash");
QObject obj;
KolabSourceServer *kolabSourceServer = new KolabSourceServer(&obj);
@@ -173,20 +165,8 @@ private:
kolabSourceServer->setSingleUser(user);
SourceAccount *account = kolabSourceServer->getSourceAccount(user);
- const QStringList &receivedFolders = account->lookupFolderList();
- foreach (const QString & folder, receivedFolders) {
- qDebug() << "Folder: " << folder;
- checkFolder(folder, account->getObjects(folder));
- }
+ checkFolders(account, folders);
account->logout();
-
- QCOMPARE(receivedFolders, expectedFolders);
-
- //Check created folder
- //Check folder annotations
- //Check converted messages
-
-
}
void checkSourceAccount()