1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef OHOS_DISTRIBUTEDDATA_SERVICE_TEST_GENERAL_STORE_MOCK_H
16 #define OHOS_DISTRIBUTEDDATA_SERVICE_TEST_GENERAL_STORE_MOCK_H
17 
18 #include "cursor_mock.h"
19 #include "store/general_store.h"
20 namespace OHOS {
21 namespace DistributedData {
22 class GeneralStoreMock : public GeneralStore {
23 public:
24     int32_t Bind(Database &database, const std::map<uint32_t, BindInfo> &bindInfos,
25         const CloudConfig &config) override;
26     bool IsBound() override;
27     int32_t Execute(const std::string &table, const std::string &sql) override;
28     int32_t SetDistributedTables(
29         const std::vector<std::string> &tables, int32_t type, const std::vector<Reference> &references) override;
30     int32_t SetTrackerTable(const std::string &tableName, const std::set<std::string> &trackerColNames,
31         const std::string &extendColName, bool isForceUpgrade = false) override;
32     int32_t Insert(const std::string &table, VBuckets &&values) override;
33     int32_t Update(const std::string &table, const std::string &setSql, Values &&values, const std::string &whereSql,
34         Values &&conditions) override;
35     int32_t Replace(const std::string &table, VBucket &&value) override;
36     int32_t Delete(const std::string &table, const std::string &sql, Values &&args) override;
37     std::pair<int32_t, std::shared_ptr<Cursor>> Query(const std::string &table, const std::string &sql,
38         Values &&args) override;
39     std::pair<int32_t, std::shared_ptr<Cursor>> Query(const std::string &table, GenQuery &query) override;
40     std::pair<int32_t, int32_t> Sync(const Devices &devices, GenQuery &query, DetailAsync async,
41         const SyncParam &syncParm) override;
42     std::pair<int32_t, std::shared_ptr<Cursor>> PreSharing(GenQuery &query) override;
43     int32_t Clean(const std::vector<std::string> &devices, int32_t mode, const std::string &tableName) override;
44     int32_t Watch(int32_t origin, Watcher &watcher) override;
45     int32_t Unwatch(int32_t origin, Watcher &watcher) override;
46     int32_t RegisterDetailProgressObserver(DetailAsync async) override;
47     int32_t UnregisterDetailProgressObserver() override;
48     int32_t Close(bool isForce) override;
49     int32_t AddRef() override;
50     int32_t Release() override;
51     int32_t BindSnapshots(std::shared_ptr<std::map<std::string, std::shared_ptr<Snapshot>>> bindAssets) override;
52     int32_t MergeMigratedData(const std::string &tableName, VBuckets &&values) override;
53     int32_t CleanTrackerData(const std::string &tableName, int64_t cursor) override;
54     std::vector<std::string> GetWaterVersion(const std::string &deviceId) override;
55     void SetExecutor(std::shared_ptr<Executor> executor) override;
56     void MakeCursor(const std::map<std::string, Value> &entry);
57     std::pair<int32_t, uint32_t> LockCloudDB() override;
58     int32_t UnLockCloudDB() override;
59 
60 private:
61     std::shared_ptr<Cursor> cursor_ = nullptr;
62 };
63 } // namespace DistributedData
64 } // namespace OHOS
65 #endif