summaryrefslogtreecommitdiffstats
path: root/tests/pipelinetest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pipelinetest.cpp')
-rw-r--r--tests/pipelinetest.cpp61
1 files changed, 30 insertions, 31 deletions
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp
index c6ee9ab..7216f62 100644
--- a/tests/pipelinetest.cpp
+++ b/tests/pipelinetest.cpp
@@ -190,13 +190,12 @@ class PipelineTest : public QObject
190private slots: 190private slots:
191 void initTestCase() 191 void initTestCase()
192 { 192 {
193 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
194 Sink::AdaptorFactoryRegistry::instance().registerFactory<Sink::ApplicationDomain::Event, TestEventAdaptorFactory>("test"); 193 Sink::AdaptorFactoryRegistry::instance().registerFactory<Sink::ApplicationDomain::Event, TestEventAdaptorFactory>("test");
195 } 194 }
196 195
197 void init() 196 void init()
198 { 197 {
199 removeFromDisk("org.kde.pipelinetest.instance1"); 198 removeFromDisk("sink.pipelinetest.instance1");
200 } 199 }
201 200
202 void testCreate() 201 void testCreate()
@@ -204,14 +203,14 @@ private slots:
204 flatbuffers::FlatBufferBuilder entityFbb; 203 flatbuffers::FlatBufferBuilder entityFbb;
205 auto command = createEntityCommand(createEvent(entityFbb)); 204 auto command = createEntityCommand(createEvent(entityFbb));
206 205
207 Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); 206 Sink::Pipeline pipeline("sink.pipelinetest.instance1");
208 pipeline.setResourceType("test"); 207 pipeline.setResourceType("test");
209 208
210 pipeline.startTransaction(); 209 pipeline.startTransaction();
211 pipeline.newEntity(command.constData(), command.size()); 210 pipeline.newEntity(command.constData(), command.size());
212 pipeline.commit(); 211 pipeline.commit();
213 212
214 auto result = getKeys("org.kde.pipelinetest.instance1", "event.main"); 213 auto result = getKeys("sink.pipelinetest.instance1", "event.main");
215 qDebug() << result; 214 qDebug() << result;
216 QCOMPARE(result.size(), 1); 215 QCOMPARE(result.size(), 1);
217 } 216 }
@@ -221,7 +220,7 @@ private slots:
221 flatbuffers::FlatBufferBuilder entityFbb; 220 flatbuffers::FlatBufferBuilder entityFbb;
222 auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); 221 auto command = createEntityCommand(createEvent(entityFbb, "summary", "description"));
223 222
224 Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); 223 Sink::Pipeline pipeline("sink.pipelinetest.instance1");
225 pipeline.setResourceType("test"); 224 pipeline.setResourceType("test");
226 225
227 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); 226 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create();
@@ -232,7 +231,7 @@ private slots:
232 pipeline.commit(); 231 pipeline.commit();
233 232
234 // Get uid of written entity 233 // Get uid of written entity
235 auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); 234 auto keys = getKeys("sink.pipelinetest.instance1", "event.main");
236 QCOMPARE(keys.size(), 1); 235 QCOMPARE(keys.size(), 1);
237 const auto key = keys.first(); 236 const auto key = keys.first();
238 const auto uid = Sink::Storage::uidFromKey(key); 237 const auto uid = Sink::Storage::uidFromKey(key);
@@ -245,7 +244,7 @@ private slots:
245 pipeline.commit(); 244 pipeline.commit();
246 245
247 // Ensure we've got the new revision with the modification 246 // Ensure we've got the new revision with the modification
248 auto buffer = getEntity("org.kde.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 2)); 247 auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 2));
249 QVERIFY(!buffer.isEmpty()); 248 QVERIFY(!buffer.isEmpty());
250 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 249 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
251 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 250 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity());
@@ -254,7 +253,7 @@ private slots:
254 QVERIFY2(adaptor->getProperty("description").toString() == QString("description"), "The modification has sideeffects."); 253 QVERIFY2(adaptor->getProperty("description").toString() == QString("description"), "The modification has sideeffects.");
255 254
256 // Both revisions are in the store at this point 255 // Both revisions are in the store at this point
257 QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 2); 256 QCOMPARE(getKeys("sink.pipelinetest.instance1", "event.main").size(), 2);
258 257
259 // Cleanup old revisions 258 // Cleanup old revisions
260 pipeline.startTransaction(); 259 pipeline.startTransaction();
@@ -262,7 +261,7 @@ private slots:
262 pipeline.commit(); 261 pipeline.commit();
263 262
264 // And now only the latest revision is left 263 // And now only the latest revision is left
265 QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 1); 264 QCOMPARE(getKeys("sink.pipelinetest.instance1", "event.main").size(), 1);
266 } 265 }
267 266
268 void testModifyWithUnrelatedOperationInbetween() 267 void testModifyWithUnrelatedOperationInbetween()
@@ -270,7 +269,7 @@ private slots:
270 flatbuffers::FlatBufferBuilder entityFbb; 269 flatbuffers::FlatBufferBuilder entityFbb;
271 auto command = createEntityCommand(createEvent(entityFbb)); 270 auto command = createEntityCommand(createEvent(entityFbb));
272 271
273 Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); 272 Sink::Pipeline pipeline("sink.pipelinetest.instance1");
274 pipeline.setResourceType("test"); 273 pipeline.setResourceType("test");
275 274
276 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); 275 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create();
@@ -281,7 +280,7 @@ private slots:
281 pipeline.commit(); 280 pipeline.commit();
282 281
283 // Get uid of written entity 282 // Get uid of written entity
284 auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); 283 auto keys = getKeys("sink.pipelinetest.instance1", "event.main");
285 QCOMPARE(keys.size(), 1); 284 QCOMPARE(keys.size(), 1);
286 const auto uid = Sink::Storage::uidFromKey(keys.first()); 285 const auto uid = Sink::Storage::uidFromKey(keys.first());
287 286
@@ -303,7 +302,7 @@ private slots:
303 pipeline.commit(); 302 pipeline.commit();
304 303
305 // Ensure we've got the new revision with the modification 304 // Ensure we've got the new revision with the modification
306 auto buffer = getEntity("org.kde.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 3)); 305 auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 3));
307 QVERIFY(!buffer.isEmpty()); 306 QVERIFY(!buffer.isEmpty());
308 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 307 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
309 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 308 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity());
@@ -314,7 +313,7 @@ private slots:
314 { 313 {
315 flatbuffers::FlatBufferBuilder entityFbb; 314 flatbuffers::FlatBufferBuilder entityFbb;
316 auto command = createEntityCommand(createEvent(entityFbb)); 315 auto command = createEntityCommand(createEvent(entityFbb));
317 Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); 316 Sink::Pipeline pipeline("sink.pipelinetest.instance1");
318 pipeline.setResourceType("test"); 317 pipeline.setResourceType("test");
319 318
320 // Create the initial revision 319 // Create the initial revision
@@ -322,7 +321,7 @@ private slots:
322 pipeline.newEntity(command.constData(), command.size()); 321 pipeline.newEntity(command.constData(), command.size());
323 pipeline.commit(); 322 pipeline.commit();
324 323
325 auto result = getKeys("org.kde.pipelinetest.instance1", "event.main"); 324 auto result = getKeys("sink.pipelinetest.instance1", "event.main");
326 QCOMPARE(result.size(), 1); 325 QCOMPARE(result.size(), 1);
327 326
328 const auto uid = Sink::Storage::uidFromKey(result.first()); 327 const auto uid = Sink::Storage::uidFromKey(result.first());
@@ -334,7 +333,7 @@ private slots:
334 pipeline.commit(); 333 pipeline.commit();
335 334
336 // We have a new revision that indicates the deletion 335 // We have a new revision that indicates the deletion
337 QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 2); 336 QCOMPARE(getKeys("sink.pipelinetest.instance1", "event.main").size(), 2);
338 337
339 // Cleanup old revisions 338 // Cleanup old revisions
340 pipeline.startTransaction(); 339 pipeline.startTransaction();
@@ -342,18 +341,18 @@ private slots:
342 pipeline.commit(); 341 pipeline.commit();
343 342
344 // And all revisions are gone 343 // And all revisions are gone
345 QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 0); 344 QCOMPARE(getKeys("sink.pipelinetest.instance1", "event.main").size(), 0);
346 } 345 }
347 346
348 void testPreprocessor() 347 void testPreprocessor()
349 { 348 {
350 flatbuffers::FlatBufferBuilder entityFbb; 349 flatbuffers::FlatBufferBuilder entityFbb;
351 350
352 TestProcessor testProcessor; 351 auto testProcessor = new TestProcessor;
353 352
354 Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); 353 Sink::Pipeline pipeline("sink.pipelinetest.instance1");
355 pipeline.setResourceType("test"); 354 pipeline.setResourceType("test");
356 pipeline.setPreprocessors("event", QVector<Sink::Preprocessor *>() << &testProcessor); 355 pipeline.setPreprocessors("event", QVector<Sink::Preprocessor *>() << testProcessor);
357 pipeline.startTransaction(); 356 pipeline.startTransaction();
358 // pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); 357 // pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create());
359 358
@@ -361,24 +360,24 @@ private slots:
361 { 360 {
362 auto command = createEntityCommand(createEvent(entityFbb)); 361 auto command = createEntityCommand(createEvent(entityFbb));
363 pipeline.newEntity(command.constData(), command.size()); 362 pipeline.newEntity(command.constData(), command.size());
364 QCOMPARE(testProcessor.newUids.size(), 1); 363 QCOMPARE(testProcessor->newUids.size(), 1);
365 QCOMPARE(testProcessor.newRevisions.size(), 1); 364 QCOMPARE(testProcessor->newRevisions.size(), 1);
366 // Key doesn't contain revision and is just the uid 365 // Key doesn't contain revision and is just the uid
367 QCOMPARE(testProcessor.newUids.at(0), Sink::Storage::uidFromKey(testProcessor.newUids.at(0))); 366 QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::uidFromKey(testProcessor->newUids.at(0)));
368 } 367 }
369 pipeline.commit(); 368 pipeline.commit();
370 entityFbb.Clear(); 369 entityFbb.Clear();
371 pipeline.startTransaction(); 370 pipeline.startTransaction();
372 auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); 371 auto keys = getKeys("sink.pipelinetest.instance1", "event.main");
373 QCOMPARE(keys.size(), 1); 372 QCOMPARE(keys.size(), 1);
374 const auto uid = Sink::Storage::uidFromKey(keys.first()); 373 const auto uid = Sink::Storage::uidFromKey(keys.first());
375 { 374 {
376 auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); 375 auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1);
377 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); 376 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size());
378 QCOMPARE(testProcessor.modifiedUids.size(), 1); 377 QCOMPARE(testProcessor->modifiedUids.size(), 1);
379 QCOMPARE(testProcessor.modifiedRevisions.size(), 1); 378 QCOMPARE(testProcessor->modifiedRevisions.size(), 1);
380 // Key doesn't contain revision and is just the uid 379 // Key doesn't contain revision and is just the uid
381 QCOMPARE(testProcessor.modifiedUids.at(0), Sink::Storage::uidFromKey(testProcessor.modifiedUids.at(0))); 380 QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::uidFromKey(testProcessor->modifiedUids.at(0)));
382 } 381 }
383 pipeline.commit(); 382 pipeline.commit();
384 entityFbb.Clear(); 383 entityFbb.Clear();
@@ -386,12 +385,12 @@ private slots:
386 { 385 {
387 auto deleteCommand = deleteEntityCommand(uid, 1); 386 auto deleteCommand = deleteEntityCommand(uid, 1);
388 pipeline.deletedEntity(deleteCommand.constData(), deleteCommand.size()); 387 pipeline.deletedEntity(deleteCommand.constData(), deleteCommand.size());
389 QCOMPARE(testProcessor.deletedUids.size(), 1); 388 QCOMPARE(testProcessor->deletedUids.size(), 1);
390 QCOMPARE(testProcessor.deletedUids.size(), 1); 389 QCOMPARE(testProcessor->deletedUids.size(), 1);
391 QCOMPARE(testProcessor.deletedSummaries.size(), 1); 390 QCOMPARE(testProcessor->deletedSummaries.size(), 1);
392 // Key doesn't contain revision and is just the uid 391 // Key doesn't contain revision and is just the uid
393 QCOMPARE(testProcessor.deletedUids.at(0), Sink::Storage::uidFromKey(testProcessor.deletedUids.at(0))); 392 QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::uidFromKey(testProcessor->deletedUids.at(0)));
394 QCOMPARE(testProcessor.deletedSummaries.at(0), QByteArray("summary2")); 393 QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2"));
395 } 394 }
396 } 395 }
397}; 396};