summaryrefslogtreecommitdiffstats
path: root/tests/teststore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/teststore.cpp')
-rw-r--r--tests/teststore.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/teststore.cpp b/tests/teststore.cpp
index e5a3ea88..9d56dd33 100644
--- a/tests/teststore.cpp
+++ b/tests/teststore.cpp
@@ -160,11 +160,14 @@ QVariant TestStore::load(const QByteArray &type, const QVariantMap &filter)
160 using namespace Sink::ApplicationDomain; 160 using namespace Sink::ApplicationDomain;
161 const auto list = loadList(type, filter); 161 const auto list = loadList(type, filter);
162 if (!list.isEmpty()) { 162 if (!list.isEmpty()) {
163 if (list.size() > 1) {
164 qWarning() << "While loading" << type << "with filter" << filter
165 << "; got multiple elements, but returning the first one.";
166 }
163 return list.first(); 167 return list.first();
164 } 168 }
165 return {}; 169 return {};
166} 170}
167
168template <typename T> 171template <typename T>
169QVariantList toVariantList(const QList<T> &list) 172QVariantList toVariantList(const QList<T> &list)
170{ 173{
@@ -183,6 +186,17 @@ QVariantList TestStore::loadList(const QByteArray &type, const QVariantMap &filt
183 if (filter.contains("resource")) { 186 if (filter.contains("resource")) {
184 query.resourceFilter(filter.value("resource").toByteArray()); 187 query.resourceFilter(filter.value("resource").toByteArray());
185 } 188 }
189
190 for (QVariantMap::const_iterator it = filter.begin(); it != filter.end(); ++it) {
191 if (it.key() == "messageId") {
192 query.filter<Mail::MessageId>(it.value());
193 } else if (it.key() == "draft") {
194 query.filter<Mail::Draft>(it.value());
195 } else if (it.key() == "subject") {
196 query.filter<Mail::Subject>(it.value());
197 }
198 }
199
186 if (type == "mail") { 200 if (type == "mail") {
187 return toVariantList(Sink::Store::read<Mail>(query)); 201 return toVariantList(Sink::Store::read<Mail>(query));
188 } 202 }
@@ -205,6 +219,7 @@ QVariantMap TestStore::read(const QVariant &object)
205 using namespace Sink::ApplicationDomain; 219 using namespace Sink::ApplicationDomain;
206 QVariantMap map; 220 QVariantMap map;
207 if (auto mail = object.value<Mail::Ptr>()) { 221 if (auto mail = object.value<Mail::Ptr>()) {
222 map.insert("uid", mail->identifier());
208 map.insert("subject", mail->getSubject()); 223 map.insert("subject", mail->getSubject());
209 map.insert("draft", mail->getDraft()); 224 map.insert("draft", mail->getDraft());
210 return map; 225 return map;