summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/maildirresourcetest.cpp38
1 files changed, 11 insertions, 27 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp
index 8952ff2..146489d 100644
--- a/tests/maildirresourcetest.cpp
+++ b/tests/maildirresourcetest.cpp
@@ -320,10 +320,9 @@ private Q_SLOTS:
320 } 320 }
321 auto mail = mails.first(); 321 auto mail = mails.first();
322 322
323 auto inspectionCommand = Akonadi2::Resources::Inspection::ExistenceInspection(*mail, true);
324 return Store::remove(*mail) 323 return Store::remove(*mail)
325 .then(Store::flushMessageQueue(query.resources)) //The change needs to be replayed already 324 .then(Store::flushMessageQueue(query.resources)) //The change needs to be replayed already
326 .then(Resources::inspect<Mail>(inspectionCommand)); 325 .then(Resources::inspect<Mail>(Resources::Inspection::ExistenceInspection(*mail, false)));
327 }) 326 })
328 .then<void>([](){}); 327 .then<void>([](){});
329 }) 328 })
@@ -338,45 +337,30 @@ private Q_SLOTS:
338 using namespace Akonadi2::ApplicationDomain; 337 using namespace Akonadi2::ApplicationDomain;
339 338
340 auto query = Query::ResourceFilter("org.kde.maildir.instance1"); 339 auto query = Query::ResourceFilter("org.kde.maildir.instance1");
341 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 340 Store::synchronize(query).exec().waitForFinished();
342 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 341 Store::flushMessageQueue(query.resources).exec().waitForFinished();
343 342
344 auto result = Store::fetchOne<Folder>( 343 auto result = Store::fetchOne<Folder>(
345 Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") 344 Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name")
346 ) 345 )
347 .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { 346 .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) {
347 Trace() << "Found a folder" << folder.identifier();
348 return Store::fetchAll<Mail>( 348 return Store::fetchAll<Mail>(
349 Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") 349 Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject")
350 ) 350 )
351 .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([](const QList<Mail::Ptr> &mails) -> KAsync::Job<void> { 351 .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) {
352 //Can't use QCOMPARE because it tries to return 352 //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE
353 if (mails.size() != 1) { 353 if (mails.size() != 1) {
354 return KAsync::error<void>(1, "Wrong number of mails."); 354 return KAsync::error<void>(1, "Wrong number of mails.");
355 } 355 }
356 auto mail = mails.first(); 356 auto mail = mails.first();
357 mail->setProperty("unread", true); 357 mail->setProperty("unread", true);
358 return Akonadi2::Store::modify(*mail); 358 auto inspectionCommand = Resources::Inspection::PropertyInspection(*mail, "unread", true);
359 return Store::modify(*mail)
360 .then<void>(Store::flushMessageQueue(query.resources)) //The change needs to be replayed already
361 .then(Resources::inspect<Mail>(inspectionCommand));
359 }) 362 })
360 .then<void>(Akonadi2::Store::flushMessageQueue(query.resources)) 363 .then<void>([](){});
361 .then<void, KAsync::Job<void> >([folder]() {
362 return Store::fetchAll<Mail>(
363 Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject" << "unread")
364 )
365 .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
366 //Can't use QCOMPARE because it tries to return
367 if (mails.size() != 1) {
368 return KAsync::error<void>(1, "Wrong number of mails.");
369 }
370 auto mail = mails.first();
371 //Can't use QCOMPARE because it tries to return
372 if (mail->getProperty("unread").toBool() != true) {
373 return KAsync::error<void>(1, "Wrong property value.");
374 }
375 auto inspectionCommand = Akonadi2::Resources::Inspection::PropertyInspection(*mail, "unread", true);
376 return Akonadi2::Resources::inspect<Mail>(inspectionCommand);
377 })
378 .then<void>([](){});
379 });
380 }) 364 })
381 .exec(); 365 .exec();
382 result.waitForFinished(); 366 result.waitForFinished();