From 922e0979e2c27ff8dbc765ae151d17c7815b98a0 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 26 Jun 2018 11:44:11 +0200 Subject: [Storage] Implement Key API --- tests/pipelinetest.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'tests/pipelinetest.cpp') diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 45e2fbb..7431deb 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp @@ -250,8 +250,9 @@ private slots: // Get uid of written entity auto keys = getKeys(instanceIdentifier(), "event.main"); QCOMPARE(keys.size(), 1); - const auto key = keys.first(); - const auto uid = Sink::Storage::DataStore::uidFromKey(key); + auto key = Sink::Storage::Key::fromInternalByteArray(keys.first()); + //const auto uid = Sink::Storage::DataStore::uidFromKey(key); + const auto uid = key.identifier().toDisplayByteArray(); // Execute the modification entityFbb.Clear(); @@ -260,8 +261,10 @@ private slots: pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); pipeline.commit(); + key.setRevision(2); + // Ensure we've got the new revision with the modification - auto buffer = getEntity(instanceIdentifier(), "event.main", Sink::Storage::DataStore::assembleKey(uid, 2)); + auto buffer = getEntity(instanceIdentifier(), "event.main", key.toInternalByteArray()); QVERIFY(!buffer.isEmpty()); Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); @@ -296,7 +299,8 @@ private slots: // Get uid of written entity auto keys = getKeys(instanceIdentifier(), "event.main"); QCOMPARE(keys.size(), 1); - const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first()); + auto key = Sink::Storage::Key::fromInternalByteArray(keys.first()); + const auto uid = key.identifier().toDisplayByteArray(); // Create another operation inbetween @@ -315,8 +319,10 @@ private slots: pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); pipeline.commit(); + key.setRevision(3); + // Ensure we've got the new revision with the modification - auto buffer = getEntity(instanceIdentifier(), "event.main", Sink::Storage::DataStore::assembleKey(uid, 3)); + auto buffer = getEntity(instanceIdentifier(), "event.main", key.toInternalByteArray()); QVERIFY(!buffer.isEmpty()); Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); @@ -337,7 +343,7 @@ private slots: auto result = getKeys(instanceIdentifier(), "event.main"); QCOMPARE(result.size(), 1); - const auto uid = Sink::Storage::DataStore::uidFromKey(result.first()); + const auto uid = Sink::Storage::Key::fromInternalByteArray(result.first()).identifier().toDisplayByteArray(); // Delete entity auto deleteCommand = deleteEntityCommand(uid, 1); @@ -373,21 +379,23 @@ private slots: QCOMPARE(testProcessor->newUids.size(), 1); QCOMPARE(testProcessor->newRevisions.size(), 1); // Key doesn't contain revision and is just the uid - QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->newUids.at(0))); + const auto uid = Sink::Storage::Key::fromDisplayByteArray(testProcessor->newUids.at(0)).identifier().toDisplayByteArray(); + QCOMPARE(testProcessor->newUids.at(0), uid); } pipeline.commit(); entityFbb.Clear(); pipeline.startTransaction(); auto keys = getKeys(instanceIdentifier(), "event.main"); QCOMPARE(keys.size(), 1); - const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first()); + const auto uid = Sink::Storage::Key::fromDisplayByteArray(keys.first()).identifier().toDisplayByteArray(); { auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); QCOMPARE(testProcessor->modifiedUids.size(), 1); QCOMPARE(testProcessor->modifiedRevisions.size(), 1); // Key doesn't contain revision and is just the uid - QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->modifiedUids.at(0))); + const auto uid2 = Sink::Storage::Key::fromDisplayByteArray(testProcessor->modifiedUids.at(0)).identifier().toDisplayByteArray(); + QCOMPARE(testProcessor->modifiedUids.at(0), uid2); } pipeline.commit(); entityFbb.Clear(); @@ -399,7 +407,8 @@ private slots: QCOMPARE(testProcessor->deletedUids.size(), 1); QCOMPARE(testProcessor->deletedSummaries.size(), 1); // Key doesn't contain revision and is just the uid - QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->deletedUids.at(0))); + const auto uid2 = Sink::Storage::Key::fromDisplayByteArray(testProcessor->modifiedUids.at(0)).identifier().toDisplayByteArray(); + QCOMPARE(testProcessor->deletedUids.at(0), uid2); QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2")); } } -- cgit v1.2.3