File indexing completed on 2025-01-19 04:56:44

0001 /*
0002  * SPDX-FileCopyrightText: 2015 Kevin Ottens <ervin@kde.org>
0003  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 
0007 #include "akonadifakestoragebehavior.h"
0008 
0009 using namespace Testlib;
0010 
0011 AkonadiFakeStorageBehavior::AkonadiFakeStorageBehavior()
0012 {
0013 }
0014 
0015 AkonadiFakeStorageBehavior::~AkonadiFakeStorageBehavior()
0016 {
0017 }
0018 
0019 void AkonadiFakeStorageBehavior::setFetchCollectionsErrorCode(Akonadi::Collection::Id id, int errorCode)
0020 {
0021     m_fetchCollectionsErrorCode[id] = errorCode;
0022 }
0023 
0024 int AkonadiFakeStorageBehavior::fetchCollectionsErrorCode(Akonadi::Collection::Id id) const
0025 {
0026     return m_fetchCollectionsErrorCode.value(id, KJob::NoError);
0027 }
0028 
0029 void AkonadiFakeStorageBehavior::setFetchCollectionsBehavior(Akonadi::Collection::Id id, FetchBehavior behavior)
0030 {
0031     m_fetchCollectionsBehavior[id] = behavior;
0032 }
0033 
0034 AkonadiFakeStorageBehavior::FetchBehavior AkonadiFakeStorageBehavior::fetchCollectionsBehavior(Akonadi::Collection::Id id) const
0035 {
0036     return m_fetchCollectionsBehavior.value(id, NormalFetch);
0037 }
0038 
0039 void AkonadiFakeStorageBehavior::setSearchCollectionsErrorCode(const QString &name, int errorCode)
0040 {
0041     m_searchCollectionsErrorCode[name] = errorCode;
0042 }
0043 
0044 int AkonadiFakeStorageBehavior::searchCollectionsErrorCode(const QString &name) const
0045 {
0046     return m_searchCollectionsErrorCode.value(name, KJob::NoError);
0047 }
0048 
0049 void AkonadiFakeStorageBehavior::setSearchCollectionsBehavior(const QString &name, AkonadiFakeStorageBehavior::FetchBehavior behavior)
0050 {
0051     m_searchCollectionsBehavior[name] = behavior;
0052 }
0053 
0054 AkonadiFakeStorageBehavior::FetchBehavior AkonadiFakeStorageBehavior::searchCollectionsBehavior(const QString &name) const
0055 {
0056     return m_searchCollectionsBehavior.value(name, NormalFetch);
0057 }
0058 
0059 void AkonadiFakeStorageBehavior::setFetchItemsErrorCode(Akonadi::Collection::Id id, int errorCode)
0060 {
0061     m_fetchItemsErrorCode[id] = errorCode;
0062 }
0063 
0064 int AkonadiFakeStorageBehavior::fetchItemsErrorCode(Akonadi::Collection::Id id) const
0065 {
0066     return m_fetchItemsErrorCode.value(id, KJob::NoError);
0067 }
0068 
0069 void AkonadiFakeStorageBehavior::setFetchItemsBehavior(Akonadi::Collection::Id id, FetchBehavior behavior)
0070 {
0071     m_fetchItemsBehavior[id] = behavior;
0072 }
0073 
0074 AkonadiFakeStorageBehavior::FetchBehavior AkonadiFakeStorageBehavior::fetchItemsBehavior(Akonadi::Collection::Id id) const
0075 {
0076     return m_fetchItemsBehavior.value(id, NormalFetch);
0077 }
0078 
0079 void AkonadiFakeStorageBehavior::setFetchItemErrorCode(Akonadi::Item::Id id, int errorCode)
0080 {
0081     m_fetchItemErrorCode[id] = errorCode;
0082 }
0083 
0084 int AkonadiFakeStorageBehavior::fetchItemErrorCode(Akonadi::Item::Id id) const
0085 {
0086     return m_fetchItemErrorCode.value(id, KJob::NoError);
0087 }
0088 
0089 void AkonadiFakeStorageBehavior::setFetchItemBehavior(Akonadi::Item::Id id, FetchBehavior behavior)
0090 {
0091     m_fetchItemBehavior[id] = behavior;
0092 }
0093 
0094 AkonadiFakeStorageBehavior::FetchBehavior AkonadiFakeStorageBehavior::fetchItemBehavior(Akonadi::Item::Id id) const
0095 {
0096     return m_fetchItemBehavior.value(id, NormalFetch);
0097 }
0098 
0099 void AkonadiFakeStorageBehavior::setCreateNextItemError(int errorCode, const QString &errorText)
0100 {
0101     m_createNextItemErrorCode = errorCode;
0102     m_createNextItemErrorText = errorText;
0103 }
0104 
0105 int AkonadiFakeStorageBehavior::createNextItemErrorCode()
0106 {
0107     return std::exchange(m_createNextItemErrorCode, KJob::NoError);
0108 }
0109 
0110 QString AkonadiFakeStorageBehavior::createNextItemErrorText()
0111 {
0112     return std::exchange(m_createNextItemErrorText, QString());
0113 }
0114 
0115 void AkonadiFakeStorageBehavior::setDeleteNextItemError(int errorCode, const QString &errorText)
0116 {
0117     m_deleteNextItemErrorCode = errorCode;
0118     m_deleteNextItemErrorText = errorText;
0119 }
0120 
0121 int AkonadiFakeStorageBehavior::deleteNextItemErrorCode()
0122 {
0123     return std::exchange(m_deleteNextItemErrorCode, KJob::NoError);
0124 }
0125 
0126 QString AkonadiFakeStorageBehavior::deleteNextItemErrorText()
0127 {
0128     return std::exchange(m_deleteNextItemErrorText, QString());
0129 }
0130 
0131 void AkonadiFakeStorageBehavior::setUpdateNextItemError(int errorCode, const QString &errorText)
0132 {
0133     m_updateNextItemErrorCode = errorCode;
0134     m_updateNextItemErrorText = errorText;
0135 }
0136 
0137 int AkonadiFakeStorageBehavior::updateNextItemErrorCode()
0138 {
0139     return std::exchange(m_updateNextItemErrorCode, KJob::NoError);
0140 }
0141 
0142 QString AkonadiFakeStorageBehavior::updateNextItemErrorText()
0143 {
0144     return std::exchange(m_updateNextItemErrorText, QString());
0145 }