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 #include "db_change_data_mock.h"
17 namespace OHOS {
18 namespace DistributedData {
DBChangeDataMock(const std::vector<DBEntry> & inserts,const std::vector<DBEntry> & updates,const std::vector<DBEntry> & deletes)19 DBChangeDataMock::DBChangeDataMock(const std::vector<DBEntry> &inserts, const std::vector<DBEntry> &updates,
20                                    const std::vector<DBEntry> &deletes)
21 {
22     for (auto &entry : inserts) {
23         entries_[INSERT].push_back(entry);
24     }
25     for (auto &entry : updates) {
26         entries_[UPDATE].push_back(entry);
27     }
28     for (auto &entry : deletes) {
29         entries_[DELETE].push_back(entry);
30     }
31 }
32 
GetEntriesInserted() const33 const std::list<DBEntry> &DBChangeDataMock::GetEntriesInserted() const
34 {
35     return entries_[INSERT];
36 }
37 
GetEntriesUpdated() const38 const std::list<DBEntry> &DBChangeDataMock::GetEntriesUpdated() const
39 {
40     return entries_[UPDATE];
41 }
42 
GetEntriesDeleted() const43 const std::list<DBEntry> &DBChangeDataMock::GetEntriesDeleted() const
44 {
45     return entries_[DELETE];
46 }
47 
IsCleared() const48 bool DBChangeDataMock::IsCleared() const
49 {
50     return false;
51 }
52 
AddEntry(DBEntry entry,int32_t type)53 bool DBChangeDataMock::AddEntry(DBEntry entry, int32_t type)
54 {
55     entries_[type].push_back(std::move(entry));
56     return false;
57 }
58 }
59 }