diff options
Diffstat (limited to 'tests/teststore.cpp')
-rw-r--r-- | tests/teststore.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/teststore.cpp b/tests/teststore.cpp index e5a3ea88..24067f4f 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp | |||
@@ -160,6 +160,9 @@ 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 << "; got multiple elements, but returning the first one."; | ||
165 | } | ||
163 | return list.first(); | 166 | return list.first(); |
164 | } | 167 | } |
165 | return {}; | 168 | return {}; |
@@ -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; |