diff --git a/src/akonadi/akonadicachingstorage.h b/src/akonadi/akonadicachingstorage.h --- a/src/akonadi/akonadicachingstorage.h +++ b/src/akonadi/akonadicachingstorage.h @@ -51,7 +51,7 @@ KJob *createTransaction(QObject *parent) override; - CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) override; + CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth, QObject *parent) override; ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) override; ItemFetchJobInterface *fetchItem(Akonadi::Item item, QObject *parent) override; diff --git a/src/akonadi/akonadicachingstorage.cpp b/src/akonadi/akonadicachingstorage.cpp --- a/src/akonadi/akonadicachingstorage.cpp +++ b/src/akonadi/akonadicachingstorage.cpp @@ -61,7 +61,8 @@ QTimer::singleShot(0, this, &CachingCollectionFetchJob::retrieveFromCache); } else { auto job = m_storage->fetchCollections(Akonadi::Collection::root(), - Akonadi::StorageInterface::Recursive); + Akonadi::StorageInterface::Recursive, + this); job->setResource(m_resource); addSubjob(job->kjob()); } @@ -363,9 +364,9 @@ return m_storage->createTransaction(parent); } -CollectionFetchJobInterface *CachingStorage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth) +CollectionFetchJobInterface *CachingStorage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth, QObject *parent) { - return new CachingCollectionFetchJob(m_storage, m_cache, collection, depth); + return new CachingCollectionFetchJob(m_storage, m_cache, collection, depth, parent); } ItemFetchJobInterface *CachingStorage::fetchItems(Collection collection, QObject *parent) diff --git a/src/akonadi/akonadidatasourcequeries.cpp b/src/akonadi/akonadidatasourcequeries.cpp --- a/src/akonadi/akonadidatasourcequeries.cpp +++ b/src/akonadi/akonadidatasourcequeries.cpp @@ -54,7 +54,7 @@ DataSourceQueries::DataSourceResult::Ptr DataSourceQueries::findTopLevel() const { - auto fetch = m_helpers->fetchCollections(Collection::root()); + auto fetch = m_helpers->fetchCollections(Collection::root(), const_cast(this)); auto predicate = createFetchPredicate(Collection::root()); m_integrator->bind("DataSourceQueries::findTopLevel", m_findTopLevel, fetch, predicate); return m_findTopLevel->result(); @@ -64,15 +64,15 @@ { Collection root = m_serializer->createCollectionFromDataSource(source); auto &query = m_findChildren[root.id()]; - auto fetch = m_helpers->fetchCollections(root); + auto fetch = m_helpers->fetchCollections(root, const_cast(this)); auto predicate = createFetchPredicate(root); m_integrator->bind("DataSourceQueries::findChildren", query, fetch, predicate); return query->result(); } DataSourceQueries::DataSourceResult::Ptr DataSourceQueries::findAllSelected() const { - auto fetch = m_helpers->fetchAllCollections(); + auto fetch = m_helpers->fetchAllCollections(const_cast(this)); auto predicate = [this] (const Akonadi::Collection &collection) { return collection.isValid() && m_serializer->isSelectedCollection(collection); }; diff --git a/src/akonadi/akonadilivequeryhelpers.h b/src/akonadi/akonadilivequeryhelpers.h --- a/src/akonadi/akonadilivequeryhelpers.h +++ b/src/akonadi/akonadilivequeryhelpers.h @@ -43,9 +43,9 @@ LiveQueryHelpers(const SerializerInterface::Ptr &serializer, const StorageInterface::Ptr &storage); - CollectionFetchFunction fetchAllCollections() const; - CollectionFetchFunction fetchCollections(const Collection &root) const; - CollectionFetchFunction fetchItemCollection(const Item &item) const; + CollectionFetchFunction fetchAllCollections(QObject *parent) const; + CollectionFetchFunction fetchCollections(const Collection &root, QObject *parent) const; + CollectionFetchFunction fetchItemCollection(const Item &item, QObject *parent) const; ItemFetchFunction fetchItems(QObject *parent) const; ItemFetchFunction fetchItems(const Collection &collection, QObject *parent) const; diff --git a/src/akonadi/akonadilivequeryhelpers.cpp b/src/akonadi/akonadilivequeryhelpers.cpp --- a/src/akonadi/akonadilivequeryhelpers.cpp +++ b/src/akonadi/akonadilivequeryhelpers.cpp @@ -39,11 +39,11 @@ { } -LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchAllCollections() const +LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchAllCollections(QObject *parent) const { auto storage = m_storage; - return [storage] (const Domain::LiveQueryInput::AddFunction &add) { - auto job = storage->fetchCollections(Collection::root(), StorageInterface::Recursive); + return [storage, parent] (const Domain::LiveQueryInput::AddFunction &add) { + auto job = storage->fetchCollections(Collection::root(), StorageInterface::Recursive, parent); Utils::JobHandler::install(job->kjob(), [job, add] { if (job->kjob()->error()) return; @@ -54,11 +54,11 @@ }; } -LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchCollections(const Collection &root) const +LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchCollections(const Collection &root, QObject *parent) const { auto storage = m_storage; - return [storage, root] (const Domain::LiveQueryInput::AddFunction &add) { - auto job = storage->fetchCollections(root, StorageInterface::Recursive); + return [storage, root, parent] (const Domain::LiveQueryInput::AddFunction &add) { + auto job = storage->fetchCollections(root, StorageInterface::Recursive, parent); Utils::JobHandler::install(job->kjob(), [root, job, add] { if (job->kjob()->error()) return; @@ -84,7 +84,8 @@ auto storage = m_storage; return [serializer, storage, parent] (const Domain::LiveQueryInput::AddFunction &add) { auto job = storage->fetchCollections(Akonadi::Collection::root(), - StorageInterface::Recursive); + StorageInterface::Recursive, + parent); Utils::JobHandler::install(job->kjob(), [serializer, storage, job, add, parent] { if (job->kjob()->error() != KJob::NoError) return; @@ -178,11 +179,11 @@ }; } -LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchItemCollection(const Item& item) const +LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchItemCollection(const Item& item, QObject *parent) const { auto storage = m_storage; - return [storage, item] (const Domain::LiveQueryInput::AddFunction &add) { - auto job = storage->fetchCollections(item.parentCollection(), StorageInterface::Base); + return [storage, item, parent] (const Domain::LiveQueryInput::AddFunction &add) { + auto job = storage->fetchCollections(item.parentCollection(), StorageInterface::Base, parent); Utils::JobHandler::install(job->kjob(), [storage, job, add] { if (job->kjob()->error() != KJob::NoError) return; diff --git a/src/akonadi/akonadistorage.h b/src/akonadi/akonadistorage.h --- a/src/akonadi/akonadistorage.h +++ b/src/akonadi/akonadistorage.h @@ -52,7 +52,7 @@ KJob *createTransaction(QObject *parent) override; - CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) override; + CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth, QObject *parent) override; ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) override; ItemFetchJobInterface *fetchItem(Akonadi::Item item, QObject *parent) override; diff --git a/src/akonadi/akonadistorage.cpp b/src/akonadi/akonadistorage.cpp --- a/src/akonadi/akonadistorage.cpp +++ b/src/akonadi/akonadistorage.cpp @@ -193,9 +193,9 @@ return new TransactionSequence(parent); } -CollectionFetchJobInterface *Storage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth) +CollectionFetchJobInterface *Storage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth, QObject *parent) { - auto job = new CollectionJob(collection, jobTypeFromDepth(depth)); + auto job = new CollectionJob(collection, jobTypeFromDepth(depth), parent); auto scope = job->fetchScope(); scope.setContentMimeTypes({KCalCore::Todo::todoMimeType()}); diff --git a/src/akonadi/akonadistorageinterface.h b/src/akonadi/akonadistorageinterface.h --- a/src/akonadi/akonadistorageinterface.h +++ b/src/akonadi/akonadistorageinterface.h @@ -67,7 +67,7 @@ virtual KJob *createTransaction(QObject *parent) = 0; - virtual CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) = 0; + virtual CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth, QObject *parent) = 0; virtual ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) = 0; virtual ItemFetchJobInterface *fetchItem(Akonadi::Item item, QObject *parent) = 0; }; diff --git a/src/akonadi/akonaditaskqueries.cpp b/src/akonadi/akonaditaskqueries.cpp --- a/src/akonadi/akonaditaskqueries.cpp +++ b/src/akonadi/akonaditaskqueries.cpp @@ -110,7 +110,7 @@ { Akonadi::Item item = m_serializer->createItemFromTask(task); auto &query = m_findDataSource[item.id()]; - auto fetch = m_helpers->fetchItemCollection(item); + auto fetch = m_helpers->fetchItemCollection(item, const_cast(this)); auto predicate = [] (const Akonadi::Collection &) { return true; }; m_integrator->bind("TaskQueries::findDataSource", query, fetch, predicate); diff --git a/src/akonadi/akonaditaskrepository.cpp b/src/akonadi/akonaditaskrepository.cpp --- a/src/akonadi/akonaditaskrepository.cpp +++ b/src/akonadi/akonaditaskrepository.cpp @@ -51,7 +51,8 @@ } else { auto job = new CompositeJob(); CollectionFetchJobInterface *fetchCollectionJob = m_storage->fetchCollections(Akonadi::Collection::root(), - StorageInterface::Recursive); + StorageInterface::Recursive, + this); job->install(fetchCollectionJob->kjob(), [fetchCollectionJob, item, job, this] { if (fetchCollectionJob->kjob()->error() != KJob::NoError) return; diff --git a/src/zanshin/migrator/zanshin021migrator.cpp b/src/zanshin/migrator/zanshin021migrator.cpp --- a/src/zanshin/migrator/zanshin021migrator.cpp +++ b/src/zanshin/migrator/zanshin021migrator.cpp @@ -50,7 +50,7 @@ { SeenItemHash hash; - auto collectionsJob = m_storage.fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive); + auto collectionsJob = m_storage.fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive, nullptr); collectionsJob->kjob()->exec(); auto collections = collectionsJob->collections(); diff --git a/src/zanshin/migrator/zanshincontextitemsmigrator.cpp b/src/zanshin/migrator/zanshincontextitemsmigrator.cpp --- a/src/zanshin/migrator/zanshincontextitemsmigrator.cpp +++ b/src/zanshin/migrator/zanshincontextitemsmigrator.cpp @@ -46,7 +46,7 @@ { FetchResult result; - auto collectionsJob = m_storage.fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive); + auto collectionsJob = m_storage.fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive, nullptr); collectionsJob->kjob()->exec(); int deletedCount = 0; diff --git a/tests/testlib/akonadidebug.cpp b/tests/testlib/akonadidebug.cpp --- a/tests/testlib/akonadidebug.cpp +++ b/tests/testlib/akonadidebug.cpp @@ -31,7 +31,8 @@ void TestLib::AkonadiDebug::dumpTree(const Akonadi::StorageInterface::Ptr &storage) { auto colJob = storage->fetchCollections(Akonadi::Collection::root(), - Akonadi::StorageInterface::Recursive); + Akonadi::StorageInterface::Recursive, + nullptr); colJob->kjob()->exec(); foreach (const auto &col, colJob->collections()) { qDebug() << "COL:" << col.id() << col.name() << col.remoteId(); diff --git a/tests/testlib/akonadifakestorage.h b/tests/testlib/akonadifakestorage.h --- a/tests/testlib/akonadifakestorage.h +++ b/tests/testlib/akonadifakestorage.h @@ -50,7 +50,7 @@ KJob *createTransaction(QObject *parent) override; - Akonadi::CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) override; + Akonadi::CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth, QObject *parent) override; Akonadi::ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) override; Akonadi::ItemFetchJobInterface *fetchItem(Akonadi::Item item, QObject *parent) override; diff --git a/tests/testlib/akonadifakestorage.cpp b/tests/testlib/akonadifakestorage.cpp --- a/tests/testlib/akonadifakestorage.cpp +++ b/tests/testlib/akonadifakestorage.cpp @@ -311,9 +311,10 @@ } Akonadi::CollectionFetchJobInterface *AkonadiFakeStorage::fetchCollections(Akonadi::Collection collection, - Akonadi::StorageInterface::FetchDepth depth) + Akonadi::StorageInterface::FetchDepth depth, + QObject *parent) { - auto job = new AkonadiFakeCollectionFetchJob; + auto job = new AkonadiFakeCollectionFetchJob(parent); auto children = Akonadi::Collection::List(); switch (depth) { diff --git a/tests/testlib/akonadistoragetestbase.cpp b/tests/testlib/akonadistoragetestbase.cpp --- a/tests/testlib/akonadistoragetestbase.cpp +++ b/tests/testlib/akonadistoragetestbase.cpp @@ -100,7 +100,7 @@ auto storage = createStorage(); // WHEN - auto job = storage->fetchCollections(collection, depth); + auto job = storage->fetchCollections(collection, depth, nullptr); AKVERIFYEXEC(job->kjob()); // THEN @@ -122,7 +122,8 @@ // WHEN auto job = storage->fetchCollections(Akonadi::Collection::root(), - Akonadi::Storage::Recursive); + Akonadi::Storage::Recursive, + nullptr); AKVERIFYEXEC(job->kjob()); // THEN @@ -798,7 +799,7 @@ Akonadi::Collection collection; collection.setRemoteId(remoteId); - auto job = createStorage()->fetchCollections(collection, Akonadi::StorageInterface::Base); + auto job = createStorage()->fetchCollections(collection, Akonadi::StorageInterface::Base, nullptr); job->setResource(QStringLiteral("akonadi_knut_resource_0")); if (!job->kjob()->exec()) { qWarning() << job->kjob()->errorString() << remoteId; diff --git a/tests/units/akonadi/akonadicachingstoragetest.cpp b/tests/units/akonadi/akonadicachingstoragetest.cpp --- a/tests/units/akonadi/akonadicachingstoragetest.cpp +++ b/tests/units/akonadi/akonadicachingstoragetest.cpp @@ -141,7 +141,7 @@ // WHEN QFETCH(Akonadi::Collection, rootCollection); QFETCH(Akonadi::StorageInterface::FetchDepth, fetchDepth); - auto job = storage.fetchCollections(rootCollection, fetchDepth); + auto job = storage.fetchCollections(rootCollection, fetchDepth, nullptr); QVERIFY2(job->kjob()->exec(), qPrintable(job->kjob()->errorString())); // THEN @@ -170,7 +170,7 @@ // WHEN (second time shouldn't hit the original storage) data.storageBehavior().setFetchCollectionsBehavior(rootCollection.id(), AkonadiFakeStorageBehavior::EmptyFetch); data.storageBehavior().setFetchCollectionsErrorCode(rootCollection.id(), 128); - job = storage.fetchCollections(rootCollection, fetchDepth); + job = storage.fetchCollections(rootCollection, fetchDepth, nullptr); QVERIFY2(job->kjob()->exec(), qPrintable(job->kjob()->errorString())); { diff --git a/tests/units/akonadi/akonadilivequeryhelperstest.cpp b/tests/units/akonadi/akonadilivequeryhelperstest.cpp --- a/tests/units/akonadi/akonadilivequeryhelperstest.cpp +++ b/tests/units/akonadi/akonadilivequeryhelperstest.cpp @@ -100,7 +100,7 @@ }; // WHEN - auto fetch = helpers->fetchAllCollections(); + auto fetch = helpers->fetchAllCollections(nullptr); fetch(add); TestHelpers::waitForEmptyJobQueue(); @@ -172,7 +172,7 @@ // WHEN QFETCH(Akonadi::Collection, root); - auto fetch = helpers->fetchCollections(root); + auto fetch = helpers->fetchCollections(root, nullptr); fetch(add); TestHelpers::waitForEmptyJobQueue(); diff --git a/tests/units/akonadi/akonadilivequeryintegratortest.cpp b/tests/units/akonadi/akonadilivequeryintegratortest.cpp --- a/tests/units/akonadi/akonadilivequeryintegratortest.cpp +++ b/tests/units/akonadi/akonadilivequeryintegratortest.cpp @@ -75,20 +75,20 @@ return Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer); } - auto fetchCollectionsFunction(Akonadi::StorageInterface::Ptr storage) { - return [storage] (const Domain::LiveQueryInput::AddFunction &add) { - auto job = storage->fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive); + auto fetchCollectionsFunction(Akonadi::StorageInterface::Ptr storage, QObject *parent) { + return [storage, parent] (const Domain::LiveQueryInput::AddFunction &add) { + auto job = storage->fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive, parent); Utils::JobHandler::install(job->kjob(), [add, job] { foreach (const auto &col, job->collections()) { add(col); } }); }; } - auto fetchItemsInAllCollectionsFunction(Akonadi::StorageInterface::Ptr storage) { - return [storage] (const Domain::LiveQueryInput::AddFunction &add) { - auto job = storage->fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive); + auto fetchItemsInAllCollectionsFunction(Akonadi::StorageInterface::Ptr storage, QObject *parent) { + return [storage, parent] (const Domain::LiveQueryInput::AddFunction &add) { + auto job = storage->fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive, parent); Utils::JobHandler::install(job->kjob(), [add, job, storage] { foreach (const auto &col, job->collections()) { auto itemJob = storage->fetchItems(col, nullptr); @@ -101,10 +101,10 @@ }; } - auto fetchItemsInSelectedCollectionsFunction(Akonadi::StorageInterface::Ptr storage, Akonadi::SerializerInterface::Ptr serializer) + auto fetchItemsInSelectedCollectionsFunction(Akonadi::StorageInterface::Ptr storage, Akonadi::SerializerInterface::Ptr serializer, QObject *parent) { - return [storage, serializer] (const Domain::LiveQueryInput::AddFunction &add) { - auto job = storage->fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive); + return [storage, serializer, parent] (const Domain::LiveQueryInput::AddFunction &add) { + auto job = storage->fetchCollections(Akonadi::Collection::root(), Akonadi::Storage::Recursive, parent); Utils::JobHandler::install(job->kjob(), [add, job, storage, serializer] { foreach (const auto &col, job->collections()) { if (!serializer->isSelectedCollection(col)) @@ -307,7 +307,7 @@ auto storage = createStorage(data); auto query = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchCollectionsFunction(storage); + auto fetch = fetchCollectionsFunction(storage, nullptr); auto predicate = [] (const Akonadi::Collection &collection) { return collection.name().endsWith(QLatin1String("-in")); }; @@ -410,7 +410,7 @@ auto inQuery = Domain::LiveQueryOutput::Ptr(); auto exQuery = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchCollectionsFunction(storage); + auto fetch = fetchCollectionsFunction(storage, nullptr); auto inPredicate = [] (const Akonadi::Collection &collection) { return collection.name().endsWith(QLatin1String("-in")); }; @@ -461,7 +461,7 @@ auto storage = createStorage(data); auto query = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchItemsInAllCollectionsFunction(storage); + auto fetch = fetchItemsInAllCollectionsFunction(storage, nullptr); auto predicate = [] (const Akonadi::Item &item) { return titleFromItem(item).endsWith(QLatin1String("-in")); }; @@ -572,7 +572,7 @@ auto inQuery = Domain::LiveQueryOutput::Ptr(); auto exQuery = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchItemsInAllCollectionsFunction(storage); + auto fetch = fetchItemsInAllCollectionsFunction(storage, nullptr); auto inPredicate = [] (const Akonadi::Item &item) { return titleFromItem(item).endsWith(QLatin1String("-in")); }; @@ -621,7 +621,7 @@ auto serializer = createSerializer(); auto query = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchItemsInSelectedCollectionsFunction(storage, serializer); + auto fetch = fetchItemsInSelectedCollectionsFunction(storage, serializer, nullptr); auto predicate = [] (const Akonadi::Item &) { return true; }; @@ -665,7 +665,7 @@ auto storage = createStorage(data); auto query = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchItemsInAllCollectionsFunction(storage); + auto fetch = fetchItemsInAllCollectionsFunction(storage, nullptr); auto predicate = [] (const Akonadi::Item &item) { return titleFromItem(item).endsWith(QLatin1String("-in")); }; @@ -771,7 +771,7 @@ auto inQuery = Domain::LiveQueryOutput::Ptr(); auto exQuery = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchItemsInAllCollectionsFunction(storage); + auto fetch = fetchItemsInAllCollectionsFunction(storage, nullptr); auto inPredicate = [] (const Akonadi::Item &item) { return titleFromItem(item).endsWith(QLatin1String("-in")); }; @@ -820,7 +820,7 @@ auto serializer = createSerializer(); auto query = Domain::LiveQueryOutput::Ptr(); - auto fetch = fetchItemsInSelectedCollectionsFunction(storage, serializer); + auto fetch = fetchItemsInSelectedCollectionsFunction(storage, serializer, nullptr); auto predicate = [] (const Akonadi::Item &) { return true; }; diff --git a/tests/units/akonadi/akonaditaskrepositorytest.cpp b/tests/units/akonadi/akonaditaskrepositorytest.cpp --- a/tests/units/akonadi/akonaditaskrepositorytest.cpp +++ b/tests/units/akonadi/akonaditaskrepositorytest.cpp @@ -113,22 +113,24 @@ // A mock create job auto itemCreateJob = new FakeJob(this); - // Storage mock returning the create job and with no default collection Utils::MockObject storageMock; + Utils::MockObject serializerMock; + QScopedPointer repository(new Akonadi::TaskRepository(storageMock.getInstance(), + serializerMock.getInstance())); + + // Storage mock returning the create job and with no default collection storageMock(&Akonadi::StorageInterface::defaultCollection).when().thenReturn(Akonadi::Collection()); storageMock(&Akonadi::StorageInterface::fetchCollections).when(Akonadi::Collection::root(), - Akonadi::StorageInterface::Recursive) + Akonadi::StorageInterface::Recursive, + repository.get()) .thenReturn(collectionFetchJob); storageMock(&Akonadi::StorageInterface::createItem).when(item, col3) .thenReturn(itemCreateJob); // Serializer mock returning the item for the task - Utils::MockObject serializerMock; serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(task).thenReturn(item); // WHEN - QScopedPointer repository(new Akonadi::TaskRepository(storageMock.getInstance(), - serializerMock.getInstance())); repository->create(task)->exec(); // THEN @@ -155,20 +157,22 @@ Akonadi::Item item; Domain::Task::Ptr task(new Domain::Task); - // Storage mock returning the create job and with no default collection Utils::MockObject storageMock; + Utils::MockObject serializerMock; + QScopedPointer repository(new Akonadi::TaskRepository(storageMock.getInstance(), + serializerMock.getInstance())); + + // Storage mock returning the create job and with no default collection storageMock(&Akonadi::StorageInterface::defaultCollection).when().thenReturn(Akonadi::Collection()); storageMock(&Akonadi::StorageInterface::fetchCollections).when(Akonadi::Collection::root(), - Akonadi::StorageInterface::Recursive) + Akonadi::StorageInterface::Recursive, + repository.get()) .thenReturn(collectionFetchJob); // Serializer mock returning the item for the task - Utils::MockObject serializerMock; serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(task).thenReturn(item); // WHEN - QScopedPointer repository(new Akonadi::TaskRepository(storageMock.getInstance(), - serializerMock.getInstance())); auto job = repository->create(task); job->exec();