diff options
-rw-r--r-- | common/datastorequery.cpp | 8 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 1 | ||||
-rw-r--r-- | common/query.h | 135 | ||||
-rw-r--r-- | common/store.cpp | 24 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 3 | ||||
-rw-r--r-- | examples/client/CMakeLists.txt | 8 | ||||
-rw-r--r-- | examples/client/console.cpp | 76 | ||||
-rw-r--r-- | examples/client/console.h | 42 | ||||
-rw-r--r-- | examples/client/main.cpp | 222 | ||||
-rw-r--r-- | examples/imapresource/tests/imapmailsyncbenchmark.cpp | 6 | ||||
-rw-r--r-- | examples/mailtransportresource/tests/mailtransporttest.cpp | 4 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_count.cpp | 2 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_list.cpp | 3 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_show.cpp | 2 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_sync.cpp | 2 | ||||
-rw-r--r-- | tests/accountstest.cpp | 2 | ||||
-rw-r--r-- | tests/clientapitest.cpp | 14 | ||||
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 8 | ||||
-rw-r--r-- | tests/dummyresourcetest.cpp | 31 | ||||
-rw-r--r-- | tests/mailsynctest.cpp | 68 | ||||
-rw-r--r-- | tests/mailtest.cpp | 20 | ||||
-rw-r--r-- | tests/mailthreadtest.cpp | 6 | ||||
-rw-r--r-- | tests/modelinteractivitytest.cpp | 5 | ||||
-rw-r--r-- | tests/querytest.cpp | 62 |
24 files changed, 176 insertions, 578 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 0cc30e5..7341675 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp | |||
@@ -409,9 +409,6 @@ void DataStoreQuery::setupQuery() | |||
409 | { | 409 | { |
410 | auto baseFilters = mQuery.getBaseFilters(); | 410 | auto baseFilters = mQuery.getBaseFilters(); |
411 | for (const auto &k : baseFilters.keys()) { | 411 | for (const auto &k : baseFilters.keys()) { |
412 | if (k == ApplicationDomain::Entity::Resource::name) { | ||
413 | continue; | ||
414 | } | ||
415 | const auto comparator = baseFilters.value(k); | 412 | const auto comparator = baseFilters.value(k); |
416 | if (comparator.value.canConvert<Query>()) { | 413 | if (comparator.value.canConvert<Query>()) { |
417 | SinkTrace() << "Executing subquery for property: " << k; | 414 | SinkTrace() << "Executing subquery for property: " << k; |
@@ -446,9 +443,6 @@ void DataStoreQuery::setupQuery() | |||
446 | auto filter = Filter::Ptr::create(baseSet, this); | 443 | auto filter = Filter::Ptr::create(baseSet, this); |
447 | //For incremental queries the remaining filters are not sufficient | 444 | //For incremental queries the remaining filters are not sufficient |
448 | for (const auto &f : mQuery.getBaseFilters().keys()) { | 445 | for (const auto &f : mQuery.getBaseFilters().keys()) { |
449 | if (f == ApplicationDomain::Entity::Resource::name) { | ||
450 | continue; | ||
451 | } | ||
452 | filter->propertyFilter.insert(f, mQuery.getFilter(f)); | 446 | filter->propertyFilter.insert(f, mQuery.getFilter(f)); |
453 | } | 447 | } |
454 | baseSet = filter; | 448 | baseSet = filter; |
@@ -459,7 +453,7 @@ void DataStoreQuery::setupQuery() | |||
459 | /* } */ | 453 | /* } */ |
460 | 454 | ||
461 | //Setup the rest of the filter stages on top of the base set | 455 | //Setup the rest of the filter stages on top of the base set |
462 | for (const auto &stage : mQuery.filterStages.mid(1)) { | 456 | for (const auto &stage : mQuery.getFilterStages()) { |
463 | if (auto filter = stage.dynamicCast<Query::Filter>()) { | 457 | if (auto filter = stage.dynamicCast<Query::Filter>()) { |
464 | auto f = Filter::Ptr::create(baseSet, this); | 458 | auto f = Filter::Ptr::create(baseSet, this); |
465 | f->propertyFilter = filter->propertyFilter; | 459 | f->propertyFilter = filter->propertyFilter; |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 1c8b45a..7332bfb 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -242,7 +242,6 @@ struct SINK_EXPORT Entity : public ApplicationDomainType { | |||
242 | typedef QSharedPointer<Entity> Ptr; | 242 | typedef QSharedPointer<Entity> Ptr; |
243 | using ApplicationDomainType::ApplicationDomainType; | 243 | using ApplicationDomainType::ApplicationDomainType; |
244 | virtual ~Entity(); | 244 | virtual ~Entity(); |
245 | SINK_REFERENCE_PROPERTY(SinkResource, Resource, resource); | ||
246 | }; | 245 | }; |
247 | 246 | ||
248 | struct SINK_EXPORT Event : public Entity { | 247 | struct SINK_EXPORT Event : public Entity { |
diff --git a/common/query.h b/common/query.h index 82b04f7..ae307a2 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -59,46 +59,6 @@ public: | |||
59 | Comparators comparator; | 59 | Comparators comparator; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static Query ResourceFilter(const QByteArray &identifier) | ||
63 | { | ||
64 | Query query; | ||
65 | query.resources.append(identifier); | ||
66 | return query; | ||
67 | } | ||
68 | |||
69 | static Query ResourceFilter(const QByteArrayList &identifier) | ||
70 | { | ||
71 | Query query; | ||
72 | query.resources = identifier; | ||
73 | return query; | ||
74 | } | ||
75 | |||
76 | static Query ResourceFilter(const ApplicationDomain::SinkResource &entity) | ||
77 | { | ||
78 | return ResourceFilter(entity.identifier()); | ||
79 | } | ||
80 | |||
81 | static Query IdentityFilter(const QByteArray &identifier) | ||
82 | { | ||
83 | Q_ASSERT(!identifier.isEmpty()); | ||
84 | Query query; | ||
85 | query.filter(identifier); | ||
86 | return query; | ||
87 | } | ||
88 | |||
89 | static Query IdentityFilter(const QByteArrayList &identifier) | ||
90 | { | ||
91 | Query query; | ||
92 | query.filter(identifier); | ||
93 | return query; | ||
94 | } | ||
95 | |||
96 | static Query IdentityFilter(const ApplicationDomain::Entity &entity) | ||
97 | { | ||
98 | auto query = IdentityFilter(entity.identifier()); | ||
99 | query.resources << entity.resourceInstanceIdentifier(); | ||
100 | return query; | ||
101 | } | ||
102 | 62 | ||
103 | template <typename T> | 63 | template <typename T> |
104 | Query &request() | 64 | Query &request() |
@@ -124,16 +84,13 @@ public: | |||
124 | Query(const ApplicationDomain::Entity &value) : limit(0), liveQuery(false), synchronousQuery(false) | 84 | Query(const ApplicationDomain::Entity &value) : limit(0), liveQuery(false), synchronousQuery(false) |
125 | { | 85 | { |
126 | filter(value.identifier()); | 86 | filter(value.identifier()); |
127 | filter(ApplicationDomain::SinkResource(value.resourceInstanceIdentifier())); | 87 | resourceFilter(value.resourceInstanceIdentifier()); |
128 | } | 88 | } |
129 | 89 | ||
130 | |||
131 | Query(Flags flags = Flags()) : limit(0), liveQuery(false), synchronousQuery(false) | 90 | Query(Flags flags = Flags()) : limit(0), liveQuery(false), synchronousQuery(false) |
132 | { | 91 | { |
133 | } | 92 | } |
134 | 93 | ||
135 | QByteArrayList resources; | ||
136 | QByteArrayList accounts; | ||
137 | QByteArrayList requestedProperties; | 94 | QByteArrayList requestedProperties; |
138 | QByteArray parentProperty; | 95 | QByteArray parentProperty; |
139 | QByteArray sortProperty; | 96 | QByteArray sortProperty; |
@@ -147,7 +104,10 @@ public: | |||
147 | virtual ~FilterStage(){}; | 104 | virtual ~FilterStage(){}; |
148 | }; | 105 | }; |
149 | 106 | ||
150 | QList<QSharedPointer<FilterStage>> filterStages; | 107 | QList<QSharedPointer<FilterStage>> getFilterStages() |
108 | { | ||
109 | return mFilterStages; | ||
110 | } | ||
151 | 111 | ||
152 | /* | 112 | /* |
153 | * Filters | 113 | * Filters |
@@ -178,69 +138,45 @@ public: | |||
178 | 138 | ||
179 | Query &filter(const QByteArray &id) | 139 | Query &filter(const QByteArray &id) |
180 | { | 140 | { |
181 | if (filterStages.isEmpty()) { | 141 | mBaseFilterStage.ids << id; |
182 | filterStages << QSharedPointer<Filter>::create(); | ||
183 | } | ||
184 | filterStages.first().staticCast<Filter>()->ids << id; | ||
185 | return *this; | 142 | return *this; |
186 | } | 143 | } |
187 | 144 | ||
188 | Query &filter(const QByteArrayList &ids) | 145 | Query &filter(const QByteArrayList &ids) |
189 | { | 146 | { |
190 | if (filterStages.isEmpty()) { | 147 | mBaseFilterStage.ids << ids; |
191 | filterStages << QSharedPointer<Filter>::create(); | ||
192 | } | ||
193 | filterStages.first().staticCast<Filter>()->ids << ids; | ||
194 | return *this; | 148 | return *this; |
195 | } | 149 | } |
196 | 150 | ||
197 | Query &filter(const QByteArray &property, const Comparator &comparator) | 151 | Query &filter(const QByteArray &property, const Comparator &comparator) |
198 | { | 152 | { |
199 | if (filterStages.isEmpty()) { | 153 | mBaseFilterStage.propertyFilter.insert(property, comparator); |
200 | filterStages << QSharedPointer<Filter>::create(); | ||
201 | } | ||
202 | filterStages.first().staticCast<Filter>()->propertyFilter.insert(property, comparator); | ||
203 | return *this; | 154 | return *this; |
204 | } | 155 | } |
205 | 156 | ||
206 | Comparator getFilter(const QByteArray &property) const | 157 | Comparator getFilter(const QByteArray &property) const |
207 | { | 158 | { |
208 | if (filterStages.isEmpty()) { | 159 | return mBaseFilterStage.propertyFilter.value(property); |
209 | return Comparator(); | ||
210 | } | ||
211 | return filterStages.first().staticCast<Filter>()->propertyFilter.value(property); | ||
212 | } | 160 | } |
213 | 161 | ||
214 | bool hasFilter(const QByteArray &property) const | 162 | bool hasFilter(const QByteArray &property) const |
215 | { | 163 | { |
216 | if (filterStages.isEmpty()) { | 164 | return mBaseFilterStage.propertyFilter.contains(property); |
217 | return false; | ||
218 | } | ||
219 | return filterStages.first().staticCast<Filter>()->propertyFilter.contains(property); | ||
220 | } | 165 | } |
221 | 166 | ||
222 | void setBaseFilters(const QHash<QByteArray, Comparator> &filter) | 167 | void setBaseFilters(const QHash<QByteArray, Comparator> &filter) |
223 | { | 168 | { |
224 | if (filterStages.isEmpty()) { | 169 | mBaseFilterStage.propertyFilter = filter; |
225 | filterStages << QSharedPointer<Filter>::create(); | ||
226 | } | ||
227 | filterStages.first().staticCast<Filter>()->propertyFilter = filter; | ||
228 | } | 170 | } |
229 | 171 | ||
230 | QHash<QByteArray, Comparator> getBaseFilters() const | 172 | QHash<QByteArray, Comparator> getBaseFilters() const |
231 | { | 173 | { |
232 | if (filterStages.isEmpty()) { | 174 | return mBaseFilterStage.propertyFilter; |
233 | return QHash<QByteArray, Comparator>(); | ||
234 | } | ||
235 | return filterStages.first().staticCast<Filter>()->propertyFilter; | ||
236 | } | 175 | } |
237 | 176 | ||
238 | QByteArrayList ids() const | 177 | QByteArrayList ids() const |
239 | { | 178 | { |
240 | if (filterStages.isEmpty()) { | 179 | return mBaseFilterStage.ids; |
241 | return QByteArrayList(); | ||
242 | } | ||
243 | return filterStages.first().staticCast<Filter>()->ids; | ||
244 | } | 180 | } |
245 | 181 | ||
246 | template <typename T> | 182 | template <typename T> |
@@ -257,18 +193,42 @@ public: | |||
257 | return filter(T::name, QVariant::fromValue(q)); | 193 | return filter(T::name, QVariant::fromValue(q)); |
258 | } | 194 | } |
259 | 195 | ||
260 | Query &filter(const ApplicationDomain::SinkResource &resource) | 196 | Filter getResourceFilter() const |
197 | { | ||
198 | return mResourceFilter; | ||
199 | } | ||
200 | |||
201 | Query &resourceFilter(const QByteArray &id) | ||
261 | { | 202 | { |
262 | resources << resource.identifier(); | 203 | mResourceFilter.ids << id; |
263 | return *this; | 204 | return *this; |
264 | } | 205 | } |
265 | 206 | ||
266 | Query &filter(const ApplicationDomain::SinkAccount &account) | 207 | template <typename T> |
208 | Query &resourceFilter(const ApplicationDomain::ApplicationDomainType &entity) | ||
267 | { | 209 | { |
268 | accounts << account.identifier(); | 210 | mResourceFilter.propertyFilter.insert(T::name, Comparator(entity.identifier())); |
269 | return *this; | 211 | return *this; |
270 | } | 212 | } |
271 | 213 | ||
214 | Query &resourceFilter(const QByteArray &name, const Comparator &comparator) | ||
215 | { | ||
216 | mResourceFilter.propertyFilter.insert(name, comparator); | ||
217 | return *this; | ||
218 | } | ||
219 | |||
220 | template <typename T> | ||
221 | Query &resourceContainsFilter(const QVariant &value) | ||
222 | { | ||
223 | return resourceFilter(T::name, Comparator(value, Comparator::Contains)); | ||
224 | } | ||
225 | |||
226 | template <typename T> | ||
227 | Query &resourceFilter(const QVariant &value) | ||
228 | { | ||
229 | return resourceFilter(T::name, value); | ||
230 | } | ||
231 | |||
272 | class Reduce : public FilterStage { | 232 | class Reduce : public FilterStage { |
273 | public: | 233 | public: |
274 | 234 | ||
@@ -318,7 +278,7 @@ public: | |||
318 | Reduce &reduce(const Reduce::Selector &s) | 278 | Reduce &reduce(const Reduce::Selector &s) |
319 | { | 279 | { |
320 | auto reduction = QSharedPointer<Reduce>::create(T::name, s); | 280 | auto reduction = QSharedPointer<Reduce>::create(T::name, s); |
321 | filterStages << reduction; | 281 | mFilterStages << reduction; |
322 | return *reduction; | 282 | return *reduction; |
323 | } | 283 | } |
324 | 284 | ||
@@ -345,7 +305,7 @@ public: | |||
345 | void bloom() | 305 | void bloom() |
346 | { | 306 | { |
347 | auto bloom = QSharedPointer<Bloom>::create(T::name); | 307 | auto bloom = QSharedPointer<Bloom>::create(T::name); |
348 | filterStages << bloom; | 308 | mFilterStages << bloom; |
349 | } | 309 | } |
350 | 310 | ||
351 | //Query fixtures | 311 | //Query fixtures |
@@ -357,7 +317,7 @@ public: | |||
357 | { | 317 | { |
358 | Sink::Query query; | 318 | Sink::Query query; |
359 | if (!mail.resourceInstanceIdentifier().isEmpty()) { | 319 | if (!mail.resourceInstanceIdentifier().isEmpty()) { |
360 | query.filter(ApplicationDomain::SinkResource(mail.resourceInstanceIdentifier())); | 320 | query.resourceFilter(mail.resourceInstanceIdentifier()); |
361 | } | 321 | } |
362 | query.filter(mail.identifier()); | 322 | query.filter(mail.identifier()); |
363 | query.sort<ApplicationDomain::Mail::Date>(); | 323 | query.sort<ApplicationDomain::Mail::Date>(); |
@@ -372,7 +332,7 @@ public: | |||
372 | { | 332 | { |
373 | Sink::Query query; | 333 | Sink::Query query; |
374 | if (!folder.resourceInstanceIdentifier().isEmpty()) { | 334 | if (!folder.resourceInstanceIdentifier().isEmpty()) { |
375 | query.filter(ApplicationDomain::SinkResource(folder.resourceInstanceIdentifier())); | 335 | query.resourceFilter(folder.resourceInstanceIdentifier()); |
376 | } | 336 | } |
377 | query.filter<ApplicationDomain::Mail::Folder>(folder); | 337 | query.filter<ApplicationDomain::Mail::Folder>(folder); |
378 | query.sort<ApplicationDomain::Mail::Date>(); | 338 | query.sort<ApplicationDomain::Mail::Date>(); |
@@ -380,7 +340,10 @@ public: | |||
380 | return query; | 340 | return query; |
381 | } | 341 | } |
382 | 342 | ||
383 | 343 | private: | |
344 | Filter mResourceFilter; | ||
345 | Filter mBaseFilterStage; | ||
346 | QList<QSharedPointer<FilterStage>> mFilterStages; | ||
384 | }; | 347 | }; |
385 | 348 | ||
386 | } | 349 | } |
diff --git a/common/store.cpp b/common/store.cpp index c015ef6..0ecdcd2 100644 --- a/common/store.cpp +++ b/common/store.cpp | |||
@@ -59,25 +59,15 @@ QString Store::getTemporaryFilePath() | |||
59 | */ | 59 | */ |
60 | static QMap<QByteArray, QByteArray> getResources(const Sink::Query &query, const QByteArray &type = QByteArray()) | 60 | static QMap<QByteArray, QByteArray> getResources(const Sink::Query &query, const QByteArray &type = QByteArray()) |
61 | { | 61 | { |
62 | const QList<QByteArray> resourceFilter = query.resources; | 62 | const QList<QByteArray> resourceFilter = query.getResourceFilter().ids; |
63 | const QList<QByteArray> accountFilter = query.accounts; | ||
64 | 63 | ||
65 | auto resourceComparator = query.getFilter(Sink::ApplicationDomain::Entity::Resource::name); | ||
66 | 64 | ||
67 | const auto filterResource = [&](const QByteArray &res) { | 65 | const auto filterResource = [&](const QByteArray &res) { |
68 | const auto configuration = ResourceConfig::getConfiguration(res); | 66 | const auto configuration = ResourceConfig::getConfiguration(res); |
69 | if (!accountFilter.isEmpty() && !accountFilter.contains(configuration.value(ApplicationDomain::SinkResource::Account::name).toByteArray())) { | 67 | for (const auto &filterProperty : query.getResourceFilter().propertyFilter.keys()) { |
70 | return true; | 68 | const auto filter = query.getResourceFilter().propertyFilter.value(filterProperty); |
71 | } | 69 | if (!filter.matches(configuration.value(filterProperty))) { |
72 | //Subquery for the resource | 70 | return true; |
73 | if (resourceComparator.value.canConvert<Query>()) { | ||
74 | const auto subquery = resourceComparator.value.value<Query>(); | ||
75 | const auto baseFilters = subquery.getBaseFilters(); | ||
76 | for (const auto &filterProperty : baseFilters.keys()) { | ||
77 | const auto filter = baseFilters.value(filterProperty); | ||
78 | if (!filter.matches(configuration.value(filterProperty))) { | ||
79 | return true; | ||
80 | } | ||
81 | } | 71 | } |
82 | } | 72 | } |
83 | return false; | 73 | return false; |
@@ -159,7 +149,7 @@ QSharedPointer<QAbstractItemModel> Store::loadModel(Query query) | |||
159 | auto aggregatingEmitter = AggregatingResultEmitter<typename DomainType::Ptr>::Ptr::create(); | 149 | auto aggregatingEmitter = AggregatingResultEmitter<typename DomainType::Ptr>::Ptr::create(); |
160 | model->setEmitter(aggregatingEmitter); | 150 | model->setEmitter(aggregatingEmitter); |
161 | 151 | ||
162 | if (query.liveQuery && query.resources.isEmpty() && !ApplicationDomain::isGlobalType(ApplicationDomain::getTypeName<DomainType>())) { | 152 | if (query.liveQuery && query.getResourceFilter().ids.isEmpty() && !ApplicationDomain::isGlobalType(ApplicationDomain::getTypeName<DomainType>())) { |
163 | SinkTrace() << "Listening for new resources"; | 153 | SinkTrace() << "Listening for new resources"; |
164 | auto facade = FacadeFactory::instance().getFacade<ApplicationDomain::SinkResource>("", ""); | 154 | auto facade = FacadeFactory::instance().getFacade<ApplicationDomain::SinkResource>("", ""); |
165 | Q_ASSERT(facade); | 155 | Q_ASSERT(facade); |
@@ -267,8 +257,8 @@ KAsync::Job<void> Store::removeDataFromDisk(const QByteArray &identifier) | |||
267 | 257 | ||
268 | KAsync::Job<void> Store::synchronize(const Sink::Query &query) | 258 | KAsync::Job<void> Store::synchronize(const Sink::Query &query) |
269 | { | 259 | { |
270 | SinkTrace() << "synchronize" << query.resources; | ||
271 | auto resources = getResources(query).keys(); | 260 | auto resources = getResources(query).keys(); |
261 | SinkTrace() << "synchronize" << resources; | ||
272 | //FIXME only necessary because each doesn't propagate errors | 262 | //FIXME only necessary because each doesn't propagate errors |
273 | auto errorFlag = new bool; | 263 | auto errorFlag = new bool; |
274 | return KAsync::value(resources) | 264 | return KAsync::value(resources) |
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d6f2d90..9d87b1c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt | |||
@@ -1,6 +1,3 @@ | |||
1 | # the client | ||
2 | add_subdirectory(client) | ||
3 | |||
4 | # a simple dummy resource implementation | 1 | # a simple dummy resource implementation |
5 | add_subdirectory(dummyresource) | 2 | add_subdirectory(dummyresource) |
6 | 3 | ||
diff --git a/examples/client/CMakeLists.txt b/examples/client/CMakeLists.txt deleted file mode 100644 index ef00368..0000000 --- a/examples/client/CMakeLists.txt +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | project(sink_client) | ||
2 | |||
3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
4 | |||
5 | add_executable(${PROJECT_NAME} main.cpp console.cpp) | ||
6 | target_link_libraries(${PROJECT_NAME} sink) | ||
7 | qt5_use_modules(${PROJECT_NAME} Widgets Network) | ||
8 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | ||
diff --git a/examples/client/console.cpp b/examples/client/console.cpp deleted file mode 100644 index 8b4f1a5..0000000 --- a/examples/client/console.cpp +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #include "console.h" | ||
22 | |||
23 | #include <QFontDatabase> | ||
24 | #include <QLabel> | ||
25 | #include <QTextBrowser> | ||
26 | #include <QVBoxLayout> | ||
27 | |||
28 | static Console *s_console = 0; | ||
29 | |||
30 | Console *Console::main() | ||
31 | { | ||
32 | if (!s_console) { | ||
33 | s_console = new Console(QString()); | ||
34 | } | ||
35 | return s_console; | ||
36 | } | ||
37 | |||
38 | Console::Console(const QString &title) | ||
39 | : QWidget(0) | ||
40 | { | ||
41 | if (!s_console) { | ||
42 | s_console = this; | ||
43 | } | ||
44 | |||
45 | resize(1000, 1500); | ||
46 | |||
47 | QVBoxLayout *topLayout = new QVBoxLayout(this); | ||
48 | |||
49 | QLabel *titleLabel = new QLabel(this); | ||
50 | titleLabel->setText(title); | ||
51 | QFont font = titleLabel->font(); | ||
52 | font.setWeight(QFont::Bold); | ||
53 | titleLabel->setFont(font); | ||
54 | titleLabel->setAlignment(Qt::AlignCenter); | ||
55 | |||
56 | QFont consoleFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); | ||
57 | consoleFont.setPointSize(7); | ||
58 | m_textDisplay = new QTextBrowser(this); | ||
59 | m_textDisplay->document()->setDefaultFont(consoleFont); | ||
60 | topLayout->addWidget(titleLabel); | ||
61 | topLayout->addWidget(m_textDisplay, 10); | ||
62 | |||
63 | show(); | ||
64 | m_timestamper.start(); | ||
65 | } | ||
66 | |||
67 | Console::~Console() | ||
68 | { | ||
69 | |||
70 | } | ||
71 | |||
72 | void Console::log(const QString &message) | ||
73 | { | ||
74 | m_textDisplay->append(QString::number(m_timestamper.elapsed()).rightJustified(6) + ": " + message); | ||
75 | } | ||
76 | |||
diff --git a/examples/client/console.h b/examples/client/console.h deleted file mode 100644 index a6fef01..0000000 --- a/examples/client/console.h +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #pragma once | ||
22 | |||
23 | #include <QTime> | ||
24 | #include <QWidget> | ||
25 | |||
26 | class QTextBrowser; | ||
27 | |||
28 | class Console : public QWidget | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | public: | ||
32 | static Console *main(); | ||
33 | Console(const QString &title); | ||
34 | ~Console(); | ||
35 | |||
36 | void log(const QString &message); | ||
37 | |||
38 | private: | ||
39 | QTextBrowser *m_textDisplay; | ||
40 | QTime m_timestamper; | ||
41 | static Console *s_output; | ||
42 | }; | ||
diff --git a/examples/client/main.cpp b/examples/client/main.cpp deleted file mode 100644 index f4b472f..0000000 --- a/examples/client/main.cpp +++ /dev/null | |||
@@ -1,222 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include <QApplication> | ||
21 | #include <QCommandLineParser> | ||
22 | #include <QCommandLineOption> | ||
23 | #include <QTime> | ||
24 | |||
25 | #include "common/store.h" | ||
26 | #include "common/log.h" | ||
27 | |||
28 | #include <QWidget> | ||
29 | #include <QTreeView> | ||
30 | #include <QVBoxLayout> | ||
31 | #include <QLabel> | ||
32 | #include <QPushButton> | ||
33 | #include <QItemSelectionModel> | ||
34 | #include <iostream> | ||
35 | |||
36 | /** | ||
37 | * A small abstraction layer to use the sink store with the type available as string. | ||
38 | */ | ||
39 | class StoreBase { | ||
40 | public: | ||
41 | virtual ~StoreBase(){}; | ||
42 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; | ||
43 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; | ||
44 | virtual KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
45 | virtual KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
46 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
47 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) = 0; | ||
48 | }; | ||
49 | |||
50 | template <typename T> | ||
51 | class Store : public StoreBase { | ||
52 | public: | ||
53 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { | ||
54 | return T::Ptr::create(); | ||
55 | } | ||
56 | |||
57 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { | ||
58 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
59 | } | ||
60 | |||
61 | KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
62 | return Sink::Store::create<T>(*static_cast<const T*>(&type)); | ||
63 | } | ||
64 | |||
65 | KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
66 | return Sink::Store::modify<T>(*static_cast<const T*>(&type)); | ||
67 | } | ||
68 | |||
69 | KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
70 | return Sink::Store::remove<T>(*static_cast<const T*>(&type)); | ||
71 | } | ||
72 | |||
73 | QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) Q_DECL_OVERRIDE { | ||
74 | return Sink::Store::loadModel<T>(query); | ||
75 | } | ||
76 | }; | ||
77 | |||
78 | StoreBase& getStore(const QString &type) | ||
79 | { | ||
80 | if (type == "folder") { | ||
81 | static Store<Sink::ApplicationDomain::Folder> store; | ||
82 | return store; | ||
83 | } else if (type == "mail") { | ||
84 | static Store<Sink::ApplicationDomain::Mail> store; | ||
85 | return store; | ||
86 | } else if (type == "event") { | ||
87 | static Store<Sink::ApplicationDomain::Event> store; | ||
88 | return store; | ||
89 | } else if (type == "resource") { | ||
90 | static Store<Sink::ApplicationDomain::SinkResource> store; | ||
91 | return store; | ||
92 | } | ||
93 | Q_ASSERT(false); | ||
94 | qWarning() << "Trying to get a store that doesn't exist, falling back to event"; | ||
95 | static Store<Sink::ApplicationDomain::Event> store; | ||
96 | return store; | ||
97 | } | ||
98 | |||
99 | template <typename T> | ||
100 | class View : public QWidget | ||
101 | { | ||
102 | public: | ||
103 | View(QAbstractItemModel *model) | ||
104 | : QWidget() | ||
105 | { | ||
106 | auto modelView = new QTreeView(this); | ||
107 | modelView->setModel(model); | ||
108 | resize(1000, 1500); | ||
109 | |||
110 | auto topLayout = new QVBoxLayout(this); | ||
111 | |||
112 | auto titleLabel = new QLabel(this); | ||
113 | titleLabel->setText("Demo"); | ||
114 | auto font = titleLabel->font(); | ||
115 | font.setWeight(QFont::Bold); | ||
116 | titleLabel->setFont(font); | ||
117 | titleLabel->setAlignment(Qt::AlignCenter); | ||
118 | |||
119 | auto syncButton = new QPushButton(this); | ||
120 | syncButton->setText("Synchronize!"); | ||
121 | QObject::connect(syncButton, &QPushButton::pressed, []() { | ||
122 | Sink::Query query; | ||
123 | query.resources << "sink.dummy.instance1"; | ||
124 | Sink::Store::synchronize(query).exec(); | ||
125 | }); | ||
126 | |||
127 | auto removeButton = new QPushButton(this); | ||
128 | removeButton->setText("Remove"); | ||
129 | QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { | ||
130 | for (auto index : modelView->selectionModel()->selectedIndexes()) { | ||
131 | auto object = index.data(Sink::Store::DomainObjectRole).value<typename T::Ptr>(); | ||
132 | Sink::Store::remove(*object).exec(); | ||
133 | } | ||
134 | }); | ||
135 | |||
136 | topLayout->addWidget(titleLabel); | ||
137 | topLayout->addWidget(syncButton); | ||
138 | topLayout->addWidget(removeButton); | ||
139 | topLayout->addWidget(modelView, 10); | ||
140 | |||
141 | show(); | ||
142 | } | ||
143 | |||
144 | }; | ||
145 | |||
146 | static QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query) | ||
147 | { | ||
148 | QTime time; | ||
149 | time.start(); | ||
150 | if (type == "folder") { | ||
151 | query.requestedProperties << "name" << "parent"; | ||
152 | } else if (type == "mail") { | ||
153 | query.requestedProperties << "subject" << "folder" << "date"; | ||
154 | } else if (type == "event") { | ||
155 | query.requestedProperties << "summary"; | ||
156 | } else if (type == "resource") { | ||
157 | query.requestedProperties << "type"; | ||
158 | } | ||
159 | auto model = getStore(type).loadModel(query); | ||
160 | qDebug() << "Folder type " << type; | ||
161 | qDebug() << "Loaded model in " << time.elapsed() << " ms"; | ||
162 | Q_ASSERT(model); | ||
163 | return model; | ||
164 | } | ||
165 | |||
166 | QMap<QString, QString> consumeMap(QList<QString> &list) | ||
167 | { | ||
168 | QMap<QString, QString> map; | ||
169 | while(list.size() >= 2) { | ||
170 | map.insert(list.at(0), list.at(1)); | ||
171 | list = list.mid(2); | ||
172 | } | ||
173 | return map; | ||
174 | } | ||
175 | |||
176 | int main(int argc, char *argv[]) | ||
177 | { | ||
178 | QApplication app(argc, argv); | ||
179 | |||
180 | QCommandLineParser cliOptions; | ||
181 | cliOptions.addPositionalArgument(QObject::tr("[type]"), | ||
182 | QObject::tr("A type to work with")); | ||
183 | cliOptions.addPositionalArgument(QObject::tr("[resource]"), | ||
184 | QObject::tr("A resource to connect to")); | ||
185 | cliOptions.addOption(QCommandLineOption("debuglevel", "A debuglevel from 0-6", "debuglevel")); | ||
186 | cliOptions.addHelpOption(); | ||
187 | cliOptions.process(app); | ||
188 | QStringList args = cliOptions.positionalArguments(); | ||
189 | |||
190 | if (cliOptions.isSet("debuglevel")) { | ||
191 | Sink::Log::setDebugOutputLevel(static_cast<Sink::Log::DebugLevel>(cliOptions.value("debuglevel").toInt())); | ||
192 | } | ||
193 | |||
194 | auto type = !args.isEmpty() ? args.takeFirst() : QByteArray(); | ||
195 | auto resources = args; | ||
196 | |||
197 | Sink::Query query; | ||
198 | for (const auto &res : resources) { | ||
199 | query.resources << res.toLatin1(); | ||
200 | } | ||
201 | query.liveQuery = true; | ||
202 | if (type == "folder") { | ||
203 | query.parentProperty = "parent"; | ||
204 | } | ||
205 | auto model = loadModel(type, query); | ||
206 | if (type == "folder") { | ||
207 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) { | ||
208 | for (int i = start; i <= end; i++) { | ||
209 | model->fetchMore(model->index(i, 0, index)); | ||
210 | } | ||
211 | }); | ||
212 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Folder> >::create(model.data()); | ||
213 | app.exec(); | ||
214 | } else if (type == "mail") { | ||
215 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Mail> >::create(model.data()); | ||
216 | app.exec(); | ||
217 | } else if (type == "event") { | ||
218 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Event> >::create(model.data()); | ||
219 | app.exec(); | ||
220 | } | ||
221 | return 0; | ||
222 | } | ||
diff --git a/examples/imapresource/tests/imapmailsyncbenchmark.cpp b/examples/imapresource/tests/imapmailsyncbenchmark.cpp index 1cf8861..824b769 100644 --- a/examples/imapresource/tests/imapmailsyncbenchmark.cpp +++ b/examples/imapresource/tests/imapmailsyncbenchmark.cpp | |||
@@ -107,7 +107,7 @@ private slots: | |||
107 | void testSync() | 107 | void testSync() |
108 | { | 108 | { |
109 | Sink::Query query; | 109 | Sink::Query query; |
110 | query.resources << mResourceInstanceIdentifier; | 110 | query.resourceFilter(mResourceInstanceIdentifier); |
111 | query.request<Folder::Name>().request<Folder::SpecialPurpose>(); | 111 | query.request<Folder::Name>().request<Folder::SpecialPurpose>(); |
112 | 112 | ||
113 | QTime time; | 113 | QTime time; |
@@ -117,7 +117,7 @@ private slots: | |||
117 | VERIFYEXEC(Store::synchronize(query)); | 117 | VERIFYEXEC(Store::synchronize(query)); |
118 | SinkLog() << "Sync took: " << Sink::Log::TraceTime(time.elapsed()); | 118 | SinkLog() << "Sync took: " << Sink::Log::TraceTime(time.elapsed()); |
119 | 119 | ||
120 | VERIFYEXEC(ResourceControl::flushMessageQueue(query.resources)); | 120 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
121 | SinkLog() << "Total took: " << Sink::Log::TraceTime(time.elapsed()); | 121 | SinkLog() << "Total took: " << Sink::Log::TraceTime(time.elapsed()); |
122 | 122 | ||
123 | time.start(); | 123 | time.start(); |
@@ -125,7 +125,7 @@ private slots: | |||
125 | VERIFYEXEC(Store::synchronize(query)); | 125 | VERIFYEXEC(Store::synchronize(query)); |
126 | SinkLog() << "ReSync took: " << Sink::Log::TraceTime(time.elapsed()); | 126 | SinkLog() << "ReSync took: " << Sink::Log::TraceTime(time.elapsed()); |
127 | 127 | ||
128 | VERIFYEXEC(ResourceControl::flushMessageQueue(query.resources)); | 128 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
129 | SinkLog() << "Total resync took: " << Sink::Log::TraceTime(time.elapsed()); | 129 | SinkLog() << "Total resync took: " << Sink::Log::TraceTime(time.elapsed()); |
130 | } | 130 | } |
131 | }; | 131 | }; |
diff --git a/examples/mailtransportresource/tests/mailtransporttest.cpp b/examples/mailtransportresource/tests/mailtransporttest.cpp index fdd591b..e44aa23 100644 --- a/examples/mailtransportresource/tests/mailtransporttest.cpp +++ b/examples/mailtransportresource/tests/mailtransporttest.cpp | |||
@@ -61,10 +61,10 @@ private slots: | |||
61 | 61 | ||
62 | VERIFYEXEC(Store::create(mail)); | 62 | VERIFYEXEC(Store::create(mail)); |
63 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 63 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
64 | VERIFYEXEC(Store::synchronize(Query::ResourceFilter(mResourceInstanceIdentifier))); | 64 | VERIFYEXEC(Store::synchronize(Query().resourceFilter(mResourceInstanceIdentifier))); |
65 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, true))); | 65 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, true))); |
66 | 66 | ||
67 | auto sentMail = Store::readOne<ApplicationDomain::Mail>(Query::IdentityFilter(mail).request<Mail::Sent>().request<Mail::Subject>()); | 67 | auto sentMail = Store::readOne<ApplicationDomain::Mail>(Query(mail).request<Mail::Sent>().request<Mail::Subject>()); |
68 | QVERIFY(sentMail.getSent()); | 68 | QVERIFY(sentMail.getSent()); |
69 | QVERIFY(!sentMail.getSubject().isEmpty()); | 69 | QVERIFY(!sentMail.getSubject().isEmpty()); |
70 | } | 70 | } |
diff --git a/sinksh/syntax_modules/sink_count.cpp b/sinksh/syntax_modules/sink_count.cpp index fde7c33..7e04c79 100644 --- a/sinksh/syntax_modules/sink_count.cpp +++ b/sinksh/syntax_modules/sink_count.cpp | |||
@@ -51,7 +51,7 @@ bool count(const QStringList &args, State &state) | |||
51 | 51 | ||
52 | Sink::Query query; | 52 | Sink::Query query; |
53 | for (const auto &res : resources) { | 53 | for (const auto &res : resources) { |
54 | query.resources << res.toLatin1(); | 54 | query.resourceFilter(res.toLatin1()); |
55 | } | 55 | } |
56 | query.liveQuery = false; | 56 | query.liveQuery = false; |
57 | 57 | ||
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index 2d7ef5f..e176aab 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp | |||
@@ -59,8 +59,7 @@ bool list(const QStringList &args, State &state) | |||
59 | auto filterIndex = args.indexOf("--filter"); | 59 | auto filterIndex = args.indexOf("--filter"); |
60 | if (filterIndex >= 0) { | 60 | if (filterIndex >= 0) { |
61 | for (int i = 1; i < filterIndex; i++) { | 61 | for (int i = 1; i < filterIndex; i++) { |
62 | query.resources << args.at(i).toLatin1(); | 62 | query.resourceFilter(args.at(i).toLatin1()); |
63 | query.filter(Sink::ApplicationDomain::SinkResource(args.at(i).toLatin1())); | ||
64 | } | 63 | } |
65 | for (int i = filterIndex + 1; i < args.size(); i++) { | 64 | for (int i = filterIndex + 1; i < args.size(); i++) { |
66 | auto filter = args.at(i).split("="); | 65 | auto filter = args.at(i).split("="); |
diff --git a/sinksh/syntax_modules/sink_show.cpp b/sinksh/syntax_modules/sink_show.cpp index 5197e77..45fd62c 100644 --- a/sinksh/syntax_modules/sink_show.cpp +++ b/sinksh/syntax_modules/sink_show.cpp | |||
@@ -60,7 +60,7 @@ bool show(const QStringList &args, State &state) | |||
60 | if (queryForResourceOrAgent) { | 60 | if (queryForResourceOrAgent) { |
61 | query.filter(resource.toLatin1()); | 61 | query.filter(resource.toLatin1()); |
62 | } else { | 62 | } else { |
63 | query.filter(Sink::ApplicationDomain::SinkResource(resource.toLatin1())); | 63 | query.resourceFilter(resource.toLatin1()); |
64 | } | 64 | } |
65 | query.liveQuery = false; | 65 | query.liveQuery = false; |
66 | 66 | ||
diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp index e3c51ff..1c7ed0f 100644 --- a/sinksh/syntax_modules/sink_sync.cpp +++ b/sinksh/syntax_modules/sink_sync.cpp | |||
@@ -41,7 +41,7 @@ bool sync(const QStringList &args, State &state) | |||
41 | { | 41 | { |
42 | Sink::Query query; | 42 | Sink::Query query; |
43 | for (const auto &res : args) { | 43 | for (const auto &res : args) { |
44 | query.resources << res.toLatin1(); | 44 | query.resourceFilter(res.toLatin1()); |
45 | } | 45 | } |
46 | 46 | ||
47 | QTimer::singleShot(0, [query, state]() { | 47 | QTimer::singleShot(0, [query, state]() { |
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index 260602c..8216210 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp | |||
@@ -139,7 +139,7 @@ private slots: | |||
139 | QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::OfflineStatus)); | 139 | QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::OfflineStatus)); |
140 | 140 | ||
141 | //Synchronize to connect | 141 | //Synchronize to connect |
142 | VERIFYEXEC(Sink::Store::synchronize(Query::ResourceFilter(res))); | 142 | VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier()))); |
143 | 143 | ||
144 | QTRY_COMPARE_WITH_TIMEOUT(model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>()->getStatus(), static_cast<int>(Sink::ApplicationDomain::ConnectedStatus), 1000); | 144 | QTRY_COMPARE_WITH_TIMEOUT(model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>()->getStatus(), static_cast<int>(Sink::ApplicationDomain::ConnectedStatus), 1000); |
145 | } | 145 | } |
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 44eb845..fd3d5f0 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -104,7 +104,7 @@ private slots: | |||
104 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 104 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
105 | 105 | ||
106 | Sink::Query query; | 106 | Sink::Query query; |
107 | query.resources << "dummyresource.instance1"; | 107 | query.resourceFilter("dummyresource.instance1"); |
108 | query.liveQuery = false; | 108 | query.liveQuery = false; |
109 | 109 | ||
110 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | 110 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
@@ -115,7 +115,7 @@ private slots: | |||
115 | void testLoadWithoutResource() | 115 | void testLoadWithoutResource() |
116 | { | 116 | { |
117 | Sink::Query query; | 117 | Sink::Query query; |
118 | query.resources << "nonexisting.resource"; | 118 | query.resourceFilter("nonexisting.resource"); |
119 | query.liveQuery = false; | 119 | query.liveQuery = false; |
120 | 120 | ||
121 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | 121 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
@@ -129,7 +129,7 @@ private slots: | |||
129 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 129 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
130 | 130 | ||
131 | Sink::Query query; | 131 | Sink::Query query; |
132 | query.resources << "dummyresource.instance1"; | 132 | query.resourceFilter("dummyresource.instance1"); |
133 | query.liveQuery = false; | 133 | query.liveQuery = false; |
134 | 134 | ||
135 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 135 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
@@ -147,7 +147,7 @@ private slots: | |||
147 | 147 | ||
148 | // Test | 148 | // Test |
149 | Sink::Query query; | 149 | Sink::Query query; |
150 | query.resources << "dummyresource.instance1"; | 150 | query.resourceFilter("dummyresource.instance1"); |
151 | query.liveQuery = false; | 151 | query.liveQuery = false; |
152 | query.parentProperty = "parent"; | 152 | query.parentProperty = "parent"; |
153 | 153 | ||
@@ -170,7 +170,7 @@ private slots: | |||
170 | 170 | ||
171 | // Test | 171 | // Test |
172 | Sink::Query query; | 172 | Sink::Query query; |
173 | query.resources << "dummyresource.instance1"; | 173 | query.resourceFilter("dummyresource.instance1"); |
174 | query.liveQuery = false; | 174 | query.liveQuery = false; |
175 | query.parentProperty = "parent"; | 175 | query.parentProperty = "parent"; |
176 | 176 | ||
@@ -193,7 +193,7 @@ private slots: | |||
193 | 193 | ||
194 | // Test | 194 | // Test |
195 | Sink::Query query; | 195 | Sink::Query query; |
196 | query.resources << "dummyresource.instance1"; | 196 | query.resourceFilter("dummyresource.instance1"); |
197 | query.liveQuery = true; | 197 | query.liveQuery = true; |
198 | query.parentProperty = "parent"; | 198 | query.parentProperty = "parent"; |
199 | 199 | ||
@@ -268,7 +268,7 @@ private slots: | |||
268 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 268 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
269 | 269 | ||
270 | Sink::Query query; | 270 | Sink::Query query; |
271 | query.resources << "dummyresource.instance1"; | 271 | query.resourceFilter("dummyresource.instance1"); |
272 | query.liveQuery = false; | 272 | query.liveQuery = false; |
273 | 273 | ||
274 | bool gotValue = false; | 274 | bool gotValue = false; |
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index ffaa8f6..8c6afb4 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -13,6 +13,8 @@ | |||
13 | #include "log.h" | 13 | #include "log.h" |
14 | #include "resourceconfig.h" | 14 | #include "resourceconfig.h" |
15 | #include "notification_generated.h" | 15 | #include "notification_generated.h" |
16 | #include "test.h" | ||
17 | #include "testutils.h" | ||
16 | 18 | ||
17 | #include "hawd/dataset.h" | 19 | #include "hawd/dataset.h" |
18 | #include "hawd/formatter.h" | 20 | #include "hawd/formatter.h" |
@@ -98,8 +100,8 @@ private slots: | |||
98 | // Ensure everything is processed | 100 | // Ensure everything is processed |
99 | { | 101 | { |
100 | Sink::Query query; | 102 | Sink::Query query; |
101 | query.resources << "sink.dummy.instance1"; | 103 | query.resourceFilter("sink.dummy.instance1"); |
102 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 104 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
103 | } | 105 | } |
104 | auto allProcessedTime = time.elapsed(); | 106 | auto allProcessedTime = time.elapsed(); |
105 | 107 | ||
@@ -127,7 +129,7 @@ private slots: | |||
127 | { | 129 | { |
128 | time.start(); | 130 | time.start(); |
129 | Sink::Query query; | 131 | Sink::Query query; |
130 | query.resources << "sink.dummy.instance1"; | 132 | query.resourceFilter("sink.dummy.instance1"); |
131 | 133 | ||
132 | query.filter("uid", Sink::Query::Comparator("testuid")); | 134 | query.filter("uid", Sink::Query::Comparator("testuid")); |
133 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | 135 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index a7a492c..2ff31e5 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "pipeline.h" | 12 | #include "pipeline.h" |
13 | #include "log.h" | 13 | #include "log.h" |
14 | #include "test.h" | 14 | #include "test.h" |
15 | #include "testutils.h" | ||
15 | 16 | ||
16 | using namespace Sink; | 17 | using namespace Sink; |
17 | using namespace Sink::ApplicationDomain; | 18 | using namespace Sink::ApplicationDomain; |
@@ -66,10 +67,10 @@ private slots: | |||
66 | event.setProperty("summary", "summaryValue"); | 67 | event.setProperty("summary", "summaryValue"); |
67 | Sink::Store::create<Event>(event).exec().waitForFinished(); | 68 | Sink::Store::create<Event>(event).exec().waitForFinished(); |
68 | 69 | ||
69 | auto query = Query::ResourceFilter("sink.dummy.instance1") ; | 70 | auto query = Query().resourceFilter("sink.dummy.instance1") ; |
70 | 71 | ||
71 | // Ensure all local data is processed | 72 | // Ensure all local data is processed |
72 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 73 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
73 | 74 | ||
74 | auto model = Sink::Store::loadModel<Event>(query.filter<Event::Uid>("testuid")); | 75 | auto model = Sink::Store::loadModel<Event>(query.filter<Event::Uid>("testuid")); |
75 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 76 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
@@ -88,10 +89,10 @@ private slots: | |||
88 | event.setProperty("uid", "testuid2"); | 89 | event.setProperty("uid", "testuid2"); |
89 | Sink::Store::create<Event>(event).exec().waitForFinished(); | 90 | Sink::Store::create<Event>(event).exec().waitForFinished(); |
90 | 91 | ||
91 | auto query = Query::ResourceFilter("sink.dummy.instance1") ; | 92 | auto query = Query().resourceFilter("sink.dummy.instance1") ; |
92 | 93 | ||
93 | // Ensure all local data is processed | 94 | // Ensure all local data is processed |
94 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 95 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
95 | 96 | ||
96 | auto model = Sink::Store::loadModel<Event>(query.filter<Event::Uid>("testuid")); | 97 | auto model = Sink::Store::loadModel<Event>(query.filter<Event::Uid>("testuid")); |
97 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 98 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
@@ -113,10 +114,10 @@ private slots: | |||
113 | event.setProperty("summary", "summaryValue2"); | 114 | event.setProperty("summary", "summaryValue2"); |
114 | Sink::Store::create<Event>(event).exec().waitForFinished(); | 115 | Sink::Store::create<Event>(event).exec().waitForFinished(); |
115 | 116 | ||
116 | auto query = Query::ResourceFilter("sink.dummy.instance1") ; | 117 | auto query = Query().resourceFilter("sink.dummy.instance1") ; |
117 | 118 | ||
118 | // Ensure all local data is processed | 119 | // Ensure all local data is processed |
119 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 120 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
120 | 121 | ||
121 | auto model = Sink::Store::loadModel<Event>(query.filter<Event::Summary>("summaryValue2")); | 122 | auto model = Sink::Store::loadModel<Event>(query.filter<Event::Summary>("summaryValue2")); |
122 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 123 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
@@ -143,11 +144,11 @@ private slots: | |||
143 | 144 | ||
144 | void testSyncAndFacade() | 145 | void testSyncAndFacade() |
145 | { | 146 | { |
146 | const auto query = Query::ResourceFilter("sink.dummy.instance1"); | 147 | const auto query = Query().resourceFilter("sink.dummy.instance1"); |
147 | 148 | ||
148 | // Ensure all local data is processed | 149 | // Ensure all local data is processed |
149 | Sink::Store::synchronize(query).exec().waitForFinished(); | 150 | Sink::Store::synchronize(query).exec().waitForFinished(); |
150 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 151 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
151 | 152 | ||
152 | auto model = Sink::Store::loadModel<Event>(query); | 153 | auto model = Sink::Store::loadModel<Event>(query); |
153 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | 154 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); |
@@ -159,12 +160,12 @@ private slots: | |||
159 | 160 | ||
160 | void testSyncAndFacadeMail() | 161 | void testSyncAndFacadeMail() |
161 | { | 162 | { |
162 | auto query = Query::ResourceFilter("sink.dummy.instance1"); | 163 | auto query = Query().resourceFilter("sink.dummy.instance1"); |
163 | query.request<Mail::Subject>(); | 164 | query.request<Mail::Subject>(); |
164 | 165 | ||
165 | // Ensure all local data is processed | 166 | // Ensure all local data is processed |
166 | Sink::Store::synchronize(query).exec().waitForFinished(); | 167 | Sink::Store::synchronize(query).exec().waitForFinished(); |
167 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 168 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
168 | 169 | ||
169 | auto model = Sink::Store::loadModel<Mail>(query); | 170 | auto model = Sink::Store::loadModel<Mail>(query); |
170 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | 171 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); |
@@ -182,10 +183,10 @@ private slots: | |||
182 | event.setProperty("summary", "summaryValue"); | 183 | event.setProperty("summary", "summaryValue"); |
183 | Sink::Store::create<Event>(event).exec().waitForFinished(); | 184 | Sink::Store::create<Event>(event).exec().waitForFinished(); |
184 | 185 | ||
185 | auto query = Query::ResourceFilter("sink.dummy.instance1").filter<Event::Uid>("testuid"); | 186 | auto query = Query().resourceFilter("sink.dummy.instance1").filter<Event::Uid>("testuid"); |
186 | 187 | ||
187 | // Ensure all local data is processed | 188 | // Ensure all local data is processed |
188 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 189 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
189 | 190 | ||
190 | // Test create | 191 | // Test create |
191 | Event event2; | 192 | Event event2; |
@@ -204,7 +205,7 @@ private slots: | |||
204 | Sink::Store::modify<Event>(event2).exec().waitForFinished(); | 205 | Sink::Store::modify<Event>(event2).exec().waitForFinished(); |
205 | 206 | ||
206 | // Ensure all local data is processed | 207 | // Ensure all local data is processed |
207 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 208 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
208 | 209 | ||
209 | // Test modify | 210 | // Test modify |
210 | { | 211 | { |
@@ -219,7 +220,7 @@ private slots: | |||
219 | Sink::Store::remove<Event>(event2).exec().waitForFinished(); | 220 | Sink::Store::remove<Event>(event2).exec().waitForFinished(); |
220 | 221 | ||
221 | // Ensure all local data is processed | 222 | // Ensure all local data is processed |
222 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 223 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
223 | 224 | ||
224 | // Test remove | 225 | // Test remove |
225 | { | 226 | { |
@@ -231,7 +232,7 @@ private slots: | |||
231 | 232 | ||
232 | void testWriteModifyDeleteLive() | 233 | void testWriteModifyDeleteLive() |
233 | { | 234 | { |
234 | auto query = Query::ResourceFilter("sink.dummy.instance1"); | 235 | auto query = Query().resourceFilter("sink.dummy.instance1"); |
235 | query.liveQuery = true; | 236 | query.liveQuery = true; |
236 | query.filter<Event::Uid>("testuid"); | 237 | query.filter<Event::Uid>("testuid"); |
237 | 238 | ||
diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp index 8260978..98ac685 100644 --- a/tests/mailsynctest.cpp +++ b/tests/mailsynctest.cpp | |||
@@ -81,12 +81,12 @@ void MailSyncTest::testListFolders() | |||
81 | } | 81 | } |
82 | 82 | ||
83 | Sink::Query query; | 83 | Sink::Query query; |
84 | query.resources << mResourceInstanceIdentifier; | 84 | query.resourceFilter(mResourceInstanceIdentifier); |
85 | query.request<Folder::Name>().request<Folder::SpecialPurpose>(); | 85 | query.request<Folder::Name>().request<Folder::SpecialPurpose>(); |
86 | 86 | ||
87 | // Ensure all local data is processed | 87 | // Ensure all local data is processed |
88 | VERIFYEXEC(Store::synchronize(query)); | 88 | VERIFYEXEC(Store::synchronize(query)); |
89 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 89 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
90 | 90 | ||
91 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { | 91 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { |
92 | QStringList names; | 92 | QStringList names; |
@@ -121,14 +121,14 @@ void MailSyncTest::testListFolders() | |||
121 | void MailSyncTest::testListNewFolder() | 121 | void MailSyncTest::testListNewFolder() |
122 | { | 122 | { |
123 | Sink::Query query; | 123 | Sink::Query query; |
124 | query.resources << mResourceInstanceIdentifier; | 124 | query.resourceFilter(mResourceInstanceIdentifier); |
125 | query.request<Folder::Name>(); | 125 | query.request<Folder::Name>(); |
126 | 126 | ||
127 | createFolder(QStringList() << "test2"); | 127 | createFolder(QStringList() << "test2"); |
128 | 128 | ||
129 | // Ensure all local data is processed | 129 | // Ensure all local data is processed |
130 | VERIFYEXEC(Store::synchronize(query)); | 130 | VERIFYEXEC(Store::synchronize(query)); |
131 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 131 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
132 | 132 | ||
133 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { | 133 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { |
134 | QStringList names; | 134 | QStringList names; |
@@ -143,17 +143,17 @@ void MailSyncTest::testListNewFolder() | |||
143 | void MailSyncTest::testListRemovedFolder() | 143 | void MailSyncTest::testListRemovedFolder() |
144 | { | 144 | { |
145 | Sink::Query query; | 145 | Sink::Query query; |
146 | query.resources << mResourceInstanceIdentifier; | 146 | query.resourceFilter(mResourceInstanceIdentifier); |
147 | query.request<Folder::Name>(); | 147 | query.request<Folder::Name>(); |
148 | 148 | ||
149 | VERIFYEXEC(Store::synchronize(query)); | 149 | VERIFYEXEC(Store::synchronize(query)); |
150 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 150 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
151 | 151 | ||
152 | removeFolder(QStringList() << "test2"); | 152 | removeFolder(QStringList() << "test2"); |
153 | 153 | ||
154 | // Ensure all local data is processed | 154 | // Ensure all local data is processed |
155 | VERIFYEXEC(Store::synchronize(query)); | 155 | VERIFYEXEC(Store::synchronize(query)); |
156 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 156 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
157 | 157 | ||
158 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { | 158 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { |
159 | QStringList names; | 159 | QStringList names; |
@@ -171,14 +171,14 @@ void MailSyncTest::testListFolderHierarchy() | |||
171 | QSKIP("Missing capability folder.hierarchy"); | 171 | QSKIP("Missing capability folder.hierarchy"); |
172 | } | 172 | } |
173 | Sink::Query query; | 173 | Sink::Query query; |
174 | query.resources << mResourceInstanceIdentifier; | 174 | query.resourceFilter(mResourceInstanceIdentifier); |
175 | query.request<Folder::Name>().request<Folder::Parent>(); | 175 | query.request<Folder::Name>().request<Folder::Parent>(); |
176 | 176 | ||
177 | createFolder(QStringList() << "test" << "sub"); | 177 | createFolder(QStringList() << "test" << "sub"); |
178 | 178 | ||
179 | // Ensure all local data is processed | 179 | // Ensure all local data is processed |
180 | VERIFYEXEC(Store::synchronize(query)); | 180 | VERIFYEXEC(Store::synchronize(query)); |
181 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 181 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
182 | 182 | ||
183 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { | 183 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { |
184 | QHash<QString, Folder::Ptr> map; | 184 | QHash<QString, Folder::Ptr> map; |
@@ -214,14 +214,14 @@ void MailSyncTest::testListNewSubFolder() | |||
214 | QSKIP("Missing capability mail.folderhierarchy"); | 214 | QSKIP("Missing capability mail.folderhierarchy"); |
215 | } | 215 | } |
216 | Sink::Query query; | 216 | Sink::Query query; |
217 | query.resources << mResourceInstanceIdentifier; | 217 | query.resourceFilter(mResourceInstanceIdentifier); |
218 | query.request<Folder::Name>(); | 218 | query.request<Folder::Name>(); |
219 | 219 | ||
220 | createFolder(QStringList() << "test" << "sub1"); | 220 | createFolder(QStringList() << "test" << "sub1"); |
221 | 221 | ||
222 | // Ensure all local data is processed | 222 | // Ensure all local data is processed |
223 | VERIFYEXEC(Store::synchronize(query)); | 223 | VERIFYEXEC(Store::synchronize(query)); |
224 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 224 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
225 | 225 | ||
226 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { | 226 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { |
227 | QStringList names; | 227 | QStringList names; |
@@ -239,17 +239,17 @@ void MailSyncTest::testListRemovedSubFolder() | |||
239 | QSKIP("Missing capability folder.hierarchy"); | 239 | QSKIP("Missing capability folder.hierarchy"); |
240 | } | 240 | } |
241 | Sink::Query query; | 241 | Sink::Query query; |
242 | query.resources << mResourceInstanceIdentifier; | 242 | query.resourceFilter(mResourceInstanceIdentifier); |
243 | query.request<Folder::Name>(); | 243 | query.request<Folder::Name>(); |
244 | 244 | ||
245 | VERIFYEXEC(Store::synchronize(query)); | 245 | VERIFYEXEC(Store::synchronize(query)); |
246 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 246 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
247 | 247 | ||
248 | removeFolder(QStringList() << "test" << "sub1"); | 248 | removeFolder(QStringList() << "test" << "sub1"); |
249 | 249 | ||
250 | // Ensure all local data is processed | 250 | // Ensure all local data is processed |
251 | VERIFYEXEC(Store::synchronize(query)); | 251 | VERIFYEXEC(Store::synchronize(query)); |
252 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 252 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
253 | 253 | ||
254 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { | 254 | auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { |
255 | QStringList names; | 255 | QStringList names; |
@@ -264,12 +264,12 @@ void MailSyncTest::testListRemovedSubFolder() | |||
264 | void MailSyncTest::testListMails() | 264 | void MailSyncTest::testListMails() |
265 | { | 265 | { |
266 | Sink::Query query; | 266 | Sink::Query query; |
267 | query.resources << mResourceInstanceIdentifier; | 267 | query.resourceFilter(mResourceInstanceIdentifier); |
268 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); | 268 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); |
269 | 269 | ||
270 | // Ensure all local data is processed | 270 | // Ensure all local data is processed |
271 | VERIFYEXEC(Store::synchronize(query)); | 271 | VERIFYEXEC(Store::synchronize(query)); |
272 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 272 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
273 | 273 | ||
274 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 274 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
275 | QCOMPARE(mails.size(), 1); | 275 | QCOMPARE(mails.size(), 1); |
@@ -290,15 +290,15 @@ void MailSyncTest::testListMails() | |||
290 | void MailSyncTest::testResyncMails() | 290 | void MailSyncTest::testResyncMails() |
291 | { | 291 | { |
292 | Sink::Query query; | 292 | Sink::Query query; |
293 | query.resources << mResourceInstanceIdentifier; | 293 | query.resourceFilter(mResourceInstanceIdentifier); |
294 | 294 | ||
295 | // Ensure all local data is processed | 295 | // Ensure all local data is processed |
296 | VERIFYEXEC(Store::synchronize(query)); | 296 | VERIFYEXEC(Store::synchronize(query)); |
297 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 297 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
298 | 298 | ||
299 | // Ensure all local data is processed | 299 | // Ensure all local data is processed |
300 | VERIFYEXEC(Store::synchronize(query)); | 300 | VERIFYEXEC(Store::synchronize(query)); |
301 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 301 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
302 | 302 | ||
303 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 303 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
304 | QCOMPARE(mails.size(), 1); | 304 | QCOMPARE(mails.size(), 1); |
@@ -309,20 +309,20 @@ void MailSyncTest::testResyncMails() | |||
309 | void MailSyncTest::testFetchNewRemovedMessages() | 309 | void MailSyncTest::testFetchNewRemovedMessages() |
310 | { | 310 | { |
311 | Sink::Query query; | 311 | Sink::Query query; |
312 | query.resources << mResourceInstanceIdentifier; | 312 | query.resourceFilter(mResourceInstanceIdentifier); |
313 | query.request<Mail::Subject>().request<Mail::MimeMessage>(); | 313 | query.request<Mail::Subject>().request<Mail::MimeMessage>(); |
314 | 314 | ||
315 | // Ensure all local data is processed | 315 | // Ensure all local data is processed |
316 | VERIFYEXEC(Store::synchronize(query)); | 316 | VERIFYEXEC(Store::synchronize(query)); |
317 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 317 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
318 | 318 | ||
319 | auto msg = KMime::Message::Ptr::create(); | 319 | auto msg = KMime::Message::Ptr::create(); |
320 | msg->subject(true)->fromUnicodeString("Foobar", "utf8"); | 320 | msg->subject(true)->fromUnicodeString("Foobar", "utf8"); |
321 | msg->assemble(); | 321 | msg->assemble(); |
322 | auto messageIdentifier = createMessage(QStringList() << "test", msg->encodedContent(true)); | 322 | auto messageIdentifier = createMessage(QStringList() << "test", msg->encodedContent(true)); |
323 | 323 | ||
324 | Store::synchronize(query).exec().waitForFinished(); | 324 | VERIFYEXEC(Store::synchronize(query)); |
325 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 325 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
326 | 326 | ||
327 | { | 327 | { |
328 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 328 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
@@ -333,8 +333,8 @@ void MailSyncTest::testFetchNewRemovedMessages() | |||
333 | 333 | ||
334 | removeMessage(QStringList() << "test", messageIdentifier); | 334 | removeMessage(QStringList() << "test", messageIdentifier); |
335 | 335 | ||
336 | Store::synchronize(query).exec().waitForFinished(); | 336 | VERIFYEXEC(Store::synchronize(query)); |
337 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 337 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
338 | 338 | ||
339 | { | 339 | { |
340 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 340 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
@@ -347,7 +347,8 @@ void MailSyncTest::testFetchNewRemovedMessages() | |||
347 | void MailSyncTest::testFlagChange() | 347 | void MailSyncTest::testFlagChange() |
348 | { | 348 | { |
349 | Sink::Query query; | 349 | Sink::Query query; |
350 | query.resources << mResourceInstanceIdentifier; | 350 | query.resourceFilter(mResourceInstanceIdentifier); |
351 | query.filter<Mail::Important>(true); | ||
351 | query.request<Mail::Subject>().request<Mail::Important>(); | 352 | query.request<Mail::Subject>().request<Mail::Important>(); |
352 | 353 | ||
353 | auto msg = KMime::Message::Ptr::create(); | 354 | auto msg = KMime::Message::Ptr::create(); |
@@ -355,13 +356,12 @@ void MailSyncTest::testFlagChange() | |||
355 | msg->assemble(); | 356 | msg->assemble(); |
356 | auto messageIdentifier = createMessage(QStringList() << "test", msg->encodedContent(true)); | 357 | auto messageIdentifier = createMessage(QStringList() << "test", msg->encodedContent(true)); |
357 | 358 | ||
358 | Store::synchronize(query).exec().waitForFinished(); | 359 | VERIFYEXEC(Store::synchronize(query)); |
359 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 360 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
360 | 361 | ||
361 | { | 362 | { |
362 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 363 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
363 | QCOMPARE(mails.size(), 2); | 364 | QCOMPARE(mails.size(), 0); |
364 | QVERIFY(!mails.at(1)->getImportant()); | ||
365 | }); | 365 | }); |
366 | VERIFYEXEC(job); | 366 | VERIFYEXEC(job); |
367 | } | 367 | } |
@@ -370,12 +370,12 @@ void MailSyncTest::testFlagChange() | |||
370 | 370 | ||
371 | // Ensure all local data is processed | 371 | // Ensure all local data is processed |
372 | VERIFYEXEC(Store::synchronize(query)); | 372 | VERIFYEXEC(Store::synchronize(query)); |
373 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 373 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
374 | 374 | ||
375 | { | 375 | { |
376 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 376 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
377 | QCOMPARE(mails.size(), 2); | 377 | QCOMPARE(mails.size(), 1); |
378 | QVERIFY(mails.at(1)->getImportant()); | 378 | QVERIFY(mails.first()->getImportant()); |
379 | }); | 379 | }); |
380 | VERIFYEXEC(job); | 380 | VERIFYEXEC(job); |
381 | } | 381 | } |
@@ -389,7 +389,7 @@ void MailSyncTest::testFailingSync() | |||
389 | VERIFYEXEC(Store::create(resource)); | 389 | VERIFYEXEC(Store::create(resource)); |
390 | 390 | ||
391 | Sink::Query query; | 391 | Sink::Query query; |
392 | query.resources << resource.identifier(); | 392 | query.resourceFilter(resource.identifier()); |
393 | 393 | ||
394 | // Ensure sync fails if resource is misconfigured | 394 | // Ensure sync fails if resource is misconfigured |
395 | auto future = Store::synchronize(query).exec(); | 395 | auto future = Store::synchronize(query).exec(); |
diff --git a/tests/mailtest.cpp b/tests/mailtest.cpp index ed145d4..3339838 100644 --- a/tests/mailtest.cpp +++ b/tests/mailtest.cpp | |||
@@ -298,7 +298,7 @@ void MailTest::testMarkMailAsRead() | |||
298 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 298 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
299 | 299 | ||
300 | auto job = Store::fetchAll<Mail>(Query() | 300 | auto job = Store::fetchAll<Mail>(Query() |
301 | .filter(SinkResource(mResourceInstanceIdentifier)) | 301 | .resourceFilter(mResourceInstanceIdentifier) |
302 | .request<Mail::Folder>() | 302 | .request<Mail::Folder>() |
303 | .request<Mail::Subject>() | 303 | .request<Mail::Subject>() |
304 | ) | 304 | ) |
@@ -315,7 +315,7 @@ void MailTest::testMarkMailAsRead() | |||
315 | 315 | ||
316 | // Verify that we can still query for all relevant information | 316 | // Verify that we can still query for all relevant information |
317 | auto job2 = Store::fetchAll<Mail>(Query() | 317 | auto job2 = Store::fetchAll<Mail>(Query() |
318 | .filter(SinkResource(mResourceInstanceIdentifier)) | 318 | .resourceFilter(mResourceInstanceIdentifier) |
319 | .request<Mail::Folder>() | 319 | .request<Mail::Folder>() |
320 | .request<Mail::Subject>() | 320 | .request<Mail::Subject>() |
321 | .request<Mail::MimeMessage>() | 321 | .request<Mail::MimeMessage>() |
@@ -351,7 +351,7 @@ void MailTest::testCreateDraft() | |||
351 | 351 | ||
352 | QByteArray folderIdentifier; | 352 | QByteArray folderIdentifier; |
353 | 353 | ||
354 | auto createdDraft = Store::readOne<ApplicationDomain::Mail>(Query::IdentityFilter(mail).request<Mail::Folder>()); | 354 | auto createdDraft = Store::readOne<ApplicationDomain::Mail>(Query(mail).request<Mail::Folder>()); |
355 | folderIdentifier = createdDraft.getFolder(); | 355 | folderIdentifier = createdDraft.getFolder(); |
356 | QVERIFY(!folderIdentifier.isEmpty()); | 356 | QVERIFY(!folderIdentifier.isEmpty()); |
357 | 357 | ||
@@ -370,7 +370,7 @@ void MailTest::testCreateDraft() | |||
370 | //Ensure the folder is also existing | 370 | //Ensure the folder is also existing |
371 | { | 371 | { |
372 | ApplicationDomain::Folder folder; | 372 | ApplicationDomain::Folder folder; |
373 | auto folders = Store::read<ApplicationDomain::Folder>(Query::IdentityFilter(folderIdentifier)); | 373 | auto folders = Store::read<ApplicationDomain::Folder>(Query().filter(folderIdentifier)); |
374 | QCOMPARE(folders.size(), 1); | 374 | QCOMPARE(folders.size(), 1); |
375 | folder = folders.first(); | 375 | folder = folders.first(); |
376 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::ExistenceInspection(folder, true))); | 376 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::ExistenceInspection(folder, true))); |
@@ -400,7 +400,7 @@ void MailTest::testModifyMailToDraft() | |||
400 | VERIFYEXEC(Store::create(mail)); | 400 | VERIFYEXEC(Store::create(mail)); |
401 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 401 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
402 | 402 | ||
403 | auto modifiedMail = Store::readOne<ApplicationDomain::Mail>(Query::IdentityFilter(mail)); | 403 | auto modifiedMail = Store::readOne<ApplicationDomain::Mail>(Query(mail)); |
404 | modifiedMail.setDraft(true); | 404 | modifiedMail.setDraft(true); |
405 | VERIFYEXEC(Store::modify(modifiedMail)); | 405 | VERIFYEXEC(Store::modify(modifiedMail)); |
406 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 406 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
@@ -408,7 +408,7 @@ void MailTest::testModifyMailToDraft() | |||
408 | 408 | ||
409 | QByteArray folderIdentifier; | 409 | QByteArray folderIdentifier; |
410 | { | 410 | { |
411 | auto createdDraft = Store::readOne<ApplicationDomain::Mail>(Query::IdentityFilter(mail).request<Mail::Folder>()); | 411 | auto createdDraft = Store::readOne<ApplicationDomain::Mail>(Query(mail).request<Mail::Folder>()); |
412 | folderIdentifier = createdDraft.getFolder(); | 412 | folderIdentifier = createdDraft.getFolder(); |
413 | QVERIFY(!folderIdentifier.isEmpty()); | 413 | QVERIFY(!folderIdentifier.isEmpty()); |
414 | } | 414 | } |
@@ -416,7 +416,7 @@ void MailTest::testModifyMailToDraft() | |||
416 | //Ensure the folder is also existing | 416 | //Ensure the folder is also existing |
417 | { | 417 | { |
418 | ApplicationDomain::Folder folder; | 418 | ApplicationDomain::Folder folder; |
419 | auto folders = Store::read<ApplicationDomain::Folder>(Query::IdentityFilter(folderIdentifier).request<Folder::SpecialPurpose>()); | 419 | auto folders = Store::read<ApplicationDomain::Folder>(Query().filter(folderIdentifier).request<Folder::SpecialPurpose>()); |
420 | QCOMPARE(folders.size(), 1); | 420 | QCOMPARE(folders.size(), 1); |
421 | folder = folders.first(); | 421 | folder = folders.first(); |
422 | QVERIFY(folder.getSpecialPurpose().contains("drafts")); | 422 | QVERIFY(folder.getSpecialPurpose().contains("drafts")); |
@@ -447,7 +447,7 @@ void MailTest::testModifyMailToTrash() | |||
447 | VERIFYEXEC(Store::create(mail)); | 447 | VERIFYEXEC(Store::create(mail)); |
448 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 448 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
449 | 449 | ||
450 | auto modifiedMail = Store::readOne<ApplicationDomain::Mail>(Query::IdentityFilter(mail)); | 450 | auto modifiedMail = Store::readOne<ApplicationDomain::Mail>(Query(mail)); |
451 | modifiedMail.setTrash(true); | 451 | modifiedMail.setTrash(true); |
452 | VERIFYEXEC(Store::modify(modifiedMail)); | 452 | VERIFYEXEC(Store::modify(modifiedMail)); |
453 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 453 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
@@ -455,7 +455,7 @@ void MailTest::testModifyMailToTrash() | |||
455 | 455 | ||
456 | QByteArray folderIdentifier; | 456 | QByteArray folderIdentifier; |
457 | { | 457 | { |
458 | auto createdMail = Store::readOne<ApplicationDomain::Mail>(Query::IdentityFilter(mail).request<Mail::Folder>()); | 458 | auto createdMail = Store::readOne<ApplicationDomain::Mail>(Query(mail).request<Mail::Folder>()); |
459 | folderIdentifier = createdMail.getFolder(); | 459 | folderIdentifier = createdMail.getFolder(); |
460 | QVERIFY(!folderIdentifier.isEmpty()); | 460 | QVERIFY(!folderIdentifier.isEmpty()); |
461 | } | 461 | } |
@@ -463,7 +463,7 @@ void MailTest::testModifyMailToTrash() | |||
463 | //Ensure the folder is also existing | 463 | //Ensure the folder is also existing |
464 | { | 464 | { |
465 | ApplicationDomain::Folder folder; | 465 | ApplicationDomain::Folder folder; |
466 | auto folders = Store::read<ApplicationDomain::Folder>(Query::IdentityFilter(folderIdentifier).request<Folder::SpecialPurpose>()); | 466 | auto folders = Store::read<ApplicationDomain::Folder>(Query().filter(folderIdentifier).request<Folder::SpecialPurpose>()); |
467 | QCOMPARE(folders.size(), 1); | 467 | QCOMPARE(folders.size(), 1); |
468 | folder = folders.first(); | 468 | folder = folders.first(); |
469 | QVERIFY(folder.getSpecialPurpose().contains("trash")); | 469 | QVERIFY(folder.getSpecialPurpose().contains("trash")); |
diff --git a/tests/mailthreadtest.cpp b/tests/mailthreadtest.cpp index 6ba54df..b6b0da2 100644 --- a/tests/mailthreadtest.cpp +++ b/tests/mailthreadtest.cpp | |||
@@ -66,14 +66,14 @@ void MailThreadTest::init() | |||
66 | void MailThreadTest::testListThreadLeader() | 66 | void MailThreadTest::testListThreadLeader() |
67 | { | 67 | { |
68 | Sink::Query query; | 68 | Sink::Query query; |
69 | query.filter(SinkResource(mResourceInstanceIdentifier)); | 69 | query.resourceFilter(mResourceInstanceIdentifier); |
70 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); | 70 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); |
71 | query.sort<Mail::Date>(); | 71 | query.sort<Mail::Date>(); |
72 | query.reduce<Mail::ThreadId>(Query::Reduce::Selector::max<Mail::Date>()); | 72 | query.reduce<Mail::ThreadId>(Query::Reduce::Selector::max<Mail::Date>()); |
73 | 73 | ||
74 | // Ensure all local data is processed | 74 | // Ensure all local data is processed |
75 | VERIFYEXEC(Store::synchronize(query)); | 75 | VERIFYEXEC(Store::synchronize(query)); |
76 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 76 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
77 | 77 | ||
78 | auto mails = Store::read<Mail>(query); | 78 | auto mails = Store::read<Mail>(query); |
79 | QCOMPARE(mails.size(), 1); | 79 | QCOMPARE(mails.size(), 1); |
@@ -125,7 +125,7 @@ void MailThreadTest::testIndexInMixedOrder() | |||
125 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 125 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
126 | 126 | ||
127 | auto query = Sink::Query::threadLeaders(folder); | 127 | auto query = Sink::Query::threadLeaders(folder); |
128 | query.filter(SinkResource(mResourceInstanceIdentifier)); | 128 | query.resourceFilter(mResourceInstanceIdentifier); |
129 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); | 129 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); |
130 | 130 | ||
131 | Mail threadLeader; | 131 | Mail threadLeader; |
diff --git a/tests/modelinteractivitytest.cpp b/tests/modelinteractivitytest.cpp index 1ac0e2d..df0c772 100644 --- a/tests/modelinteractivitytest.cpp +++ b/tests/modelinteractivitytest.cpp | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "log.h" | 11 | #include "log.h" |
12 | #include "modelresult.h" | 12 | #include "modelresult.h" |
13 | #include "test.h" | 13 | #include "test.h" |
14 | #include "testutils.h" | ||
14 | 15 | ||
15 | static int blockingTime; | 16 | static int blockingTime; |
16 | 17 | ||
@@ -76,10 +77,10 @@ private slots: | |||
76 | } | 77 | } |
77 | 78 | ||
78 | Sink::Query query; | 79 | Sink::Query query; |
79 | query.resources << "sink.dummy.instance1"; | 80 | query.resourceFilter("sink.dummy.instance1"); |
80 | query.liveQuery = true; | 81 | query.liveQuery = true; |
81 | 82 | ||
82 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 83 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
83 | 84 | ||
84 | // Test | 85 | // Test |
85 | QTime time; | 86 | QTime time; |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index db17026..e978787 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -49,7 +49,7 @@ private slots: | |||
49 | { | 49 | { |
50 | // Test | 50 | // Test |
51 | Sink::Query query; | 51 | Sink::Query query; |
52 | query.resources << "foobar"; | 52 | query.resourceFilter("foobar"); |
53 | query.liveQuery = true; | 53 | query.liveQuery = true; |
54 | 54 | ||
55 | // 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 |
@@ -69,7 +69,7 @@ private slots: | |||
69 | 69 | ||
70 | // Test | 70 | // Test |
71 | Sink::Query query; | 71 | Sink::Query query; |
72 | query.resources << "sink.dummy.instance1"; | 72 | query.resourceFilter("sink.dummy.instance1"); |
73 | query.liveQuery = true; | 73 | query.liveQuery = true; |
74 | 74 | ||
75 | // 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 |
@@ -87,11 +87,11 @@ private slots: | |||
87 | 87 | ||
88 | // Test | 88 | // Test |
89 | Sink::Query query; | 89 | Sink::Query query; |
90 | query.resources << "sink.dummy.instance1"; | 90 | query.resourceFilter("sink.dummy.instance1"); |
91 | query.liveQuery = false; | 91 | query.liveQuery = false; |
92 | 92 | ||
93 | // Ensure all local data is processed | 93 | // Ensure all local data is processed |
94 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 94 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
95 | 95 | ||
96 | // 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 |
97 | auto model = Sink::Store::loadModel<Mail>(query); | 97 | auto model = Sink::Store::loadModel<Mail>(query); |
@@ -118,7 +118,7 @@ private slots: | |||
118 | 118 | ||
119 | // Test | 119 | // Test |
120 | Sink::Query query; | 120 | Sink::Query query; |
121 | query.resources << "sink.dummy.instance1"; | 121 | query.resourceFilter("sink.dummy.instance1"); |
122 | query.liveQuery = true; | 122 | query.liveQuery = true; |
123 | query.filter<Mail::Folder>("folder1"); | 123 | query.filter<Mail::Folder>("folder1"); |
124 | 124 | ||
@@ -150,7 +150,7 @@ private slots: | |||
150 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 150 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
151 | 151 | ||
152 | Sink::Query query; | 152 | Sink::Query query; |
153 | query.resources << "sink.dummy.instance1"; | 153 | query.resourceFilter("sink.dummy.instance1"); |
154 | 154 | ||
155 | // Ensure all local data is processed | 155 | // Ensure all local data is processed |
156 | Sink::Store::synchronize(query).exec().waitForFinished(); | 156 | Sink::Store::synchronize(query).exec().waitForFinished(); |
@@ -164,7 +164,7 @@ private slots: | |||
164 | 164 | ||
165 | // Test | 165 | // Test |
166 | Sink::Query query; | 166 | Sink::Query query; |
167 | query.filter(SinkResource("sink.dummy.instance1")); | 167 | query.resourceFilter("sink.dummy.instance1"); |
168 | query.filter(id); | 168 | query.filter(id); |
169 | auto model = Sink::Store::loadModel<Mail>(query); | 169 | auto model = Sink::Store::loadModel<Mail>(query); |
170 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 170 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -181,7 +181,7 @@ private slots: | |||
181 | 181 | ||
182 | // Test | 182 | // Test |
183 | Sink::Query query; | 183 | Sink::Query query; |
184 | query.resources << "sink.dummy.instance1"; | 184 | query.resourceFilter("sink.dummy.instance1"); |
185 | query.liveQuery = true; | 185 | query.liveQuery = true; |
186 | 186 | ||
187 | // 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 |
@@ -199,10 +199,10 @@ private slots: | |||
199 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); | 199 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); |
200 | 200 | ||
201 | Sink::Query query; | 201 | Sink::Query query; |
202 | query.resources << "sink.dummy.instance1"; | 202 | query.resourceFilter("sink.dummy.instance1"); |
203 | 203 | ||
204 | // Ensure all local data is processed | 204 | // Ensure all local data is processed |
205 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 205 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
206 | 206 | ||
207 | auto model = Sink::Store::loadModel<Folder>(query); | 207 | auto model = Sink::Store::loadModel<Folder>(query); |
208 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 208 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -218,11 +218,11 @@ private slots: | |||
218 | 218 | ||
219 | // Test | 219 | // Test |
220 | Sink::Query query; | 220 | Sink::Query query; |
221 | query.resources << "sink.dummy.instance1"; | 221 | query.resourceFilter("sink.dummy.instance1"); |
222 | query.parentProperty = "parent"; | 222 | query.parentProperty = "parent"; |
223 | 223 | ||
224 | // Ensure all local data is processed | 224 | // Ensure all local data is processed |
225 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 225 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
226 | 226 | ||
227 | // 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 |
228 | auto model = Sink::Store::loadModel<Folder>(query); | 228 | auto model = Sink::Store::loadModel<Folder>(query); |
@@ -252,12 +252,12 @@ private slots: | |||
252 | 252 | ||
253 | // Test | 253 | // Test |
254 | Sink::Query query; | 254 | Sink::Query query; |
255 | query.resources << "sink.dummy.instance1"; | 255 | query.resourceFilter("sink.dummy.instance1"); |
256 | query.liveQuery = false; | 256 | query.liveQuery = false; |
257 | query.filter<Mail::Uid>("test1"); | 257 | query.filter<Mail::Uid>("test1"); |
258 | 258 | ||
259 | // Ensure all local data is processed | 259 | // Ensure all local data is processed |
260 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 260 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
261 | 261 | ||
262 | // 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 |
263 | auto model = Sink::Store::loadModel<Mail>(query); | 263 | auto model = Sink::Store::loadModel<Mail>(query); |
@@ -274,10 +274,10 @@ private slots: | |||
274 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); | 274 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); |
275 | 275 | ||
276 | Sink::Query query; | 276 | Sink::Query query; |
277 | query.resources << "sink.dummy.instance1"; | 277 | query.resourceFilter("sink.dummy.instance1"); |
278 | 278 | ||
279 | // Ensure all local data is processed | 279 | // Ensure all local data is processed |
280 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 280 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
281 | 281 | ||
282 | auto model = Sink::Store::loadModel<Folder>(query); | 282 | auto model = Sink::Store::loadModel<Folder>(query); |
283 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 283 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -294,11 +294,11 @@ private slots: | |||
294 | 294 | ||
295 | // Test | 295 | // Test |
296 | Sink::Query query; | 296 | Sink::Query query; |
297 | query.resources << "sink.dummy.instance1"; | 297 | query.resourceFilter("sink.dummy.instance1"); |
298 | query.filter<Mail::Folder>(*folderEntity); | 298 | query.filter<Mail::Folder>(*folderEntity); |
299 | 299 | ||
300 | // Ensure all local data is processed | 300 | // Ensure all local data is processed |
301 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 301 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
302 | 302 | ||
303 | // 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 |
304 | auto model = Sink::Store::loadModel<Mail>(query); | 304 | auto model = Sink::Store::loadModel<Mail>(query); |
@@ -318,10 +318,10 @@ private slots: | |||
318 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); | 318 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); |
319 | 319 | ||
320 | Sink::Query query; | 320 | Sink::Query query; |
321 | query.resources << "sink.dummy.instance1"; | 321 | query.resourceFilter("sink.dummy.instance1"); |
322 | 322 | ||
323 | // Ensure all local data is processed | 323 | // Ensure all local data is processed |
324 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 324 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
325 | 325 | ||
326 | auto model = Sink::Store::loadModel<Folder>(query); | 326 | auto model = Sink::Store::loadModel<Folder>(query); |
327 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 327 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -348,12 +348,12 @@ private slots: | |||
348 | 348 | ||
349 | // Test | 349 | // Test |
350 | Sink::Query query; | 350 | Sink::Query query; |
351 | query.resources << "sink.dummy.instance1"; | 351 | query.resourceFilter("sink.dummy.instance1"); |
352 | query.filter<Mail::Folder>(*folderEntity); | 352 | query.filter<Mail::Folder>(*folderEntity); |
353 | query.filter<Mail::Uid>("test1"); | 353 | query.filter<Mail::Uid>("test1"); |
354 | 354 | ||
355 | // Ensure all local data is processed | 355 | // Ensure all local data is processed |
356 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 356 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
357 | 357 | ||
358 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 358 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
359 | auto model = Sink::Store::loadModel<Mail>(query); | 359 | auto model = Sink::Store::loadModel<Mail>(query); |
@@ -370,10 +370,10 @@ private slots: | |||
370 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); | 370 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); |
371 | 371 | ||
372 | Sink::Query query; | 372 | Sink::Query query; |
373 | query.resources << "sink.dummy.instance1"; | 373 | query.resourceFilter("sink.dummy.instance1"); |
374 | 374 | ||
375 | // Ensure all local data is processed | 375 | // Ensure all local data is processed |
376 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 376 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
377 | 377 | ||
378 | auto model = Sink::Store::loadModel<Folder>(query); | 378 | auto model = Sink::Store::loadModel<Folder>(query); |
379 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 379 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -408,14 +408,14 @@ private slots: | |||
408 | 408 | ||
409 | // Test | 409 | // Test |
410 | Sink::Query query; | 410 | Sink::Query query; |
411 | query.filter(SinkResource("sink.dummy.instance1")); | 411 | query.resourceFilter("sink.dummy.instance1"); |
412 | query.filter<Mail::Folder>(*folderEntity); | 412 | query.filter<Mail::Folder>(*folderEntity); |
413 | query.sort<Mail::Date>(); | 413 | query.sort<Mail::Date>(); |
414 | query.limit = 1; | 414 | query.limit = 1; |
415 | query.liveQuery = false; | 415 | query.liveQuery = false; |
416 | 416 | ||
417 | // Ensure all local data is processed | 417 | // Ensure all local data is processed |
418 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 418 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
419 | 419 | ||
420 | auto model = Sink::Store::loadModel<Mail>(query); | 420 | auto model = Sink::Store::loadModel<Mail>(query); |
421 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 421 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -485,7 +485,7 @@ private slots: | |||
485 | 485 | ||
486 | // Test | 486 | // Test |
487 | Sink::Query query; | 487 | Sink::Query query; |
488 | query.filter(account1); | 488 | query.resourceFilter<SinkResource::Account>(account1); |
489 | 489 | ||
490 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 490 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
491 | auto folders = Sink::Store::read<Folder>(query); | 491 | auto folders = Sink::Store::read<Folder>(query); |
@@ -517,7 +517,7 @@ private slots: | |||
517 | } | 517 | } |
518 | 518 | ||
519 | // Ensure all local data is processed | 519 | // Ensure all local data is processed |
520 | Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1").exec().waitForFinished(); | 520 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
521 | 521 | ||
522 | //Setup two folders with a mail each, ensure we only get the mail from the folder that matches the folder filter. | 522 | //Setup two folders with a mail each, ensure we only get the mail from the folder that matches the folder filter. |
523 | Query query; | 523 | Query query; |
@@ -538,12 +538,12 @@ private slots: | |||
538 | auto resource1 = ApplicationDomainType::createEntity<SinkResource>(); | 538 | auto resource1 = ApplicationDomainType::createEntity<SinkResource>(); |
539 | resource1.setResourceType("sink.dummy"); | 539 | resource1.setResourceType("sink.dummy"); |
540 | resource1.setCapabilities(QByteArrayList() << "cap1"); | 540 | resource1.setCapabilities(QByteArrayList() << "cap1"); |
541 | Store::create(resource1).exec().waitForFinished(); | 541 | VERIFYEXEC(Store::create(resource1)); |
542 | 542 | ||
543 | auto resource2 = ApplicationDomainType::createEntity<SinkResource>(); | 543 | auto resource2 = ApplicationDomainType::createEntity<SinkResource>(); |
544 | resource2.setCapabilities(QByteArrayList() << "cap2"); | 544 | resource2.setCapabilities(QByteArrayList() << "cap2"); |
545 | resource2.setResourceType("sink.dummy"); | 545 | resource2.setResourceType("sink.dummy"); |
546 | Store::create(resource2).exec().waitForFinished(); | 546 | VERIFYEXEC(Store::create(resource2)); |
547 | 547 | ||
548 | Folder folder1(resource1.identifier()); | 548 | Folder folder1(resource1.identifier()); |
549 | VERIFYEXEC(Sink::Store::create<Folder>(folder1)); | 549 | VERIFYEXEC(Sink::Store::create<Folder>(folder1)); |
@@ -552,7 +552,7 @@ private slots: | |||
552 | 552 | ||
553 | // Test | 553 | // Test |
554 | Sink::Query query; | 554 | Sink::Query query; |
555 | query.filter<Folder::Resource>(Sink::Query().containsFilter<SinkResource::Capabilities>("cap1")); | 555 | query.resourceContainsFilter<SinkResource::Capabilities>("cap1"); |
556 | 556 | ||
557 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 557 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
558 | auto folders = Sink::Store::read<Folder>(query); | 558 | auto folders = Sink::Store::read<Folder>(query); |