diff options
-rw-r--r-- | common/pipeline.cpp | 8 | ||||
-rw-r--r-- | tests/interresourcemovetest.cpp | 32 |
2 files changed, 26 insertions, 14 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index f29c7db..0cdedee 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -295,9 +295,11 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
295 | 295 | ||
296 | //The entity is either being copied or moved | 296 | //The entity is either being copied or moved |
297 | if (newEntity.resourceInstanceIdentifier() != d->resourceContext.resourceInstanceIdentifier) { | 297 | if (newEntity.resourceInstanceIdentifier() != d->resourceContext.resourceInstanceIdentifier) { |
298 | SinkTraceCtx(d->logCtx) << "Moving entity to new resource " << newEntity.identifier() << newEntity.resourceInstanceIdentifier(); | 298 | auto copy = *ApplicationDomain::ApplicationDomainType::getInMemoryCopy<ApplicationDomain::ApplicationDomainType>(newEntity, newEntity.availableProperties()); |
299 | newEntity.setChangedProperties(newEntity.availableProperties().toSet()); | 299 | copy.setResource(newEntity.resourceInstanceIdentifier()); |
300 | return create(bufferType, newEntity) | 300 | copy.setChangedProperties(copy.availableProperties().toSet()); |
301 | SinkTraceCtx(d->logCtx) << "Moving entity to new resource " << copy.identifier() << copy.resourceInstanceIdentifier(); | ||
302 | return create(bufferType, copy) | ||
301 | .then([=](const KAsync::Error &error) { | 303 | .then([=](const KAsync::Error &error) { |
302 | if (!error) { | 304 | if (!error) { |
303 | SinkTraceCtx(d->logCtx) << "Move of " << current.identifier() << "was successfull"; | 305 | SinkTraceCtx(d->logCtx) << "Move of " << current.identifier() << "was successfull"; |
diff --git a/tests/interresourcemovetest.cpp b/tests/interresourcemovetest.cpp index 5438bc7..174befc 100644 --- a/tests/interresourcemovetest.cpp +++ b/tests/interresourcemovetest.cpp | |||
@@ -121,24 +121,26 @@ private slots: | |||
121 | 121 | ||
122 | void testCopy() | 122 | void testCopy() |
123 | { | 123 | { |
124 | Event event("instance1"); | 124 | QByteArray testuid = "testuid@test.test"; |
125 | event.setProperty("uid", "testuid"); | 125 | QString subject = "summaryValue"; |
126 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 126 | auto mimeMessage = message(testuid, subject); |
127 | event.setProperty("summary", "summaryValue"); | 127 | |
128 | VERIFYEXEC(Sink::Store::create<Event>(event)); | 128 | Mail mail("instance1"); |
129 | mail.setMimeMessage(mimeMessage); | ||
130 | VERIFYEXEC(Sink::Store::create<Mail>(mail)); | ||
129 | 131 | ||
130 | 132 | ||
131 | Event createdEvent; | 133 | Mail createdMail; |
132 | // Ensure all local data is processed | 134 | // Ensure all local data is processed |
133 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "instance1")); | 135 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "instance1")); |
134 | { | 136 | { |
135 | auto query = Query().resourceFilter("instance1") ; | 137 | auto query = Query().resourceFilter("instance1") ; |
136 | auto list = Sink::Store::read<Event>(query.filter<Event::Uid>("testuid")); | 138 | auto list = Sink::Store::read<Mail>(query.filter<Mail::MessageId>(testuid)); |
137 | QCOMPARE(list.size(), 1); | 139 | QCOMPARE(list.size(), 1); |
138 | createdEvent = list.first(); | 140 | createdMail = list.first(); |
139 | } | 141 | } |
140 | 142 | ||
141 | VERIFYEXEC(Sink::Store::copy<Event>(createdEvent, "instance2")); | 143 | VERIFYEXEC(Sink::Store::copy<Mail>(createdMail, "instance2")); |
142 | 144 | ||
143 | //FIXME we can't guarantee that that the create command arrives at instance2 before the flush command, so we'll just wait for a little bit. | 145 | //FIXME we can't guarantee that that the create command arrives at instance2 before the flush command, so we'll just wait for a little bit. |
144 | QTest::qWait(100); | 146 | QTest::qWait(100); |
@@ -148,15 +150,23 @@ private slots: | |||
148 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "instance2")); | 150 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "instance2")); |
149 | { | 151 | { |
150 | auto query = Query().resourceFilter("instance2") ; | 152 | auto query = Query().resourceFilter("instance2") ; |
151 | auto list = Sink::Store::read<Event>(query.filter<Event::Uid>("testuid")); | 153 | auto list = Sink::Store::read<Mail>(query.filter<Mail::MessageId>(testuid)); |
152 | QCOMPARE(list.size(), 1); | 154 | QCOMPARE(list.size(), 1); |
155 | const auto mail = list.first(); | ||
156 | QVERIFY(!mail.getMimeMessagePath().isEmpty()); | ||
157 | QCOMPARE(mail.getSubject(), subject); | ||
158 | QCOMPARE(mail.getMimeMessage(), mimeMessage); | ||
153 | } | 159 | } |
154 | 160 | ||
155 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "instance1")); | 161 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "instance1")); |
156 | { | 162 | { |
157 | auto query = Query().resourceFilter("instance1") ; | 163 | auto query = Query().resourceFilter("instance1") ; |
158 | auto list = Sink::Store::read<Event>(query.filter<Event::Uid>("testuid")); | 164 | auto list = Sink::Store::read<Mail>(query.filter<Mail::MessageId>(testuid)); |
159 | QCOMPARE(list.size(), 1); | 165 | QCOMPARE(list.size(), 1); |
166 | const auto mail = list.first(); | ||
167 | QVERIFY(!mail.getMimeMessagePath().isEmpty()); | ||
168 | QCOMPARE(mail.getSubject(), subject); | ||
169 | QCOMPARE(mail.getMimeMessage(), mimeMessage); | ||
160 | } | 170 | } |
161 | } | 171 | } |
162 | 172 | ||