• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include <gmock/gmock.h>
17 #include "transaction.h"
18 
19 namespace OHOS::FileManagement::CloudDisk {
20 using namespace NativeRdb;
21 class TransactionMock : public NativeRdb::Transaction {
22 public:
23     MOCK_METHOD3(Update, std::pair<int32_t, int32_t>(const Row &row, const AbsRdbPredicates &predicates,
24                  Resolution resolution));
25     MOCK_METHOD5(Update, std::pair<int, int>(const std::string &table, const Row &row,
26                  const std::string &where, const Values &args, Resolution resolution));
27     MOCK_METHOD3(Insert, std::pair<int32_t, int64_t>(const std::string &table, const Row &row,
28                  Resolution resolution));
29     MOCK_METHOD0(Commit, int32_t());
30     MOCK_METHOD0(Rollback, int32_t());
31     MOCK_METHOD0(Close, int32_t());
32     MOCK_METHOD2(BatchInsert, std::pair<int32_t, int64_t>(const std::string &table, const Rows &rows));
33     MOCK_METHOD2(BatchInsert, std::pair<int32_t, int64_t>(const std::string &table, const RefRows &rows));
34     MOCK_METHOD3(BatchInsertWithConflictResolution, std::pair<int32_t, int64_t>(const std::string &table,
35                  const RefRows &rows, Resolution resolution));
36     MOCK_METHOD3(Delete, std::pair<int32_t, int32_t>(const std::string &table, const std::string &whereClause,
37                  const Values &args));
38     MOCK_METHOD1(Delete, std::pair<int32_t, int32_t>(const AbsRdbPredicates &predicates));
39     MOCK_METHOD3(QueryByStep, std::shared_ptr<ResultSet>(const std::string &sql, const Values &args, bool preCount));
40     MOCK_METHOD3(QueryByStep, std::shared_ptr<ResultSet>(const AbsRdbPredicates &predicates, const Fields &columns,
41                  bool preCount));
42     MOCK_METHOD2(Execute, std::pair<int32_t, ValueObject>(const std::string &sql, const Values &args));
43 };
44 }