1 /* 2 * Copyright (c) 2022 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 16 #ifndef OHOS_DISTRIBUTEDDATA_SERVICE_TEST_DB_CHANGE_DATA_MOCK_H 17 #define OHOS_DISTRIBUTEDDATA_SERVICE_TEST_DB_CHANGE_DATA_MOCK_H 18 #include "kv_store_changed_data.h" 19 namespace OHOS { 20 namespace DistributedData { 21 using DBEntry = DistributedDB::Entry; 22 class DBChangeDataMock : public DistributedDB::KvStoreChangedData { 23 public: 24 enum Action : int32_t { 25 INSERT, 26 UPDATE, 27 DELETE, 28 BUTT 29 }; 30 DBChangeDataMock(const std::vector<DBEntry> &inserts, const std::vector<DBEntry> &updates, 31 const std::vector<DBEntry> &deletes); 32 const std::list<DBEntry> &GetEntriesInserted() const override; 33 const std::list<DBEntry> &GetEntriesUpdated() const override; 34 const std::list<DBEntry> &GetEntriesDeleted() const override; 35 bool IsCleared() const override; 36 37 bool AddEntry(DBEntry entry, int32_t type = DELETE); 38 39 private: 40 std::list<DBEntry> entries_[BUTT]; 41 }; 42 } // namespace DistributedData 43 } // namespace OHOS 44 #endif // OHOS_DISTRIBUTEDDATA_SERVICE_TEST_DB_CHANGE_DATA_MOCK_H 45