summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-27 16:15:44 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-27 16:15:44 +0200
commit5830d7e0d1d35494823f5fa61a4871b8d9df1c9d (patch)
tree1383d9b6ad926a97ee8376175c6bee01182dc096 /tests/querytest.cpp
parent529db49c496f4f668cec3f7c59d2d0ec78c50c9a (diff)
downloadsink-5830d7e0d1d35494823f5fa61a4871b8d9df1c9d.tar.gz
sink-5830d7e0d1d35494823f5fa61a4871b8d9df1c9d.zip
Use the Query::filter api.
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp119
1 files changed, 60 insertions, 59 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index ab2a7e5..be1e0f6 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -12,6 +12,7 @@
12#include "test.h" 12#include "test.h"
13#include "testutils.h" 13#include "testutils.h"
14 14
15using namespace Sink;
15using namespace Sink::ApplicationDomain; 16using namespace Sink::ApplicationDomain;
16 17
17/** 18/**
@@ -52,7 +53,7 @@ private slots:
52 query.liveQuery = true; 53 query.liveQuery = true;
53 54
54 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data 55 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
55 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 56 auto model = Sink::Store::loadModel<Mail>(query);
56 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 57 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
57 QCOMPARE(model->rowCount(), 0); 58 QCOMPARE(model->rowCount(), 0);
58 } 59 }
@@ -62,8 +63,8 @@ private slots:
62 { 63 {
63 // Setup 64 // Setup
64 { 65 {
65 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 66 Mail mail("sink.dummy.instance1");
66 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 67 Sink::Store::create<Mail>(mail).exec().waitForFinished();
67 } 68 }
68 69
69 // Test 70 // Test
@@ -72,7 +73,7 @@ private slots:
72 query.liveQuery = true; 73 query.liveQuery = true;
73 74
74 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data 75 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
75 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 76 auto model = Sink::Store::loadModel<Mail>(query);
76 QTRY_COMPARE(model->rowCount(), 1); 77 QTRY_COMPARE(model->rowCount(), 1);
77 } 78 }
78 79
@@ -80,8 +81,8 @@ private slots:
80 { 81 {
81 // Setup 82 // Setup
82 { 83 {
83 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 84 Mail mail("sink.dummy.instance1");
84 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 85 Sink::Store::create<Mail>(mail).exec().waitForFinished();
85 } 86 }
86 87
87 // Test 88 // Test
@@ -93,7 +94,7 @@ private slots:
93 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 94 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
94 95
95 // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data 96 // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data
96 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 97 auto model = Sink::Store::loadModel<Mail>(query);
97 98
98 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 99 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
99 QCOMPARE(model->rowCount(), 1); 100 QCOMPARE(model->rowCount(), 1);
@@ -125,7 +126,7 @@ private slots:
125 auto model = Sink::Store::loadModel<Mail>(query); 126 auto model = Sink::Store::loadModel<Mail>(query);
126 QTRY_COMPARE(model->rowCount(), 1); 127 QTRY_COMPARE(model->rowCount(), 1);
127 128
128 auto mail = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>(); 129 auto mail = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Mail::Ptr>();
129 { 130 {
130 mail->setFolder("folder2"); 131 mail->setFolder("folder2");
131 Sink::Store::modify<Mail>(*mail).exec().waitForFinished(); 132 Sink::Store::modify<Mail>(*mail).exec().waitForFinished();
@@ -144,9 +145,9 @@ private slots:
144 QByteArray id; 145 QByteArray id;
145 // Setup 146 // Setup
146 { 147 {
147 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 148 Mail mail("sink.dummy.instance1");
148 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 149 Sink::Store::create<Mail>(mail).exec().waitForFinished();
149 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 150 Sink::Store::create<Mail>(mail).exec().waitForFinished();
150 151
151 Sink::Query query; 152 Sink::Query query;
152 query.resources << "sink.dummy.instance1"; 153 query.resources << "sink.dummy.instance1";
@@ -155,17 +156,17 @@ private slots:
155 Sink::Store::synchronize(query).exec().waitForFinished(); 156 Sink::Store::synchronize(query).exec().waitForFinished();
156 157
157 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data 158 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
158 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 159 auto model = Sink::Store::loadModel<Mail>(query);
159 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 160 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
160 QVERIFY(model->rowCount() >= 1); 161 QVERIFY(model->rowCount() >= 1);
161 id = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->identifier(); 162 id = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Mail::Ptr>()->identifier();
162 } 163 }
163 164
164 // Test 165 // Test
165 Sink::Query query; 166 Sink::Query query;
166 query.resources << "sink.dummy.instance1"; 167 query.resources << "sink.dummy.instance1";
167 query.ids << id; 168 query.ids << id;
168 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 169 auto model = Sink::Store::loadModel<Mail>(query);
169 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 170 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
170 QCOMPARE(model->rowCount(), 1); 171 QCOMPARE(model->rowCount(), 1);
171 } 172 }
@@ -174,8 +175,8 @@ private slots:
174 { 175 {
175 // Setup 176 // Setup
176 { 177 {
177 Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); 178 Folder folder("sink.dummy.instance1");
178 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 179 Sink::Store::create<Folder>(folder).exec().waitForFinished();
179 } 180 }
180 181
181 // Test 182 // Test
@@ -184,9 +185,9 @@ private slots:
184 query.liveQuery = true; 185 query.liveQuery = true;
185 186
186 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data 187 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
187 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 188 auto model = Sink::Store::loadModel<Folder>(query);
188 QTRY_COMPARE(model->rowCount(), 1); 189 QTRY_COMPARE(model->rowCount(), 1);
189 auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); 190 auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>();
190 QVERIFY(!folderEntity->identifier().isEmpty()); 191 QVERIFY(!folderEntity->identifier().isEmpty());
191 } 192 }
192 193
@@ -194,8 +195,8 @@ private slots:
194 { 195 {
195 // Setup 196 // Setup
196 { 197 {
197 Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); 198 Folder folder("sink.dummy.instance1");
198 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 199 Sink::Store::create<Folder>(folder).exec().waitForFinished();
199 200
200 Sink::Query query; 201 Sink::Query query;
201 query.resources << "sink.dummy.instance1"; 202 query.resources << "sink.dummy.instance1";
@@ -203,16 +204,16 @@ private slots:
203 // Ensure all local data is processed 204 // Ensure all local data is processed
204 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 205 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
205 206
206 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 207 auto model = Sink::Store::loadModel<Folder>(query);
207 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 208 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
208 QCOMPARE(model->rowCount(), 1); 209 QCOMPARE(model->rowCount(), 1);
209 210
210 auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); 211 auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>();
211 QVERIFY(!folderEntity->identifier().isEmpty()); 212 QVERIFY(!folderEntity->identifier().isEmpty());
212 213
213 Sink::ApplicationDomain::Folder subfolder("sink.dummy.instance1"); 214 Folder subfolder("sink.dummy.instance1");
214 subfolder.setProperty("parent", folderEntity->identifier()); 215 subfolder.setProperty("parent", folderEntity->identifier());
215 Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); 216 Sink::Store::create<Folder>(subfolder).exec().waitForFinished();
216 } 217 }
217 218
218 // Test 219 // Test
@@ -224,7 +225,7 @@ private slots:
224 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 225 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
225 226
226 // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data 227 // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data
227 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 228 auto model = Sink::Store::loadModel<Folder>(query);
228 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 229 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
229 QCOMPARE(model->rowCount(), 1); 230 QCOMPARE(model->rowCount(), 1);
230 model->fetchMore(model->index(0, 0)); 231 model->fetchMore(model->index(0, 0));
@@ -236,30 +237,30 @@ private slots:
236 { 237 {
237 // Setup 238 // Setup
238 { 239 {
239 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 240 Mail mail("sink.dummy.instance1");
240 mail.setProperty("uid", "test1"); 241 mail.setProperty("uid", "test1");
241 mail.setProperty("sender", "doe@example.org"); 242 mail.setProperty("sender", "doe@example.org");
242 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 243 Sink::Store::create<Mail>(mail).exec().waitForFinished();
243 } 244 }
244 245
245 { 246 {
246 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 247 Mail mail("sink.dummy.instance1");
247 mail.setProperty("uid", "test2"); 248 mail.setProperty("uid", "test2");
248 mail.setProperty("sender", "doe@example.org"); 249 mail.setProperty("sender", "doe@example.org");
249 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 250 Sink::Store::create<Mail>(mail).exec().waitForFinished();
250 } 251 }
251 252
252 // Test 253 // Test
253 Sink::Query query; 254 Sink::Query query;
254 query.resources << "sink.dummy.instance1"; 255 query.resources << "sink.dummy.instance1";
255 query.liveQuery = false; 256 query.liveQuery = false;
256 query += Sink::Query::PropertyFilter("uid", "test1"); 257 query.filter<Mail::Uid>("test1");
257 258
258 // Ensure all local data is processed 259 // Ensure all local data is processed
259 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 260 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
260 261
261 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data 262 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
262 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 263 auto model = Sink::Store::loadModel<Mail>(query);
263 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 264 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
264 QCOMPARE(model->rowCount(), 1); 265 QCOMPARE(model->rowCount(), 1);
265 } 266 }
@@ -267,10 +268,10 @@ private slots:
267 void testMailByFolder() 268 void testMailByFolder()
268 { 269 {
269 // Setup 270 // Setup
270 Sink::ApplicationDomain::Folder::Ptr folderEntity; 271 Folder::Ptr folderEntity;
271 { 272 {
272 Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); 273 Folder folder("sink.dummy.instance1");
273 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 274 Sink::Store::create<Folder>(folder).exec().waitForFinished();
274 275
275 Sink::Query query; 276 Sink::Query query;
276 query.resources << "sink.dummy.instance1"; 277 query.resources << "sink.dummy.instance1";
@@ -278,29 +279,29 @@ private slots:
278 // Ensure all local data is processed 279 // Ensure all local data is processed
279 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 280 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
280 281
281 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 282 auto model = Sink::Store::loadModel<Folder>(query);
282 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 283 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
283 QCOMPARE(model->rowCount(), 1); 284 QCOMPARE(model->rowCount(), 1);
284 285
285 folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); 286 folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>();
286 QVERIFY(!folderEntity->identifier().isEmpty()); 287 QVERIFY(!folderEntity->identifier().isEmpty());
287 288
288 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 289 Mail mail("sink.dummy.instance1");
289 mail.setProperty("uid", "test1"); 290 mail.setProperty("uid", "test1");
290 mail.setProperty("folder", folderEntity->identifier()); 291 mail.setProperty("folder", folderEntity->identifier());
291 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 292 Sink::Store::create<Mail>(mail).exec().waitForFinished();
292 } 293 }
293 294
294 // Test 295 // Test
295 Sink::Query query; 296 Sink::Query query;
296 query.resources << "sink.dummy.instance1"; 297 query.resources << "sink.dummy.instance1";
297 query += Sink::Query::PropertyFilter("folder", *folderEntity); 298 query.filter<Mail::Folder>(*folderEntity);
298 299
299 // Ensure all local data is processed 300 // Ensure all local data is processed
300 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 301 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
301 302
302 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data 303 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
303 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 304 auto model = Sink::Store::loadModel<Mail>(query);
304 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 305 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
305 QCOMPARE(model->rowCount(), 1); 306 QCOMPARE(model->rowCount(), 1);
306 } 307 }
@@ -363,10 +364,10 @@ private slots:
363 void testMailByFolderSortedByDate() 364 void testMailByFolderSortedByDate()
364 { 365 {
365 // Setup 366 // Setup
366 Sink::ApplicationDomain::Folder::Ptr folderEntity; 367 Folder::Ptr folderEntity;
367 { 368 {
368 Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); 369 Folder folder("sink.dummy.instance1");
369 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 370 Sink::Store::create<Folder>(folder).exec().waitForFinished();
370 371
371 Sink::Query query; 372 Sink::Query query;
372 query.resources << "sink.dummy.instance1"; 373 query.resources << "sink.dummy.instance1";
@@ -374,71 +375,71 @@ private slots:
374 // Ensure all local data is processed 375 // Ensure all local data is processed
375 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 376 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
376 377
377 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 378 auto model = Sink::Store::loadModel<Folder>(query);
378 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 379 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
379 QCOMPARE(model->rowCount(), 1); 380 QCOMPARE(model->rowCount(), 1);
380 381
381 folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); 382 folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>();
382 QVERIFY(!folderEntity->identifier().isEmpty()); 383 QVERIFY(!folderEntity->identifier().isEmpty());
383 384
384 const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); 385 const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0));
385 { 386 {
386 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 387 Mail mail("sink.dummy.instance1");
387 mail.setProperty("uid", "testSecond"); 388 mail.setProperty("uid", "testSecond");
388 mail.setProperty("folder", folderEntity->identifier()); 389 mail.setProperty("folder", folderEntity->identifier());
389 mail.setProperty("date", date.addDays(-1)); 390 mail.setProperty("date", date.addDays(-1));
390 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 391 Sink::Store::create<Mail>(mail).exec().waitForFinished();
391 } 392 }
392 { 393 {
393 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 394 Mail mail("sink.dummy.instance1");
394 mail.setProperty("uid", "testLatest"); 395 mail.setProperty("uid", "testLatest");
395 mail.setProperty("folder", folderEntity->identifier()); 396 mail.setProperty("folder", folderEntity->identifier());
396 mail.setProperty("date", date); 397 mail.setProperty("date", date);
397 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 398 Sink::Store::create<Mail>(mail).exec().waitForFinished();
398 } 399 }
399 { 400 {
400 Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); 401 Mail mail("sink.dummy.instance1");
401 mail.setProperty("uid", "testLast"); 402 mail.setProperty("uid", "testLast");
402 mail.setProperty("folder", folderEntity->identifier()); 403 mail.setProperty("folder", folderEntity->identifier());
403 mail.setProperty("date", date.addDays(-2)); 404 mail.setProperty("date", date.addDays(-2));
404 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 405 Sink::Store::create<Mail>(mail).exec().waitForFinished();
405 } 406 }
406 } 407 }
407 408
408 // Test 409 // Test
409 Sink::Query query; 410 Sink::Query query;
410 query.resources << "sink.dummy.instance1"; 411 query.resources << "sink.dummy.instance1";
411 query += Sink::Query::PropertyFilter("folder", *folderEntity); 412 query.filter<Mail::Folder>(*folderEntity);
412 query.sortProperty = "date"; 413 query.sort<Mail::Date>();
413 query.limit = 1; 414 query.limit = 1;
414 query.liveQuery = false; 415 query.liveQuery = false;
415 416
416 // Ensure all local data is processed 417 // Ensure all local data is processed
417 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 418 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
418 419
419 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 420 auto model = Sink::Store::loadModel<Mail>(query);
420 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 421 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
421 // The model is not sorted, but the limited set is sorted, so we can only test for the latest result. 422 // The model is not sorted, but the limited set is sorted, so we can only test for the latest result.
422 QCOMPARE(model->rowCount(), 1); 423 QCOMPARE(model->rowCount(), 1);
423 QCOMPARE(model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testLatest")); 424 QCOMPARE(model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testLatest"));
424 425
425 model->fetchMore(QModelIndex()); 426 model->fetchMore(QModelIndex());
426 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 427 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
427 QCOMPARE(model->rowCount(), 2); 428 QCOMPARE(model->rowCount(), 2);
428 // We can't make any assumptions about the order of the indexes 429 // We can't make any assumptions about the order of the indexes
429 // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testSecond")); 430 // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value<Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testSecond"));
430 } 431 }
431 432
432 void testReactToNewResource() 433 void testReactToNewResource()
433 { 434 {
434 Sink::Query query; 435 Sink::Query query;
435 query.liveQuery = true; 436 query.liveQuery = true;
436 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 437 auto model = Sink::Store::loadModel<Folder>(query);
437 QTRY_COMPARE(model->rowCount(QModelIndex()), 0); 438 QTRY_COMPARE(model->rowCount(QModelIndex()), 0);
438 439
439 auto res = Sink::ApplicationDomain::DummyResource::create(""); 440 auto res = DummyResource::create("");
440 VERIFYEXEC(Sink::Store::create(res)); 441 VERIFYEXEC(Sink::Store::create(res));
441 auto folder = Sink::ApplicationDomain::Folder::create(res.identifier()); 442 auto folder = Folder::create(res.identifier());
442 VERIFYEXEC(Sink::Store::create(folder)); 443 VERIFYEXEC(Sink::Store::create(folder));
443 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 444 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
444 445