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 "cloud_file_utils.h"
17 #include "cloud_status.h"
18 #include "clouddisk_rdb_utils.h"
19 #include "clouddisk_rdbstore.h"
20 #include "dfs_error.h"
21 #include "rdb_assistant.h"
22 #include "result_set_mock.h"
23 #include <gmock/gmock.h>
24 #include <gtest/gtest.h>
25 #include <memory>
26 
27 namespace OHOS::FileManagement::CloudDisk::Test {
28 using namespace testing;
29 using namespace testing::ext;
30 using namespace std;
31 using namespace NativeRdb;
32 
33 static const string BUNDLE_NAME = "com.ohos.photos";
34 static const int32_t USER_ID = 100;
35 class CloudDiskRdbStoreTest : public testing::Test {
36 public:
37     static void SetUpTestCase(void);
38     static void TearDownTestCase(void);
39     void SetUp();
40     void TearDown();
41     static inline shared_ptr<CloudDiskRdbStore> clouddiskrdbStore_ = nullptr;
42     static inline shared_ptr<AssistantMock> insMock = nullptr;
43 };
44 
SetUpTestCase(void)45 void CloudDiskRdbStoreTest::SetUpTestCase(void)
46 {
47     GTEST_LOG_(INFO) << "SetUpTestCase";
48     insMock = make_shared<AssistantMock>();
49     Assistant::ins = insMock;
50     clouddiskrdbStore_ = make_shared<CloudDiskRdbStore>(BUNDLE_NAME, USER_ID);
51 }
52 
TearDownTestCase(void)53 void CloudDiskRdbStoreTest::TearDownTestCase(void)
54 {
55     Assistant::ins = nullptr;
56     insMock = nullptr;
57     clouddiskrdbStore_ = nullptr;
58     GTEST_LOG_(INFO) << "TearDownTestCase";
59 }
60 
SetUp(void)61 void CloudDiskRdbStoreTest::SetUp(void)
62 {
63     GTEST_LOG_(INFO) << "SetUp";
64 }
65 
TearDown(void)66 void CloudDiskRdbStoreTest::TearDown(void)
67 {
68     GTEST_LOG_(INFO) << "TearDown";
69 }
70 
71 /**
72  * @tc.name: ReBuildDatabase
73  * @tc.desc: Verify the CloudDiskRdbStore::ReBuildDatabase function
74  * @tc.type: FUNC
75  * @tc.require: SR000HRKKA
76  */
HWTEST_F(CloudDiskRdbStoreTest, ReBuildDatabaseTest1, TestSize.Level1)77 HWTEST_F(CloudDiskRdbStoreTest, ReBuildDatabaseTest1, TestSize.Level1)
78 {
79     string databasePath = "/data";
80     auto rdb = make_shared<RdbStoreMock>();
81     clouddiskrdbStore_->rdbStore_ = rdb;
82     EXPECT_CALL(*insMock, DeleteRdbStore(_)).WillOnce(Return(E_RDB));
83 
84     int32_t ret = clouddiskrdbStore_->ReBuildDatabase(databasePath);
85     EXPECT_EQ(ret, E_RDB);
86 }
87 
88 /**
89  * @tc.name: ReBuildDatabase
90  * @tc.desc: Verify the CloudDiskRdbStore::ReBuildDatabase function
91  * @tc.type: FUNC
92  * @tc.require: SR000HRKKA
93  */
HWTEST_F(CloudDiskRdbStoreTest, ReBuildDatabaseTest2, TestSize.Level1)94 HWTEST_F(CloudDiskRdbStoreTest, ReBuildDatabaseTest2, TestSize.Level1)
95 {
96     string databasePath = "/data";
97     auto rdb = make_shared<RdbStoreMock>();
98     clouddiskrdbStore_->rdbStore_ = rdb;
99     EXPECT_CALL(*insMock, DeleteRdbStore(_)).WillOnce(Return(E_OK));
100     EXPECT_CALL(*insMock, GetRdbStore(_, _, _, _)).WillOnce(Return(nullptr));
101 
102     int32_t ret = clouddiskrdbStore_->ReBuildDatabase(databasePath);
103     EXPECT_EQ(ret, E_OK);
104 }
105 
106 /**
107  * @tc.name: ReBuildDatabase
108  * @tc.desc: Verify the CloudDiskRdbStore::ReBuildDatabase function
109  * @tc.type: FUNC
110  * @tc.require: SR000HRKKA
111  */
HWTEST_F(CloudDiskRdbStoreTest, ReBuildDatabaseTest3, TestSize.Level1)112 HWTEST_F(CloudDiskRdbStoreTest, ReBuildDatabaseTest3, TestSize.Level1)
113 {
114     string databasePath = "/data";
115     auto rdb = make_shared<RdbStoreMock>();
116     clouddiskrdbStore_->rdbStore_ = rdb;
117     EXPECT_CALL(*insMock, DeleteRdbStore(_)).WillOnce(Return(E_OK));
118     EXPECT_CALL(*insMock, GetRdbStore(_, _, _, _)).WillOnce(Return(rdb));
119 
120     int32_t ret = clouddiskrdbStore_->ReBuildDatabase(databasePath);
121     EXPECT_EQ(ret, E_OK);
122 }
123 
124 /**
125  * @tc.name: RdbInit
126  * @tc.desc: Verify the CloudDiskRdbStore::RdbInit function
127  * @tc.type: FUNC
128  * @tc.require: SR000HRKKA
129  */
HWTEST_F(CloudDiskRdbStoreTest, RdbInitTest1, TestSize.Level1)130 HWTEST_F(CloudDiskRdbStoreTest, RdbInitTest1, TestSize.Level1)
131 {
132     auto rdb = make_shared<RdbStoreMock>();
133     clouddiskrdbStore_->rdbStore_ = rdb;
134     EXPECT_CALL(*insMock, GetRdbStore(_, _, _, _)).WillOnce(Return(nullptr));
135 
136     int32_t ret = clouddiskrdbStore_->RdbInit();
137     EXPECT_EQ(ret, E_OK);
138 }
139 
140 /**
141  * @tc.name: RdbInit
142  * @tc.desc: Verify the CloudDiskRdbStore::RdbInit function
143  * @tc.type: FUNC
144  * @tc.require: SR000HRKKA
145  */
HWTEST_F(CloudDiskRdbStoreTest, RdbInitTest2, TestSize.Level1)146 HWTEST_F(CloudDiskRdbStoreTest, RdbInitTest2, TestSize.Level1)
147 {
148     auto rdb = make_shared<RdbStoreMock>();
149     clouddiskrdbStore_->rdbStore_ = rdb;
150     EXPECT_CALL(*insMock, GetRdbStore(_, _, _, _)).WillOnce(Return(rdb));
151 
152     int32_t ret = clouddiskrdbStore_->RdbInit();
153     EXPECT_EQ(ret, E_OK);
154 }
155 
156 /**
157  * @tc.name: LookUp
158  * @tc.desc: Verify the CloudDiskRdbStore::LookUp function
159  * @tc.type: FUNC
160  * @tc.require: SR000HRKKA
161  */
HWTEST_F(CloudDiskRdbStoreTest, LookUpTest1, TestSize.Level1)162 HWTEST_F(CloudDiskRdbStoreTest, LookUpTest1, TestSize.Level1)
163 {
164     const std::string parentCloudId = "";
165     const std::string fileName = "";
166     CloudDiskFileInfo info;
167     auto rdb = make_shared<RdbStoreMock>();
168     clouddiskrdbStore_->rdbStore_ = rdb;
169     int32_t ret = clouddiskrdbStore_->LookUp(parentCloudId, fileName, info);
170     EXPECT_EQ(ret, E_INVAL_ARG);
171 }
172 
173 /**
174  * @tc.name: LookUp
175  * @tc.desc: Verify the CloudDiskRdbStore::LookUp function
176  * @tc.type: FUNC
177  * @tc.require: SR000HRKKA
178  */
HWTEST_F(CloudDiskRdbStoreTest, LookUpTest2, TestSize.Level1)179 HWTEST_F(CloudDiskRdbStoreTest, LookUpTest2, TestSize.Level1)
180 {
181     const std::string parentCloudId = "rootId";
182     const std::string fileName = "test";
183     CloudDiskFileInfo info;
184     info.name = "mock";
185     auto rdb = make_shared<RdbStoreMock>();
186     clouddiskrdbStore_->rdbStore_ = rdb;
187     int32_t ret = clouddiskrdbStore_->LookUp(parentCloudId, fileName, info);
188     EXPECT_EQ(ret, E_RDB);
189 }
190 
191 /**
192  * @tc.name: LookUp
193  * @tc.desc: Verify the CloudDiskRdbStore::LookUp function
194  * @tc.type: FUNC
195  * @tc.require: SR000HRKKA
196  */
HWTEST_F(CloudDiskRdbStoreTest, LookUpTest3, TestSize.Level1)197 HWTEST_F(CloudDiskRdbStoreTest, LookUpTest3, TestSize.Level1)
198 {
199     const std::string parentCloudId = "rootId";
200     const std::string fileName = "test";
201     CloudDiskFileInfo info;
202     auto rdb = make_shared<RdbStoreMock>();
203     clouddiskrdbStore_->rdbStore_ = rdb;
204     int32_t ret = clouddiskrdbStore_->LookUp(parentCloudId, fileName, info);
205     EXPECT_EQ(ret, E_OK);
206 }
207 
208 /**
209  * @tc.name: GetAttr
210  * @tc.desc: Verify the CloudDiskRdbStore::GetAttr function
211  * @tc.type: FUNC
212  * @tc.require: SR000HRKKA
213  */
HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest1, TestSize.Level1)214 HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest1, TestSize.Level1)
215 {
216     const std::string cloudId = "";
217     const std::string fileName = "test";
218     CloudDiskFileInfo info;
219     auto rdb = make_shared<RdbStoreMock>();
220     clouddiskrdbStore_->rdbStore_ = rdb;
221     int32_t ret = clouddiskrdbStore_->GetAttr(cloudId, info);
222     EXPECT_EQ(ret, E_INVAL_ARG);
223 }
224 
225 /**
226  * @tc.name: GetAttr
227  * @tc.desc: Verify the CloudDiskRdbStore::GetAttr function
228  * @tc.type: FUNC
229  * @tc.require: SR000HRKKA
230  */
HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest2, TestSize.Level1)231 HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest2, TestSize.Level1)
232 {
233     const std::string cloudId = "100";
234     CloudDiskFileInfo info;
235     info.name = "mock";
236     auto rdb = make_shared<RdbStoreMock>();
237     clouddiskrdbStore_->rdbStore_ = rdb;
238     int32_t ret = clouddiskrdbStore_->GetAttr(cloudId, info);
239     EXPECT_EQ(ret, E_RDB);
240 }
241 
242 /**
243  * @tc.name: GetAttr
244  * @tc.desc: Verify the CloudDiskRdbStore::GetAttr function
245  * @tc.type: FUNC
246  * @tc.require: SR000HRKKA
247  */
HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest3, TestSize.Level1)248 HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest3, TestSize.Level1)
249 {
250     const std::string cloudId = "100";
251     CloudDiskFileInfo info;
252     auto rdb = make_shared<RdbStoreMock>();
253     clouddiskrdbStore_->rdbStore_ = rdb;
254     int32_t ret = clouddiskrdbStore_->GetAttr(cloudId, info);
255     EXPECT_EQ(ret, E_OK);
256 }
257 
258 /**
259  * @tc.name: SetAttr
260  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
261  * @tc.type: FUNC
262  * @tc.require: SR000HRKKA
263  */
HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest1, TestSize.Level1)264 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest1, TestSize.Level1)
265 {
266     const std::string fileName = "Test";
267     const std::string parentCloudId = "100";
268     const std::string cloudId = "";
269     const unsigned long long size = 0;
270     auto rdb = make_shared<RdbStoreMock>();
271     clouddiskrdbStore_->rdbStore_ = rdb;
272     int32_t ret = clouddiskrdbStore_->SetAttr(fileName, parentCloudId, cloudId, size);
273     EXPECT_EQ(ret, E_INVAL_ARG);
274 }
275 
276 /**
277  * @tc.name: SetAttr
278  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
279  * @tc.type: FUNC
280  * @tc.require: SR000HRKKA
281  */
HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest2, TestSize.Level1)282 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest2, TestSize.Level1)
283 {
284     const std::string fileName = "Test";
285     const std::string parentCloudId = "100";
286     const std::string cloudId = "rootId";
287     const unsigned long long size = 0;
288     auto rdb = make_shared<RdbStoreMock>();
289     clouddiskrdbStore_->rdbStore_ = rdb;
290     int32_t ret = clouddiskrdbStore_->SetAttr(fileName, parentCloudId, cloudId, size);
291     EXPECT_EQ(ret, E_INVAL_ARG);
292 }
293 
294 /**
295  * @tc.name: SetAttr
296  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
297  * @tc.type: FUNC
298  * @tc.require: SR000HRKKA
299  */
HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest3, TestSize.Level1)300 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest3, TestSize.Level1)
301 {
302     const std::string fileName = "mock";
303     const std::string parentCloudId = "100";
304     const std::string cloudId = "100";
305     const unsigned long long size = 0;
306     auto rdb = make_shared<RdbStoreMock>();
307     clouddiskrdbStore_->rdbStore_ = rdb;
308     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_RDB));
309 
310     int32_t ret = clouddiskrdbStore_->SetAttr(fileName, parentCloudId, cloudId, size);
311     EXPECT_EQ(ret, E_RDB);
312 }
313 
314 /**
315  * @tc.name: SetAttr
316  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
317  * @tc.type: FUNC
318  * @tc.require: SR000HRKKA
319  */
HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest4, TestSize.Level1)320 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest4, TestSize.Level1)
321 {
322     const std::string fileName = "mock";
323     const std::string parentCloudId = "100";
324     const std::string cloudId = "100";
325     const unsigned long long size = 0;
326     auto rdb = make_shared<RdbStoreMock>();
327     clouddiskrdbStore_->rdbStore_ = rdb;
328     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
329 
330     int32_t ret = clouddiskrdbStore_->SetAttr(fileName, parentCloudId, cloudId, size);
331     EXPECT_EQ(ret, E_RDB);
332 }
333 
334 /**
335  * @tc.name: SetAttr
336  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
337  * @tc.type: FUNC
338  * @tc.require: SR000HRKKA
339  */
HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest5, TestSize.Level1)340 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest5, TestSize.Level1)
341 {
342     const std::string fileName = "test";
343     const std::string parentCloudId = "100";
344     const std::string cloudId = "100";
345     const unsigned long long size = 0;
346     auto rdb = make_shared<RdbStoreMock>();
347     clouddiskrdbStore_->rdbStore_ = rdb;
348     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
349 
350     int32_t ret = clouddiskrdbStore_->SetAttr(fileName, parentCloudId, cloudId, size);
351     EXPECT_EQ(ret, E_OK);
352 }
353 
354 /**
355  * @tc.name: ReadDir
356  * @tc.desc: Verify the CloudDiskRdbStore::ReadDir function
357  * @tc.type: FUNC
358  * @tc.require: SR000HRKKA
359  */
HWTEST_F(CloudDiskRdbStoreTest, ReadDirTest1, TestSize.Level1)360 HWTEST_F(CloudDiskRdbStoreTest, ReadDirTest1, TestSize.Level1)
361 {
362     const std::string cloudId = "rootId";
363     vector<CloudDiskFileInfo> infos;
364     auto rdb = make_shared<RdbStoreMock>();
365     clouddiskrdbStore_->rdbStore_ = rdb;
366     int32_t ret = clouddiskrdbStore_->ReadDir(cloudId, infos);
367     EXPECT_EQ(ret, E_RDB);
368 }
369 
370 /**
371  * @tc.name: ReadDir
372  * @tc.desc: Verify the CloudDiskRdbStore::ReadDir function
373  * @tc.type: FUNC
374  * @tc.require: SR000HRKKA
375  */
HWTEST_F(CloudDiskRdbStoreTest, ReadDirTest2, TestSize.Level1)376 HWTEST_F(CloudDiskRdbStoreTest, ReadDirTest2, TestSize.Level1)
377 {
378     const std::string cloudId = "rootId";
379     CloudDiskFileInfo info;
380     vector<CloudDiskFileInfo> infos;
381     infos.push_back(info);
382     auto rdb = make_shared<RdbStoreMock>();
383     clouddiskrdbStore_->rdbStore_ = rdb;
384     int32_t ret = clouddiskrdbStore_->ReadDir(cloudId, infos);
385     EXPECT_EQ(ret, E_OK);
386 }
387 
388 /**
389  * @tc.name: Create
390  * @tc.desc: Verify the CloudDiskRdbStore::Create function
391  * @tc.type: FUNC
392  * @tc.require: SR000HRKKA
393  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest1, TestSize.Level1)394 HWTEST_F(CloudDiskRdbStoreTest, CreateTest1, TestSize.Level1)
395 {
396     const std::string cloudId = "rootId";
397     const std::string parentCloudId = "100";
398     const std::string fileName = "";
399     bool noNeedUpload = false;
400     auto rdb = make_shared<RdbStoreMock>();
401     clouddiskrdbStore_->rdbStore_ = rdb;
402     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
403     EXPECT_EQ(ret, EINVAL);
404 }
405 
406 /**
407  * @tc.name: Create
408  * @tc.desc: Verify the CloudDiskRdbStore::Create function
409  * @tc.type: FUNC
410  * @tc.require: SR000HRKKA
411  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest2, TestSize.Level1)412 HWTEST_F(CloudDiskRdbStoreTest, CreateTest2, TestSize.Level1)
413 {
414     const std::string cloudId = "rootId";
415     const std::string parentCloudId = "100";
416     const std::string fileName = "<|>";
417     bool noNeedUpload = false;
418     auto rdb = make_shared<RdbStoreMock>();
419     clouddiskrdbStore_->rdbStore_ = rdb;
420     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
421     EXPECT_EQ(ret, EINVAL);
422 }
423 
424 /**
425  * @tc.name: Create
426  * @tc.desc: Verify the CloudDiskRdbStore::Create function
427  * @tc.type: FUNC
428  * @tc.require: SR000HRKKA
429  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest3, TestSize.Level1)430 HWTEST_F(CloudDiskRdbStoreTest, CreateTest3, TestSize.Level1)
431 {
432     const std::string cloudId = "rootId";
433     const std::string parentCloudId = "100";
434     const std::string fileName = " test";
435     bool noNeedUpload = false;
436     auto rdb = make_shared<RdbStoreMock>();
437     clouddiskrdbStore_->rdbStore_ = rdb;
438     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
439     EXPECT_EQ(ret, EINVAL);
440 }
441 
442 /**
443  * @tc.name: Create
444  * @tc.desc: Verify the CloudDiskRdbStore::Create function
445  * @tc.type: FUNC
446  * @tc.require: SR000HRKKA
447  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest4, TestSize.Level1)448 HWTEST_F(CloudDiskRdbStoreTest, CreateTest4, TestSize.Level1)
449 {
450     const std::string cloudId = "";
451     const std::string parentCloudId = "";
452     const std::string fileName = "test";
453     bool noNeedUpload = false;
454     auto rdb = make_shared<RdbStoreMock>();
455     clouddiskrdbStore_->rdbStore_ = rdb;
456     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
457     EXPECT_EQ(ret, E_INVAL_ARG);
458 }
459 
460 /**
461  * @tc.name: Create
462  * @tc.desc: Verify the CloudDiskRdbStore::Create function
463  * @tc.type: FUNC
464  * @tc.require: SR000HRKKA
465  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest5, TestSize.Level1)466 HWTEST_F(CloudDiskRdbStoreTest, CreateTest5, TestSize.Level1)
467 {
468     const std::string cloudId = "rootId";
469     const std::string parentCloudId = "100";
470     const std::string fileName = "test";
471     bool noNeedUpload = false;
472     clouddiskrdbStore_->userId_ = 0;
473     auto rdb = make_shared<RdbStoreMock>();
474     clouddiskrdbStore_->rdbStore_ = rdb;
475     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
476     EXPECT_EQ(ret, E_PATH);
477 }
478 
479 /**
480  * @tc.name: Create
481  * @tc.desc: Verify the CloudDiskRdbStore::Create function
482  * @tc.type: FUNC
483  * @tc.require: SR000HRKKA
484  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest6, TestSize.Level1)485 HWTEST_F(CloudDiskRdbStoreTest, CreateTest6, TestSize.Level1)
486 {
487     const std::string cloudId = "rootId";
488     const std::string parentCloudId = "100";
489     const std::string fileName = "test";
490     bool noNeedUpload = true;
491     clouddiskrdbStore_->userId_ = 1;
492     auto rdb = make_shared<RdbStoreMock>();
493     clouddiskrdbStore_->rdbStore_ = rdb;
494     EXPECT_CALL(*rdb, Insert(_, _, _)).WillOnce(Return(E_RDB));
495 
496     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
497     EXPECT_EQ(ret, E_RDB);
498 }
499 
500 /**
501  * @tc.name: Create
502  * @tc.desc: Verify the CloudDiskRdbStore::Create function
503  * @tc.type: FUNC
504  * @tc.require: SR000HRKKA
505  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest7, TestSize.Level1)506 HWTEST_F(CloudDiskRdbStoreTest, CreateTest7, TestSize.Level1)
507 {
508     const std::string cloudId = "rootId";
509     const std::string parentCloudId = "100";
510     const std::string fileName = "mock";
511     bool noNeedUpload = true;
512     clouddiskrdbStore_->userId_ = 1;
513     auto rdb = make_shared<RdbStoreMock>();
514     clouddiskrdbStore_->rdbStore_ = rdb;
515     EXPECT_CALL(*rdb, Insert(_, _, _)).WillOnce(Return(E_OK));
516 
517     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
518     EXPECT_EQ(ret, E_RDB);
519 }
520 
521 /**
522  * @tc.name: Create
523  * @tc.desc: Verify the CloudDiskRdbStore::Create function
524  * @tc.type: FUNC
525  * @tc.require: SR000HRKKA
526  */
HWTEST_F(CloudDiskRdbStoreTest, CreateTest8, TestSize.Level1)527 HWTEST_F(CloudDiskRdbStoreTest, CreateTest8, TestSize.Level1)
528 {
529     const std::string cloudId = "rootId";
530     const std::string parentCloudId = "100";
531     const std::string fileName = "test";
532     bool noNeedUpload = true;
533     clouddiskrdbStore_->userId_ = 1;
534     auto rdb = make_shared<RdbStoreMock>();
535     clouddiskrdbStore_->rdbStore_ = rdb;
536     EXPECT_CALL(*rdb, Insert(_, _, _)).WillOnce(Return(E_OK));
537 
538     int32_t ret = clouddiskrdbStore_->Create(cloudId, parentCloudId, fileName, noNeedUpload);
539     EXPECT_EQ(ret, E_OK);
540 }
541 
542 /**
543  * @tc.name: MkDir
544  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
545  * @tc.type: FUNC
546  * @tc.require: SR000HRKKA
547  */
HWTEST_F(CloudDiskRdbStoreTest, MkDirTest1, TestSize.Level1)548 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest1, TestSize.Level1)
549 {
550     const std::string cloudId = "100";
551     const std::string parentCloudId = "100";
552     const std::string directoryName = "";
553     bool noNeedUpload = false;
554     auto rdb = make_shared<RdbStoreMock>();
555     clouddiskrdbStore_->rdbStore_ = rdb;
556     int32_t ret = clouddiskrdbStore_->MkDir(cloudId, parentCloudId, directoryName, noNeedUpload);
557     EXPECT_EQ(ret, EINVAL);
558 }
559 
560 /**
561  * @tc.name: MkDir
562  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
563  * @tc.type: FUNC
564  * @tc.require: SR000HRKKA
565  */
HWTEST_F(CloudDiskRdbStoreTest, MkDirTest2, TestSize.Level1)566 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest2, TestSize.Level1)
567 {
568     const std::string cloudId = "100";
569     const std::string parentCloudId = "100";
570     const std::string directoryName = ".trash";
571     bool noNeedUpload = false;
572     auto rdb = make_shared<RdbStoreMock>();
573     clouddiskrdbStore_->rdbStore_ = rdb;
574     int32_t ret = clouddiskrdbStore_->MkDir(cloudId, parentCloudId, directoryName, noNeedUpload);
575     EXPECT_EQ(ret, EINVAL);
576 }
577 
578 /**
579  * @tc.name: MkDir
580  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
581  * @tc.type: FUNC
582  * @tc.require: SR000HRKKA
583  */
HWTEST_F(CloudDiskRdbStoreTest, MkDirTest3, TestSize.Level1)584 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest3, TestSize.Level1)
585 {
586     const std::string cloudId = "";
587     const std::string parentCloudId = "";
588     const std::string directoryName = "test";
589     bool noNeedUpload = false;
590     auto rdb = make_shared<RdbStoreMock>();
591     clouddiskrdbStore_->rdbStore_ = rdb;
592     int32_t ret = clouddiskrdbStore_->MkDir(cloudId, parentCloudId, directoryName, noNeedUpload);
593     EXPECT_EQ(ret, E_INVAL_ARG);
594 }
595 
596 /**
597  * @tc.name: MkDir
598  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
599  * @tc.type: FUNC
600  * @tc.require: SR000HRKKA
601  */
HWTEST_F(CloudDiskRdbStoreTest, MkDirTest4, TestSize.Level1)602 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest4, TestSize.Level1)
603 {
604     const std::string cloudId = "100";
605     const std::string parentCloudId = "100";
606     const std::string directoryName = "mock";
607     bool noNeedUpload = false;
608     auto rdb = make_shared<RdbStoreMock>();
609     clouddiskrdbStore_->rdbStore_ = rdb;
610     EXPECT_CALL(*rdb, Insert(_, _, _)).WillOnce(Return(E_RDB));
611 
612     int32_t ret = clouddiskrdbStore_->MkDir(cloudId, parentCloudId, directoryName, noNeedUpload);
613     EXPECT_EQ(ret, E_RDB);
614 }
615 
616 /**
617  * @tc.name: MkDir
618  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
619  * @tc.type: FUNC
620  * @tc.require: SR000HRKKA
621  */
HWTEST_F(CloudDiskRdbStoreTest, MkDirTest5, TestSize.Level1)622 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest5, TestSize.Level1)
623 {
624     const std::string cloudId = "100";
625     const std::string parentCloudId = "100";
626     const std::string directoryName = "mock";
627     bool noNeedUpload = true;
628     auto rdb = make_shared<RdbStoreMock>();
629     clouddiskrdbStore_->rdbStore_ = rdb;
630     EXPECT_CALL(*rdb, Insert(_, _, _)).WillOnce(Return(E_OK));
631 
632     int32_t ret = clouddiskrdbStore_->MkDir(cloudId, parentCloudId, directoryName, noNeedUpload);
633     EXPECT_EQ(ret, E_RDB);
634 }
635 
636 /**
637  * @tc.name: MkDir
638  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
639  * @tc.type: FUNC
640  * @tc.require: SR000HRKKA
641  */
HWTEST_F(CloudDiskRdbStoreTest, MkDirTest6, TestSize.Level1)642 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest6, TestSize.Level1)
643 {
644     const std::string cloudId = "100";
645     const std::string parentCloudId = "100";
646     const std::string directoryName = "test";
647     bool noNeedUpload = true;
648     auto rdb = make_shared<RdbStoreMock>();
649     clouddiskrdbStore_->rdbStore_ = rdb;
650     EXPECT_CALL(*rdb, Insert(_, _, _)).WillOnce(Return(E_OK));
651 
652     int32_t ret = clouddiskrdbStore_->MkDir(cloudId, parentCloudId, directoryName, noNeedUpload);
653     EXPECT_EQ(ret, E_OK);
654 }
655 
656 /**
657  * @tc.name: Write
658  * @tc.desc: Verify the CloudDiskRdbStore::Write function
659  * @tc.type: FUNC
660  * @tc.require: SR000HRKKA
661  */
HWTEST_F(CloudDiskRdbStoreTest, WriteTest1, TestSize.Level1)662 HWTEST_F(CloudDiskRdbStoreTest, WriteTest1, TestSize.Level1)
663 {
664     const std::string cloudId = "";
665     const std::string parentCloudId = "100";
666     const std::string fileName = "file";
667     auto rdb = make_shared<RdbStoreMock>();
668     clouddiskrdbStore_->rdbStore_ = rdb;
669     int32_t ret = clouddiskrdbStore_->Write(fileName, parentCloudId, cloudId);
670     EXPECT_EQ(ret, E_INVAL_ARG);
671 }
672 
673 /**
674  * @tc.name: Write
675  * @tc.desc: Verify the CloudDiskRdbStore::Write function
676  * @tc.type: FUNC
677  * @tc.require: SR000HRKKA
678  */
HWTEST_F(CloudDiskRdbStoreTest, WriteTest2, TestSize.Level1)679 HWTEST_F(CloudDiskRdbStoreTest, WriteTest2, TestSize.Level1)
680 {
681     const std::string cloudId = "100";
682     const std::string fileName = "file";
683     const std::string parentCloudId = "rootId";
684     auto rdb = make_shared<RdbStoreMock>();
685     clouddiskrdbStore_->rdbStore_ = rdb;
686     clouddiskrdbStore_->userId_ = 0;
687     int32_t ret = clouddiskrdbStore_->Write(fileName, parentCloudId, cloudId);
688     EXPECT_EQ(ret, E_PATH);
689 }
690 
691 /**
692  * @tc.name: Write
693  * @tc.desc: Verify the CloudDiskRdbStore::Write function
694  * @tc.type: FUNC
695  * @tc.require: SR000HRKKA
696  */
HWTEST_F(CloudDiskRdbStoreTest, WriteTest3, TestSize.Level1)697 HWTEST_F(CloudDiskRdbStoreTest, WriteTest3, TestSize.Level1)
698 {
699     const std::string cloudId = "100";
700     const std::string fileName = "file";
701     const std::string parentCloudId = "rootId";
702     auto rdb = make_shared<RdbStoreMock>();
703     clouddiskrdbStore_->rdbStore_ = rdb;
704     clouddiskrdbStore_->userId_ = 1;
705     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_RDB));
706 
707     int32_t ret = clouddiskrdbStore_->Write(fileName, parentCloudId, cloudId);
708     EXPECT_EQ(ret, E_RDB);
709 }
710 
711 /**
712  * @tc.name: Write
713  * @tc.desc: Verify the CloudDiskRdbStore::Write function
714  * @tc.type: FUNC
715  * @tc.require: SR000HRKKA
716  */
HWTEST_F(CloudDiskRdbStoreTest, WriteTest4, TestSize.Level1)717 HWTEST_F(CloudDiskRdbStoreTest, WriteTest4, TestSize.Level1)
718 {
719     const std::string cloudId = "100";
720     const std::string fileName = "mock";
721     const std::string parentCloudId = "rootId";
722     auto rdb = make_shared<RdbStoreMock>();
723     clouddiskrdbStore_->rdbStore_ = rdb;
724     clouddiskrdbStore_->userId_ = 1;
725     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
726 
727     int32_t ret = clouddiskrdbStore_->Write(fileName, parentCloudId, cloudId);
728     EXPECT_EQ(ret, E_RDB);
729 }
730 
731 /**
732  * @tc.name: Write
733  * @tc.desc: Verify the CloudDiskRdbStore::Write function
734  * @tc.type: FUNC
735  * @tc.require: SR000HRKKA
736  */
HWTEST_F(CloudDiskRdbStoreTest, WriteTest5, TestSize.Level1)737 HWTEST_F(CloudDiskRdbStoreTest, WriteTest5, TestSize.Level1)
738 {
739     const std::string cloudId = "100";
740     const std::string fileName = "test";
741     const std::string parentCloudId = "rootId";
742     auto rdb = make_shared<RdbStoreMock>();
743     clouddiskrdbStore_->rdbStore_ = rdb;
744     clouddiskrdbStore_->userId_ = 1;
745     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
746 
747     int32_t ret = clouddiskrdbStore_->Write(fileName, parentCloudId, cloudId);
748     EXPECT_EQ(ret, E_OK);
749 }
750 
751 /**
752  * @tc.name: LocationSetXattr
753  * @tc.desc: Verify the CloudDiskRdbStore::LocationSetXattr function
754  * @tc.type: FUNC
755  * @tc.require: SR000HRKKA
756  */
HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest1, TestSize.Level1)757 HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest1, TestSize.Level1)
758 {
759     const std::string name = "test";
760     const std::string parentCloudId = "100";
761     const std::string cloudId = "100";
762     const std::string value = "4";
763     auto rdb = make_shared<RdbStoreMock>();
764     clouddiskrdbStore_->rdbStore_ = rdb;
765     int32_t ret = clouddiskrdbStore_->LocationSetXattr(name, parentCloudId, cloudId, value);
766     EXPECT_EQ(ret, E_INVAL_ARG);
767 }
768 
769 /**
770  * @tc.name: LocationSetXattr
771  * @tc.desc: Verify the CloudDiskRdbStore::LocationSetXattr function
772  * @tc.type: FUNC
773  * @tc.require: SR000HRKKA
774  */
HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest2, TestSize.Level1)775 HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest2, TestSize.Level1)
776 {
777     const std::string name = "mock";
778     const std::string parentCloudId = "100";
779     const std::string cloudId = "100";
780     const std::string value = "1";
781     auto rdb = make_shared<RdbStoreMock>();
782     clouddiskrdbStore_->rdbStore_ = rdb;
783     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_RDB));
784 
785     int32_t ret = clouddiskrdbStore_->LocationSetXattr(name, parentCloudId, cloudId, value);
786     EXPECT_EQ(ret, E_RDB);
787 }
788 
789 /**
790  * @tc.name: LocationSetXattr
791  * @tc.desc: Verify the CloudDiskRdbStore::LocationSetXattr function
792  * @tc.type: FUNC
793  * @tc.require: SR000HRKKA
794  */
HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest3, TestSize.Level1)795 HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest3, TestSize.Level1)
796 {
797     const std::string name = "mock";
798     const std::string parentCloudId = "100";
799     const std::string cloudId = "100";
800     const std::string value = "1";
801     auto rdb = make_shared<RdbStoreMock>();
802     clouddiskrdbStore_->rdbStore_ = rdb;
803     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
804 
805     int32_t ret = clouddiskrdbStore_->LocationSetXattr(name, parentCloudId, cloudId, value);
806     EXPECT_EQ(ret, E_RDB);
807 }
808 
809 /**
810  * @tc.name: LocationSetXattr
811  * @tc.desc: Verify the CloudDiskRdbStore::LocationSetXattr function
812  * @tc.type: FUNC
813  * @tc.require: SR000HRKKA
814  */
HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest4, TestSize.Level1)815 HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest4, TestSize.Level1)
816 {
817     const std::string name = "test";
818     const std::string parentCloudId = "100";
819     const std::string cloudId = "100";
820     const std::string value = "1";
821     auto rdb = make_shared<RdbStoreMock>();
822     clouddiskrdbStore_->rdbStore_ = rdb;
823     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
824 
825     int32_t ret = clouddiskrdbStore_->LocationSetXattr(name, parentCloudId, cloudId, value);
826     EXPECT_EQ(ret, E_OK);
827 }
828 
829 /**
830  * @tc.name: GetRowId
831  * @tc.desc: Verify the CloudDiskRdbStore::GetRowId function
832  * @tc.type: FUNC
833  * @tc.require: SR000HRKKA
834  */
HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest1, TestSize.Level1)835 HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest1, TestSize.Level1)
836 {
837     const std::string cloudId = "100";
838     int64_t rowId = 100;
839     auto rdb = make_shared<RdbStoreMock>();
840     clouddiskrdbStore_->rdbStore_ = rdb;
841     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
842     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
843 
844     int32_t ret = clouddiskrdbStore_->GetRowId(cloudId, rowId);
845     EXPECT_EQ(ret, E_RDB);
846 }
847 
848 /**
849  * @tc.name: GetRowId
850  * @tc.desc: Verify the CloudDiskRdbStore::GetRowId function
851  * @tc.type: FUNC
852  * @tc.require: SR000HRKKA
853  */
HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest2, TestSize.Level1)854 HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest2, TestSize.Level1)
855 {
856     const std::string cloudId = "100";
857     int64_t rowId = 100;
858     auto rdb = make_shared<RdbStoreMock>();
859     clouddiskrdbStore_->rdbStore_ = rdb;
860     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
861     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
862     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
863     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(1));
864 
865     int32_t ret = clouddiskrdbStore_->GetRowId(cloudId, rowId);
866     EXPECT_EQ(ret, E_RDB);
867 }
868 
869 /**
870  * @tc.name: GetRowId
871  * @tc.desc: Verify the CloudDiskRdbStore::GetRowId function
872  * @tc.type: FUNC
873  * @tc.require: SR000HRKKA
874  */
HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest3, TestSize.Level1)875 HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest3, TestSize.Level1)
876 {
877     const std::string cloudId = "100";
878     int64_t rowId = 100;
879     auto rdb = make_shared<RdbStoreMock>();
880     clouddiskrdbStore_->rdbStore_ = rdb;
881     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
882     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
883     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
884     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
885 
886     int32_t ret = clouddiskrdbStore_->GetRowId(cloudId, rowId);
887     EXPECT_EQ(ret, E_OK);
888 }
889 
890 /**
891  * @tc.name: GetParentCloudIdTest
892  * @tc.desc: Verify the CloudDiskRdbStore::GetParentCloudIdTest function
893  * @tc.type: FUNC
894  * @tc.require: SR000HRKKA
895  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest1, TestSize.Level1)896 HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest1, TestSize.Level1)
897 {
898     const std::string cloudId = "100";
899     std::string parentCloudId = "mock";
900     auto rdb = make_shared<RdbStoreMock>();
901     clouddiskrdbStore_->rdbStore_ = rdb;
902     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
903     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
904 
905     int32_t ret = clouddiskrdbStore_->GetParentCloudId(cloudId, parentCloudId);
906     EXPECT_EQ(ret, E_RDB);
907 }
908 
909 /**
910  * @tc.name: GetParentCloudIdTest
911  * @tc.desc: Verify the CloudDiskRdbStore::GetParentCloudIdTest function
912  * @tc.type: FUNC
913  * @tc.require: SR000HRKKA
914  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest2, TestSize.Level1)915 HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest2, TestSize.Level1)
916 {
917     const std::string cloudId = "100";
918     std::string parentCloudId = "mock";
919     auto rdb = make_shared<RdbStoreMock>();
920     clouddiskrdbStore_->rdbStore_ = rdb;
921     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
922     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
923     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
924     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
925 
926     int32_t ret = clouddiskrdbStore_->GetParentCloudId(cloudId, parentCloudId);
927     EXPECT_EQ(ret, E_RDB);
928 }
929 
930 /**
931  * @tc.name: GetParentCloudIdTest
932  * @tc.desc: Verify the CloudDiskRdbStore::GetParentCloudIdTest function
933  * @tc.type: FUNC
934  * @tc.require: SR000HRKKA
935  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest3, TestSize.Level1)936 HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest3, TestSize.Level1)
937 {
938     const std::string cloudId = "100";
939     std::string parentCloudId = "mock";
940     auto rdb = make_shared<RdbStoreMock>();
941     clouddiskrdbStore_->rdbStore_ = rdb;
942     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
943     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
944     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
945     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
946 
947     int32_t ret = clouddiskrdbStore_->GetParentCloudId(cloudId, parentCloudId);
948     EXPECT_EQ(ret, E_RDB);
949 }
950 
951 /**
952  * @tc.name: GetParentCloudIdTest
953  * @tc.desc: Verify the CloudDiskRdbStore::GetParentCloudIdTest function
954  * @tc.type: FUNC
955  * @tc.require: SR000HRKKA
956  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest4, TestSize.Level1)957 HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTestTest4, TestSize.Level1)
958 {
959     const std::string cloudId = "100";
960     std::string parentCloudId = "test";
961     auto rdb = make_shared<RdbStoreMock>();
962     clouddiskrdbStore_->rdbStore_ = rdb;
963     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
964     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
965     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
966     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
967 
968     int32_t ret = clouddiskrdbStore_->GetParentCloudId(cloudId, parentCloudId);
969     EXPECT_EQ(ret, E_OK);
970 }
971 
972 /**
973  * @tc.name: RecycleSetXattr
974  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
975  * @tc.type: FUNC
976  * @tc.require: SR000HRKKA
977  */
HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest1, TestSize.Level1)978 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest1, TestSize.Level1)
979 {
980     const std::string name = "test";
981     const std::string parentCloudId = "100";
982     const std::string cloudId = "100";
983     const std::string value = "notnum";
984     auto rdb = make_shared<RdbStoreMock>();
985     clouddiskrdbStore_->rdbStore_ = rdb;
986     int32_t ret = clouddiskrdbStore_->RecycleSetXattr(name, parentCloudId, cloudId, value);
987     EXPECT_EQ(ret, EINVAL);
988 }
989 
990 /**
991  * @tc.name: RecycleSetXattr
992  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
993  * @tc.type: FUNC
994  * @tc.require: SR000HRKKA
995  */
HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest2, TestSize.Level1)996 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest2, TestSize.Level1)
997 {
998     const std::string name = "test";
999     const std::string parentCloudId = "100";
1000     const std::string cloudId = "100";
1001     const std::string value = "2";
1002     auto rdb = make_shared<RdbStoreMock>();
1003     clouddiskrdbStore_->rdbStore_ = rdb;
1004     int32_t ret = clouddiskrdbStore_->RecycleSetXattr(name, parentCloudId, cloudId, value);
1005     EXPECT_EQ(ret, E_RDB);
1006 }
1007 
1008 /**
1009  * @tc.name: RecycleSetXattr
1010  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
1011  * @tc.type: FUNC
1012  * @tc.require: SR000HRKKA
1013  */
HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest3, TestSize.Level1)1014 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest3, TestSize.Level1)
1015 {
1016     const std::string name = "test";
1017     const std::string parentCloudId = "100";
1018     const std::string cloudId = "100";
1019     const std::string value = "0";
1020     auto rdb = make_shared<RdbStoreMock>();
1021     clouddiskrdbStore_->rdbStore_ = rdb;
1022     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_RDB));
1023 
1024     int32_t ret = clouddiskrdbStore_->RecycleSetXattr(name, parentCloudId, cloudId, value);
1025     EXPECT_EQ(ret, E_RDB);
1026 }
1027 
1028 /**
1029  * @tc.name: RecycleSetXattr
1030  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
1031  * @tc.type: FUNC
1032  * @tc.require: SR000HRKKA
1033  */
HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest4, TestSize.Level1)1034 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest4, TestSize.Level1)
1035 {
1036     const std::string name = "test";
1037     const std::string parentCloudId = "100";
1038     const std::string cloudId = "100";
1039     const std::string value = "0";
1040     auto rdb = make_shared<RdbStoreMock>();
1041     clouddiskrdbStore_->rdbStore_ = rdb;
1042     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
1043     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1044     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
1045 
1046     int32_t ret = clouddiskrdbStore_->RecycleSetXattr(name, parentCloudId, cloudId, value);
1047     EXPECT_EQ(ret, E_RDB);
1048 }
1049 
1050 /**
1051  * @tc.name: RecycleSetXattr
1052  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
1053  * @tc.type: FUNC
1054  * @tc.require: SR000HRKKA
1055  */
HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest5, TestSize.Level1)1056 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest5, TestSize.Level1)
1057 {
1058     const std::string name = "test";
1059     const std::string parentCloudId = "100";
1060     const std::string cloudId = "100";
1061     const std::string value = "0";
1062     auto rdb = make_shared<RdbStoreMock>();
1063     clouddiskrdbStore_->rdbStore_ = rdb;
1064     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1065     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
1066     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1067     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1068     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1069 
1070     int32_t ret = clouddiskrdbStore_->RecycleSetXattr(name, parentCloudId, cloudId, value);
1071     EXPECT_EQ(ret, E_OK);
1072 }
1073 
1074 /**
1075  * @tc.name: RecycleSetXattr
1076  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
1077  * @tc.type: FUNC
1078  * @tc.require: SR000HRKKA
1079  */
HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest6, TestSize.Level1)1080 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest6, TestSize.Level1)
1081 {
1082     const std::string name = "test";
1083     const std::string parentCloudId = "mock";
1084     const std::string cloudId = "100";
1085     const std::string value = "1";
1086     auto rdb = make_shared<RdbStoreMock>();
1087     clouddiskrdbStore_->rdbStore_ = rdb;
1088     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1089     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
1090     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1091     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1092     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1093 
1094     int32_t ret = clouddiskrdbStore_->RecycleSetXattr(name, parentCloudId, cloudId, value);
1095     EXPECT_EQ(ret, E_RDB);
1096 }
1097 
1098 /**
1099  * @tc.name: FavoriteSetXattr
1100  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1101  * @tc.type: FUNC
1102  * @tc.require: SR000HRKKA
1103  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest1, TestSize.Level1)1104 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest1, TestSize.Level1)
1105 {
1106     const std::string cloudId = "rootId";
1107     const std::string value = "notnum";
1108     auto rdb = make_shared<RdbStoreMock>();
1109     clouddiskrdbStore_->rdbStore_ = rdb;
1110     int32_t ret = clouddiskrdbStore_->FavoriteSetXattr(cloudId, value);
1111     EXPECT_EQ(ret, EINVAL);
1112 }
1113 
1114 /**
1115  * @tc.name: FavoriteSetXattr
1116  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1117  * @tc.type: FUNC
1118  * @tc.require: SR000HRKKA
1119  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest2, TestSize.Level1)1120 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest2, TestSize.Level1)
1121 {
1122     const std::string cloudId = "root";
1123     const std::string value = "2";
1124     auto rdb = make_shared<RdbStoreMock>();
1125     clouddiskrdbStore_->rdbStore_ = rdb;
1126     int32_t ret = clouddiskrdbStore_->FavoriteSetXattr(cloudId, value);
1127     EXPECT_EQ(ret, E_RDB);
1128 }
1129 
1130 /**
1131  * @tc.name: FavoriteSetXattr
1132  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1133  * @tc.type: FUNC
1134  * @tc.require: SR000HRKKA
1135  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest3, TestSize.Level1)1136 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest3, TestSize.Level1)
1137 {
1138     const std::string cloudId = "root";
1139     const std::string value = "0";
1140     auto rdb = make_shared<RdbStoreMock>();
1141     clouddiskrdbStore_->rdbStore_ = rdb;
1142     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_RDB));
1143 
1144     int32_t ret = clouddiskrdbStore_->FavoriteSetXattr(cloudId, value);
1145     EXPECT_EQ(ret, E_RDB);
1146 }
1147 
1148 /**
1149  * @tc.name: FavoriteSetXattr
1150  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1151  * @tc.type: FUNC
1152  * @tc.require: SR000HRKKA
1153  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest4, TestSize.Level1)1154 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest4, TestSize.Level1)
1155 {
1156     const std::string cloudId = "root";
1157     const std::string value = "1";
1158     auto rdb = make_shared<RdbStoreMock>();
1159     clouddiskrdbStore_->rdbStore_ = rdb;
1160     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
1161 
1162     int32_t ret = clouddiskrdbStore_->FavoriteSetXattr(cloudId, value);
1163     EXPECT_EQ(ret, E_OK);
1164 }
1165 
1166 /**
1167  * @tc.name: LocationGetXattr
1168  * @tc.desc: Verify the CloudDiskRdbStore::LocationGetXattr function
1169  * @tc.type: FUNC
1170  * @tc.require: SR000HRKKA
1171  */
HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest1, TestSize.Level1)1172 HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest1, TestSize.Level1)
1173 {
1174     const std::string cloudId = "";
1175     const std::string key = IS_FAVORITE_XATTR;
1176     std::string value = "";
1177     const std::string name = "test";
1178     const std::string parentCloudId = "rootId";
1179     auto rdb = make_shared<RdbStoreMock>();
1180     clouddiskrdbStore_->rdbStore_ = rdb;
1181     int32_t ret = clouddiskrdbStore_->LocationGetXattr(name, key, value, parentCloudId);
1182     EXPECT_EQ(ret, E_INVAL_ARG);
1183 }
1184 
1185 /**
1186  * @tc.name: LocationGetXattr
1187  * @tc.desc: Verify the CloudDiskRdbStore::LocationGetXattr function
1188  * @tc.type: FUNC
1189  * @tc.require: SR000HRKKA
1190  */
HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest2, TestSize.Level1)1191 HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest2, TestSize.Level1)
1192 {
1193     const std::string cloudId = "";
1194     const std::string key = CLOUD_FILE_LOCATION;
1195     std::string value = "";
1196     const std::string name = "mock";
1197     const std::string parentCloudId = "rootId";
1198     auto rdb = make_shared<RdbStoreMock>();
1199     clouddiskrdbStore_->rdbStore_ = rdb;
1200     int32_t ret = clouddiskrdbStore_->LocationGetXattr(name, key, value, parentCloudId);
1201     EXPECT_EQ(ret, ENOENT);
1202 }
1203 
1204 /**
1205  * @tc.name: LocationGetXattr
1206  * @tc.desc: Verify the CloudDiskRdbStore::LocationGetXattr function
1207  * @tc.type: FUNC
1208  * @tc.require: SR000HRKKA
1209  */
HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest3, TestSize.Level1)1210 HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest3, TestSize.Level1)
1211 {
1212     const std::string cloudId = "";
1213     const std::string key = CLOUD_FILE_LOCATION;
1214     std::string value = "";
1215     const std::string name = "test";
1216     const std::string parentCloudId = "rootId";
1217     auto rdb = make_shared<RdbStoreMock>();
1218     clouddiskrdbStore_->rdbStore_ = rdb;
1219     int32_t ret = clouddiskrdbStore_->LocationGetXattr(name, key, value, parentCloudId);
1220     EXPECT_EQ(ret, E_OK);
1221 }
1222 
1223 /**
1224  * @tc.name: FavoriteGetXattr
1225  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteGetXattr function
1226  * @tc.type: FUNC
1227  * @tc.require: SR000HRKKA
1228  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest1, TestSize.Level1)1229 HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest1, TestSize.Level1)
1230 {
1231     const std::string cloudId = "";
1232     const std::string key = CLOUD_FILE_LOCATION;
1233     std::string value = "";
1234     auto rdb = make_shared<RdbStoreMock>();
1235     clouddiskrdbStore_->rdbStore_ = rdb;
1236     int32_t ret = clouddiskrdbStore_->FavoriteGetXattr(cloudId, key, value);
1237     EXPECT_EQ(ret, E_INVAL_ARG);
1238 }
1239 
1240 /**
1241  * @tc.name: FavoriteGetXattr
1242  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteGetXattr function
1243  * @tc.type: FUNC
1244  * @tc.require: SR000HRKKA
1245  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest2, TestSize.Level1)1246 HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest2, TestSize.Level1)
1247 {
1248     const std::string cloudId = "cloudId";
1249     const std::string key = IS_FAVORITE_XATTR;
1250     std::string value = "";
1251     auto rdb = make_shared<RdbStoreMock>();
1252     clouddiskrdbStore_->rdbStore_ = rdb;
1253     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1254     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
1255 
1256     int32_t ret = clouddiskrdbStore_->FavoriteGetXattr(cloudId, key, value);
1257     EXPECT_EQ(ret, E_RDB);
1258 }
1259 
1260 /**
1261  * @tc.name: FavoriteGetXattr
1262  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteGetXattr function
1263  * @tc.type: FUNC
1264  * @tc.require: SR000HRKKA
1265  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest3, TestSize.Level1)1266 HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest3, TestSize.Level1)
1267 {
1268     const std::string cloudId = "cloudId";
1269     const std::string key = IS_FAVORITE_XATTR;
1270     std::string value = "";
1271     auto rdb = make_shared<RdbStoreMock>();
1272     clouddiskrdbStore_->rdbStore_ = rdb;
1273     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1274     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1275     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1276     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
1277 
1278     int32_t ret = clouddiskrdbStore_->FavoriteGetXattr(cloudId, key, value);
1279     EXPECT_EQ(ret, E_RDB);
1280 }
1281 
1282 /**
1283  * @tc.name: FavoriteGetXattr
1284  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteGetXattr function
1285  * @tc.type: FUNC
1286  * @tc.require: SR000HRKKA
1287  */
HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest4, TestSize.Level1)1288 HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest4, TestSize.Level1)
1289 {
1290     const std::string cloudId = "cloudId";
1291     const std::string key = IS_FAVORITE_XATTR;
1292     std::string value = "";
1293     auto rdb = make_shared<RdbStoreMock>();
1294     clouddiskrdbStore_->rdbStore_ = rdb;
1295     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1296     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1297     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1298     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1299 
1300     int32_t ret = clouddiskrdbStore_->FavoriteGetXattr(cloudId, key, value);
1301     EXPECT_EQ(ret, E_OK);
1302 }
1303 
1304 /**
1305  * @tc.name: FileStatusGetXattr
1306  * @tc.desc: Verify the CloudDiskRdbStore::FileStatusGetXattr function
1307  * @tc.type: FUNC
1308  * @tc.require: SR000HRKKA
1309  */
HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest1, TestSize.Level1)1310 HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest1, TestSize.Level1)
1311 {
1312     const std::string cloudId = "";
1313     const std::string key = IS_FAVORITE_XATTR;
1314     std::string value = "";
1315     auto rdb = make_shared<RdbStoreMock>();
1316     clouddiskrdbStore_->rdbStore_ = rdb;
1317     int32_t ret = clouddiskrdbStore_->FileStatusGetXattr(cloudId, key, value);
1318     EXPECT_EQ(ret, E_INVAL_ARG);
1319 }
1320 
1321 /**
1322  * @tc.name: FileStatusGetXattr
1323  * @tc.desc: Verify the CloudDiskRdbStore::FileStatusGetXattr function
1324  * @tc.type: FUNC
1325  * @tc.require: SR000HRKKA
1326  */
HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest2, TestSize.Level1)1327 HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest2, TestSize.Level1)
1328 {
1329     const std::string cloudId = "cloudId";
1330     const std::string key = IS_FILE_STATUS_XATTR;
1331     std::string value = "";
1332     auto rdb = make_shared<RdbStoreMock>();
1333     clouddiskrdbStore_->rdbStore_ = rdb;
1334     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1335     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
1336 
1337     int32_t ret = clouddiskrdbStore_->FileStatusGetXattr(cloudId, key, value);
1338     EXPECT_EQ(ret, E_RDB);
1339 }
1340 
1341 /**
1342  * @tc.name: FileStatusGetXattr
1343  * @tc.desc: Verify the CloudDiskRdbStore::FileStatusGetXattr function
1344  * @tc.type: FUNC
1345  * @tc.require: SR000HRKKA
1346  */
HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest3, TestSize.Level1)1347 HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest3, TestSize.Level1)
1348 {
1349     const std::string cloudId = "cloudId";
1350     const std::string key = IS_FILE_STATUS_XATTR;
1351     std::string value = "";
1352     auto rdb = make_shared<RdbStoreMock>();
1353     clouddiskrdbStore_->rdbStore_ = rdb;
1354     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1355     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1356     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1357     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
1358 
1359     int32_t ret = clouddiskrdbStore_->FileStatusGetXattr(cloudId, key, value);
1360     EXPECT_EQ(ret, E_RDB);
1361 }
1362 
1363 /**
1364  * @tc.name: FileStatusGetXattr
1365  * @tc.desc: Verify the CloudDiskRdbStore::FileStatusGetXattr function
1366  * @tc.type: FUNC
1367  * @tc.require: SR000HRKKA
1368  */
HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest4, TestSize.Level1)1369 HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest4, TestSize.Level1)
1370 {
1371     const std::string cloudId = "cloudId";
1372     const std::string key = IS_FILE_STATUS_XATTR;
1373     std::string value = "";
1374     auto rdb = make_shared<RdbStoreMock>();
1375     clouddiskrdbStore_->rdbStore_ = rdb;
1376     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1377     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1378     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1379     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1380 
1381     int32_t ret = clouddiskrdbStore_->FileStatusGetXattr(cloudId, key, value);
1382     EXPECT_EQ(ret, E_OK);
1383 }
1384 
1385 /**
1386  * @tc.name: GetExtAttrValue
1387  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1388  * @tc.type: FUNC
1389  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrValueTest1, TestSize.Level1)1390 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrValueTest1, TestSize.Level1)
1391 {
1392     const std::string cloudId = "";
1393     const std::string key = "";
1394     std::string value = "";
1395     auto rdb = make_shared<RdbStoreMock>();
1396     clouddiskrdbStore_->rdbStore_ = rdb;
1397     int32_t ret = clouddiskrdbStore_->GetExtAttrValue(cloudId, key, value);
1398     EXPECT_EQ(ret, E_INVAL_ARG);
1399 }
1400 
1401 /**
1402  * @tc.name: GetExtAttrValue
1403  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1404  * @tc.type: FUNC
1405  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrValueTest2, TestSize.Level1)1406 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrValueTest2, TestSize.Level1)
1407 {
1408     const std::string cloudId = "100";
1409     const std::string key = "100";
1410     std::string value = "100";
1411     auto rdb = make_shared<RdbStoreMock>();
1412     clouddiskrdbStore_->rdbStore_ = rdb;
1413     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1414     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
1415 
1416     int32_t ret = clouddiskrdbStore_->GetExtAttrValue(cloudId, key, value);
1417     EXPECT_EQ(ret, E_RDB);
1418 }
1419 
1420 /**
1421  * @tc.name: GetExtAttr
1422  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1423  * @tc.type: FUNC
1424  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest1, TestSize.Level1)1425 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest1, TestSize.Level1)
1426 {
1427     const std::string cloudId = "";
1428     std::string value = "";
1429     int32_t pos = 0;
1430     auto rdb = make_shared<RdbStoreMock>();
1431     clouddiskrdbStore_->rdbStore_ = rdb;
1432     int32_t ret = clouddiskrdbStore_->GetExtAttr(cloudId, value, pos);
1433     EXPECT_EQ(ret, E_INVAL_ARG);
1434 }
1435 
1436 /**
1437  * @tc.name: GetExtAttr
1438  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1439  * @tc.type: FUNC
1440  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest2, TestSize.Level1)1441 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest2, TestSize.Level1)
1442 {
1443     const std::string cloudId = "100";
1444     std::string value = "mock";
1445     int32_t pos = 0;
1446     auto rdb = make_shared<RdbStoreMock>();
1447     clouddiskrdbStore_->rdbStore_ = rdb;
1448     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1449     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
1450 
1451     int32_t ret = clouddiskrdbStore_->GetExtAttr(cloudId, value, pos);
1452     EXPECT_EQ(ret, E_RDB);
1453 }
1454 
1455 /**
1456  * @tc.name: GetExtAttr
1457  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1458  * @tc.type: FUNC
1459  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest3, TestSize.Level1)1460 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest3, TestSize.Level1)
1461 {
1462     const std::string cloudId = "100";
1463     std::string value = "";
1464     int32_t pos = 0;
1465     auto rdb = make_shared<RdbStoreMock>();
1466     clouddiskrdbStore_->rdbStore_ = rdb;
1467     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1468     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1469     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1470     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
1471 
1472     int32_t ret = clouddiskrdbStore_->GetExtAttr(cloudId, value, pos);
1473     EXPECT_EQ(ret, E_RDB);
1474 }
1475 
1476 /**
1477  * @tc.name: GetExtAttr
1478  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1479  * @tc.type: FUNC
1480  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest4, TestSize.Level1)1481 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest4, TestSize.Level1)
1482 {
1483     const std::string cloudId = "100";
1484     std::string value = "mock";
1485     int32_t pos = 0;
1486     auto rdb = make_shared<RdbStoreMock>();
1487     clouddiskrdbStore_->rdbStore_ = rdb;
1488     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1489     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1490     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1491     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1492 
1493     int32_t ret = clouddiskrdbStore_->GetExtAttr(cloudId, value, pos);
1494     EXPECT_EQ(ret, E_RDB);
1495 }
1496 
1497 /**
1498  * @tc.name: GetExtAttr
1499  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1500  * @tc.type: FUNC
1501  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest5, TestSize.Level1)1502 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest5, TestSize.Level1)
1503 {
1504     const std::string cloudId = "100";
1505     std::string value = "";
1506     int32_t pos = -1;
1507     auto rdb = make_shared<RdbStoreMock>();
1508     clouddiskrdbStore_->rdbStore_ = rdb;
1509     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1510     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1511     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1512     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1513 
1514     int32_t ret = clouddiskrdbStore_->GetExtAttr(cloudId, value, pos);
1515     EXPECT_EQ(ret, E_RDB);
1516 }
1517 
1518 /**
1519  * @tc.name: GetExtAttr
1520  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1521  * @tc.type: FUNC
1522  */
HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest6, TestSize.Level1)1523 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest6, TestSize.Level1)
1524 {
1525     const std::string cloudId = "100";
1526     std::string value = "";
1527     int32_t pos = 1;
1528     auto rdb = make_shared<RdbStoreMock>();
1529     clouddiskrdbStore_->rdbStore_ = rdb;
1530     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1531     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1532     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1533     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1534 
1535     int32_t ret = clouddiskrdbStore_->GetExtAttr(cloudId, value, pos);
1536     EXPECT_EQ(ret, E_OK);
1537 }
1538 
1539 /**
1540  * @tc.name: GetXAttr
1541  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
1542  * @tc.type: FUNC
1543  * @tc.require: SR000HRKKA
1544  */
HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest1, TestSize.Level1)1545 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest1, TestSize.Level1)
1546 {
1547     const std::string cloudId = "";
1548     const std::string key = CLOUD_FILE_LOCATION;
1549     std::string value = "";
1550     CacheNode node;
1551     node.fileName = "test";
1552     node.parentCloudId = "100";
1553     auto rdb = make_shared<RdbStoreMock>();
1554     clouddiskrdbStore_->rdbStore_ = rdb;
1555     int32_t ret = clouddiskrdbStore_->GetXAttr(cloudId, key, value);
1556     EXPECT_EQ(ret, E_OK);
1557 }
1558 
1559 /**
1560  * @tc.name: GetXAttr
1561  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
1562  * @tc.type: FUNC
1563  * @tc.require: SR000HRKKA
1564  */
HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest2, TestSize.Level1)1565 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest2, TestSize.Level1)
1566 {
1567     const std::string cloudId = "";
1568     const std::string key = IS_FAVORITE_XATTR;
1569     std::string value = "";
1570     auto rdb = make_shared<RdbStoreMock>();
1571     clouddiskrdbStore_->rdbStore_ = rdb;
1572     int32_t ret = clouddiskrdbStore_->GetXAttr(cloudId, key, value);
1573     EXPECT_EQ(ret, E_INVAL_ARG);
1574 }
1575 
1576 /**
1577  * @tc.name: GetXAttr
1578  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
1579  * @tc.type: FUNC
1580  * @tc.require: SR000HRKKA
1581  */
HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest3, TestSize.Level1)1582 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest3, TestSize.Level1)
1583 {
1584     const std::string cloudId = "";
1585     const std::string key = IS_FILE_STATUS_XATTR;
1586     std::string value = "";
1587     auto rdb = make_shared<RdbStoreMock>();
1588     clouddiskrdbStore_->rdbStore_ = rdb;
1589     int32_t ret = clouddiskrdbStore_->GetXAttr(cloudId, key, value);
1590     EXPECT_EQ(ret, E_INVAL_ARG);
1591 }
1592 
1593 /**
1594  * @tc.name: GetXAttr
1595  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
1596  * @tc.type: FUNC
1597  * @tc.require: SR000HRKKA
1598  */
HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest4, TestSize.Level1)1599 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest4, TestSize.Level1)
1600 {
1601     const std::string cloudId = "";
1602     const std::string key = CLOUD_EXT_ATTR;
1603     std::string value = "";
1604     auto rdb = make_shared<RdbStoreMock>();
1605     clouddiskrdbStore_->rdbStore_ = rdb;
1606     int32_t ret = clouddiskrdbStore_->GetXAttr(cloudId, key, value);
1607     EXPECT_EQ(ret, E_INVAL_ARG);
1608 }
1609 
1610 /**
1611  * @tc.name: GetXAttr
1612  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
1613  * @tc.type: FUNC
1614  * @tc.require: SR000HRKKA
1615  */
HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest5, TestSize.Level1)1616 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest5, TestSize.Level1)
1617 {
1618     const std::string cloudId = "";
1619     const std::string key = CLOUD_CLOUD_RECYCLE_XATTR;
1620     std::string value = "";
1621     auto rdb = make_shared<RdbStoreMock>();
1622     clouddiskrdbStore_->rdbStore_ = rdb;
1623     int32_t ret = clouddiskrdbStore_->GetXAttr(cloudId, key, value);
1624     EXPECT_EQ(ret, ENOSYS);
1625 }
1626 
1627 /**
1628  * @tc.name: ExtAttributeSetXattr
1629  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1630  * @tc.type: FUNC
1631  */
HWTEST_F(CloudDiskRdbStoreTest, ExtAttributeSetXattrTest1, TestSize.Level1)1632 HWTEST_F(CloudDiskRdbStoreTest, ExtAttributeSetXattrTest1, TestSize.Level1)
1633 {
1634     const std::string cloudId = "root";
1635     const std::string key = "user.cloud.test1";
1636     const std::string value = "1";
1637     auto rdb = make_shared<RdbStoreMock>();
1638     clouddiskrdbStore_->rdbStore_ = rdb;
1639     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1640     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1641     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1642     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1643     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_RDB));
1644 
1645     int32_t ret = clouddiskrdbStore_->ExtAttributeSetXattr(cloudId, value, key);
1646     EXPECT_EQ(ret, E_RDB);
1647 }
1648 
1649 /**
1650  * @tc.name: ExtAttributeSetXattr
1651  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1652  * @tc.type: FUNC
1653  */
HWTEST_F(CloudDiskRdbStoreTest, ExtAttributeSetXattrTest2, TestSize.Level1)1654 HWTEST_F(CloudDiskRdbStoreTest, ExtAttributeSetXattrTest2, TestSize.Level1)
1655 {
1656     const std::string cloudId = "root";
1657     const std::string key = "user.cloud.test1";
1658     const std::string value = "1";
1659     auto rdb = make_shared<RdbStoreMock>();
1660     clouddiskrdbStore_->rdbStore_ = rdb;
1661     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1662     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1663     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1664     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1665     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<ValueObject> &>())).WillOnce(Return(E_OK));
1666 
1667     int32_t ret = clouddiskrdbStore_->ExtAttributeSetXattr(cloudId, value, key);
1668     EXPECT_EQ(ret, E_OK);
1669 }
1670 
1671 /**
1672  * @tc.name: SetXAttr
1673  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
1674  * @tc.type: FUNC
1675  * @tc.require: SR000HRKKA
1676  */
HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest1, TestSize.Level1)1677 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest1, TestSize.Level1)
1678 {
1679     const std::string cloudId = "100";
1680     const std::string key = CLOUD_FILE_LOCATION;
1681     const std::string value = "notnum";
1682     const std::string name = "test";
1683     const std::string parentCloudId = "100";
1684     auto rdb = make_shared<RdbStoreMock>();
1685     clouddiskrdbStore_->rdbStore_ = rdb;
1686     int32_t ret = clouddiskrdbStore_->SetXAttr(cloudId, key, value, name, parentCloudId);
1687     EXPECT_EQ(ret, E_INVAL_ARG);
1688 }
1689 
1690 /**
1691  * @tc.name: SetXAttr
1692  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
1693  * @tc.type: FUNC
1694  * @tc.require: SR000HRKKA
1695  */
HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest2, TestSize.Level1)1696 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest2, TestSize.Level1)
1697 {
1698     const std::string cloudId = "100";
1699     const std::string key = CLOUD_CLOUD_RECYCLE_XATTR;
1700     const std::string value = "notnum";
1701     const std::string name = "test";
1702     const std::string parentCloudId = "100";
1703     auto rdb = make_shared<RdbStoreMock>();
1704     clouddiskrdbStore_->rdbStore_ = rdb;
1705     int32_t ret = clouddiskrdbStore_->SetXAttr(cloudId, key, value, name, parentCloudId);
1706     EXPECT_EQ(ret, EINVAL);
1707 }
1708 
1709 /**
1710  * @tc.name: SetXAttr
1711  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
1712  * @tc.type: FUNC
1713  * @tc.require: SR000HRKKA
1714  */
HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest3, TestSize.Level1)1715 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest3, TestSize.Level1)
1716 {
1717     const std::string cloudId = "100";
1718     const std::string key = IS_FAVORITE_XATTR;
1719     const std::string value = "notnum";
1720     const std::string name = "test";
1721     const std::string parentCloudId = "100";
1722     auto rdb = make_shared<RdbStoreMock>();
1723     clouddiskrdbStore_->rdbStore_ = rdb;
1724     int32_t ret = clouddiskrdbStore_->SetXAttr(cloudId, key, value, name, parentCloudId);
1725     EXPECT_EQ(ret, EINVAL);
1726 }
1727 
1728 /**
1729  * @tc.name: SetXAttr
1730  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
1731  * @tc.type: FUNC
1732  * @tc.require: SR000HRKKA
1733  */
HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest4, TestSize.Level1)1734 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest4, TestSize.Level1)
1735 {
1736     const std::string cloudId = "100";
1737     const std::string key = CLOUD_EXT_ATTR;
1738     const std::string value = "notnum";
1739     const std::string name = "test";
1740     const std::string parentCloudId = "100";
1741     auto rdb = make_shared<RdbStoreMock>();
1742     clouddiskrdbStore_->rdbStore_ = rdb;
1743     int32_t ret = clouddiskrdbStore_->SetXAttr(cloudId, key, value, name, parentCloudId);
1744     EXPECT_EQ(ret, E_RDB);
1745 }
1746 
1747 /**
1748  * @tc.name: SetXAttr
1749  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
1750  * @tc.type: FUNC
1751  * @tc.require: SR000HRKKA
1752  */
HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest5, TestSize.Level1)1753 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest5, TestSize.Level1)
1754 {
1755     const std::string cloudId = "100";
1756     const std::string key = IS_FILE_STATUS_XATTR;
1757     const std::string value = "notnum";
1758     const std::string name = "test";
1759     const std::string parentCloudId = "100";
1760     auto rdb = make_shared<RdbStoreMock>();
1761     clouddiskrdbStore_->rdbStore_ = rdb;
1762     int32_t ret = clouddiskrdbStore_->SetXAttr(cloudId, key, value, name, parentCloudId);
1763     EXPECT_EQ(ret, ENOSYS);
1764 }
1765 
1766 /**
1767  * @tc.name: Rename
1768  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
1769  * @tc.type: FUNC
1770  * @tc.require: SR000HRKKA
1771  */
HWTEST_F(CloudDiskRdbStoreTest, RenameTest1, TestSize.Level1)1772 HWTEST_F(CloudDiskRdbStoreTest, RenameTest1, TestSize.Level1)
1773 {
1774     const std::string oldParentCloudId = "100";
1775     const std::string oldFileName = "test";
1776     const std::string newParentCloudId = "100";
1777     const std::string newFileName = "";
1778     auto rdb = make_shared<RdbStoreMock>();
1779     clouddiskrdbStore_->rdbStore_ = rdb;
1780     int32_t ret = clouddiskrdbStore_->Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
1781     EXPECT_EQ(ret, EINVAL);
1782 }
1783 
1784 /**
1785  * @tc.name: Rename
1786  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
1787  * @tc.type: FUNC
1788  * @tc.require: SR000HRKKA
1789  */
HWTEST_F(CloudDiskRdbStoreTest, RenameTest2, TestSize.Level1)1790 HWTEST_F(CloudDiskRdbStoreTest, RenameTest2, TestSize.Level1)
1791 {
1792     const std::string oldParentCloudId = "";
1793     const std::string oldFileName = "";
1794     const std::string newParentCloudId = "";
1795     const std::string newFileName = "test";
1796     auto rdb = make_shared<RdbStoreMock>();
1797     clouddiskrdbStore_->rdbStore_ = rdb;
1798     int32_t ret = clouddiskrdbStore_->Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
1799     EXPECT_EQ(ret, E_INVAL_ARG);
1800 }
1801 
1802 /**
1803  * @tc.name: Rename
1804  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
1805  * @tc.type: FUNC
1806  * @tc.require: SR000HRKKA
1807  */
HWTEST_F(CloudDiskRdbStoreTest, RenameTest3, TestSize.Level1)1808 HWTEST_F(CloudDiskRdbStoreTest, RenameTest3, TestSize.Level1)
1809 {
1810     const std::string oldParentCloudId = "100";
1811     const std::string oldFileName = "mock";
1812     const std::string newParentCloudId = "100";
1813     const std::string newFileName = " test";
1814     auto rdb = make_shared<RdbStoreMock>();
1815     clouddiskrdbStore_->rdbStore_ = rdb;
1816     int32_t ret = clouddiskrdbStore_->Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
1817     EXPECT_EQ(ret, EINVAL);
1818 }
1819 
1820 /**
1821  * @tc.name: Rename
1822  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
1823  * @tc.type: FUNC
1824  * @tc.require: SR000HRKKA
1825  */
HWTEST_F(CloudDiskRdbStoreTest, RenameTest4, TestSize.Level1)1826 HWTEST_F(CloudDiskRdbStoreTest, RenameTest4, TestSize.Level1)
1827 {
1828     const std::string oldParentCloudId = "100";
1829     const std::string oldFileName = "test";
1830     const std::string newParentCloudId = "100";
1831     const std::string newFileName = " test";
1832     auto rdb = make_shared<RdbStoreMock>();
1833     clouddiskrdbStore_->rdbStore_ = rdb;
1834     int32_t ret = clouddiskrdbStore_->Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
1835     EXPECT_EQ(ret, EINVAL);
1836 }
1837 
1838 /**
1839  * @tc.name: Rename
1840  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
1841  * @tc.type: FUNC
1842  * @tc.require: SR000HRKKA
1843  */
HWTEST_F(CloudDiskRdbStoreTest, RenameTest5, TestSize.Level1)1844 HWTEST_F(CloudDiskRdbStoreTest, RenameTest5, TestSize.Level1)
1845 {
1846     const std::string oldParentCloudId = "100";
1847     const std::string oldFileName = "test";
1848     const std::string newParentCloudId = "100";
1849     const std::string newFileName = "mock";
1850     auto rdb = make_shared<RdbStoreMock>();
1851     clouddiskrdbStore_->rdbStore_ = rdb;
1852     int32_t ret = clouddiskrdbStore_->Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
1853     EXPECT_EQ(ret, EINVAL);
1854 }
1855 
1856 /**
1857  * @tc.name: GetHasChild
1858  * @tc.desc: Verify the CloudDiskRdbStore::GetHasChild function
1859  * @tc.type: FUNC
1860  * @tc.require: SR000HRKKA
1861  */
HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest1, TestSize.Level1)1862 HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest1, TestSize.Level1)
1863 {
1864     const std::string cloudId = "100";
1865     bool hasChild = true;
1866     auto rdb = make_shared<RdbStoreMock>();
1867     clouddiskrdbStore_->rdbStore_ = rdb;
1868     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1869     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
1870     int32_t ret = clouddiskrdbStore_->GetHasChild(cloudId, hasChild);
1871     EXPECT_EQ(ret, E_RDB);
1872 }
1873 
1874 /**
1875  * @tc.name: GetHasChild
1876  * @tc.desc: Verify the CloudDiskRdbStore::GetHasChild function
1877  * @tc.type: FUNC
1878  * @tc.require: SR000HRKKA
1879  */
HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest2, TestSize.Level1)1880 HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest2, TestSize.Level1)
1881 {
1882     const std::string cloudId = "100";
1883     bool hasChild = true;
1884     auto rdb = make_shared<RdbStoreMock>();
1885     clouddiskrdbStore_->rdbStore_ = rdb;
1886     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1887     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1888     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1889     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
1890     int32_t ret = clouddiskrdbStore_->GetHasChild(cloudId, hasChild);
1891     EXPECT_EQ(ret, E_OK);
1892 }
1893 
1894 /**
1895  * @tc.name: GetHasChild
1896  * @tc.desc: Verify the CloudDiskRdbStore::GetHasChild function
1897  * @tc.type: FUNC
1898  * @tc.require: SR000HRKKA
1899  */
HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest3, TestSize.Level1)1900 HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest3, TestSize.Level1)
1901 {
1902     const std::string cloudId = "100";
1903     bool hasChild = true;
1904     auto rdb = make_shared<RdbStoreMock>();
1905     clouddiskrdbStore_->rdbStore_ = rdb;
1906     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
1907     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
1908     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
1909     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
1910     int32_t ret = clouddiskrdbStore_->GetHasChild(cloudId, hasChild);
1911     EXPECT_EQ(ret, E_OK);
1912 }
1913 
1914 /**
1915  * @tc.name: UnlinkSynced
1916  * @tc.desc: Verify the CloudDiskRdbStore::UnlinkSynced function
1917  * @tc.type: FUNC
1918  * @tc.require: SR000HRKKA
1919  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkSyncedTest1, TestSize.Level1)1920 HWTEST_F(CloudDiskRdbStoreTest, UnlinkSyncedTest1, TestSize.Level1)
1921 {
1922     const std::string cloudId = "100";
1923     auto rdb = make_shared<RdbStoreMock>();
1924     clouddiskrdbStore_->rdbStore_ = rdb;
1925     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<std::string> &>())).WillOnce(Return(E_RDB));
1926 
1927     int32_t ret = clouddiskrdbStore_->UnlinkSynced(cloudId);
1928     EXPECT_EQ(ret, E_RDB);
1929 }
1930 
1931 /**
1932  * @tc.name: UnlinkSynced
1933  * @tc.desc: Verify the CloudDiskRdbStore::UnlinkSynced function
1934  * @tc.type: FUNC
1935  * @tc.require: SR000HRKKA
1936  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkSyncedTest2, TestSize.Level1)1937 HWTEST_F(CloudDiskRdbStoreTest, UnlinkSyncedTest2, TestSize.Level1)
1938 {
1939     const std::string cloudId = "100";
1940     auto rdb = make_shared<RdbStoreMock>();
1941     clouddiskrdbStore_->rdbStore_ = rdb;
1942     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<std::string> &>())).WillOnce(Return(E_OK));
1943 
1944     int32_t ret = clouddiskrdbStore_->UnlinkSynced(cloudId);
1945     EXPECT_EQ(ret, E_OK);
1946 }
1947 
1948 /**
1949  * @tc.name: UnlinkLocal
1950  * @tc.desc: Verify the CloudDiskRdbStore::UnlinkLocal function
1951  * @tc.type: FUNC
1952  * @tc.require: SR000HRKKA
1953  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkLocalTest1, TestSize.Level1)1954 HWTEST_F(CloudDiskRdbStoreTest, UnlinkLocalTest1, TestSize.Level1)
1955 {
1956     const std::string cloudId = "100";
1957     auto rdb = make_shared<RdbStoreMock>();
1958     clouddiskrdbStore_->rdbStore_ = rdb;
1959     EXPECT_CALL(*rdb, Delete(_, _, _, An<const std::vector<std::string> &>())).WillOnce(Return(E_RDB));
1960 
1961     int32_t ret = clouddiskrdbStore_->UnlinkLocal(cloudId);
1962     EXPECT_EQ(ret, E_RDB);
1963 }
1964 
1965 /**
1966  * @tc.name: UnlinkLocal
1967  * @tc.desc: Verify the CloudDiskRdbStore::UnlinkLocal function
1968  * @tc.type: FUNC
1969  * @tc.require: SR000HRKKA
1970  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkLocalTest2, TestSize.Level1)1971 HWTEST_F(CloudDiskRdbStoreTest, UnlinkLocalTest2, TestSize.Level1)
1972 {
1973     const std::string cloudId = "100";
1974     auto rdb = make_shared<RdbStoreMock>();
1975     clouddiskrdbStore_->rdbStore_ = rdb;
1976     EXPECT_CALL(*rdb, Delete(_, _, _, An<const std::vector<std::string> &>())).WillOnce(Return(E_OK));
1977 
1978     int32_t ret = clouddiskrdbStore_->UnlinkLocal(cloudId);
1979     EXPECT_EQ(ret, E_OK);
1980 }
1981 
1982 /**
1983  * @tc.name: Unlink
1984  * @tc.desc: Verify the CloudDiskRdbStore::Unlink function
1985  * @tc.type: FUNC
1986  * @tc.require: SR000HRKKA
1987  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest1, TestSize.Level1)1988 HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest1, TestSize.Level1)
1989 {
1990     std::string cloudId = "";
1991     const int32_t position = LOCAL;
1992     auto rdb = make_shared<RdbStoreMock>();
1993     clouddiskrdbStore_->rdbStore_ = rdb;
1994     int32_t ret = clouddiskrdbStore_->Unlink(cloudId, position);
1995     EXPECT_EQ(ret, E_INVAL_ARG);
1996 }
1997 
1998 /**
1999  * @tc.name: Unlink
2000  * @tc.desc: Verify the CloudDiskRdbStore::Unlink function
2001  * @tc.type: FUNC
2002  * @tc.require: SR000HRKKA
2003  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest2, TestSize.Level1)2004 HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest2, TestSize.Level1)
2005 {
2006     const int32_t position = LOCAL;
2007     std::string cloudId = "100";
2008     auto rdb = make_shared<RdbStoreMock>();
2009     clouddiskrdbStore_->rdbStore_ = rdb;
2010     EXPECT_CALL(*rdb, Delete(_, _, _, An<const std::vector<std::string> &>())).WillOnce(Return(E_OK));
2011     int32_t ret = clouddiskrdbStore_->Unlink(cloudId, position);
2012     EXPECT_EQ(ret, E_OK);
2013 }
2014 
2015 /**
2016  * @tc.name: Unlink
2017  * @tc.desc: Verify the CloudDiskRdbStore::Unlink function
2018  * @tc.type: FUNC
2019  * @tc.require: SR000HRKKA
2020  */
HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest3, TestSize.Level1)2021 HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest3, TestSize.Level1)
2022 {
2023     const int32_t position = CLOUD;
2024     std::string cloudId = "100";
2025     auto rdb = make_shared<RdbStoreMock>();
2026     clouddiskrdbStore_->rdbStore_ = rdb;
2027     EXPECT_CALL(*rdb, Update(_, _, _, _, An<const std::vector<std::string> &>())).WillOnce(Return(E_OK));
2028     int32_t ret = clouddiskrdbStore_->Unlink(cloudId, position);
2029     EXPECT_EQ(ret, E_OK);
2030 }
2031 
2032 /**
2033  * @tc.name: GetDirtyType
2034  * @tc.desc: Verify the CloudDiskRdbStore::GetDirtyType function
2035  * @tc.type: FUNC
2036  * @tc.require: SR000HRKKA
2037  */
HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest1, TestSize.Level1)2038 HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest1, TestSize.Level1)
2039 {
2040     int32_t dirtyType = 0;
2041     std::string cloudId = "100";
2042     auto rdb = make_shared<RdbStoreMock>();
2043     clouddiskrdbStore_->rdbStore_ = rdb;
2044     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2045     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
2046 
2047     int32_t ret = clouddiskrdbStore_->GetDirtyType(cloudId, dirtyType);
2048     EXPECT_EQ(ret, E_RDB);
2049 }
2050 
2051 /**
2052  * @tc.name: GetDirtyType
2053  * @tc.desc: Verify the CloudDiskRdbStore::GetDirtyType function
2054  * @tc.type: FUNC
2055  * @tc.require: SR000HRKKA
2056  */
HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest2, TestSize.Level1)2057 HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest2, TestSize.Level1)
2058 {
2059     int32_t dirtyType = 0;
2060     std::string cloudId = "100";
2061     auto rdb = make_shared<RdbStoreMock>();
2062     clouddiskrdbStore_->rdbStore_ = rdb;
2063     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2064     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2065     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2066     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
2067 
2068     int32_t ret = clouddiskrdbStore_->GetDirtyType(cloudId, dirtyType);
2069     EXPECT_EQ(ret, E_RDB);
2070 }
2071 
2072 /**
2073  * @tc.name: GetDirtyType
2074  * @tc.desc: Verify the CloudDiskRdbStore::GetDirtyType function
2075  * @tc.type: FUNC
2076  * @tc.require: SR000HRKKA
2077  */
HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest3, TestSize.Level1)2078 HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest3, TestSize.Level1)
2079 {
2080     int32_t dirtyType = -1;
2081     std::string cloudId = "100";
2082     auto rdb = make_shared<RdbStoreMock>();
2083     clouddiskrdbStore_->rdbStore_ = rdb;
2084     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2085     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2086     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2087     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2088 
2089     int32_t ret = clouddiskrdbStore_->GetDirtyType(cloudId, dirtyType);
2090     EXPECT_EQ(ret, E_RDB);
2091 }
2092 
2093 /**
2094  * @tc.name: GetDirtyType
2095  * @tc.desc: Verify the CloudDiskRdbStore::GetDirtyType function
2096  * @tc.type: FUNC
2097  * @tc.require: SR000HRKKA
2098  */
HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest4, TestSize.Level1)2099 HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest4, TestSize.Level1)
2100 {
2101     int32_t dirtyType = 1;
2102     std::string cloudId = "100";
2103     auto rdb = make_shared<RdbStoreMock>();
2104     clouddiskrdbStore_->rdbStore_ = rdb;
2105     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2106     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2107     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2108     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2109 
2110     int32_t ret = clouddiskrdbStore_->GetDirtyType(cloudId, dirtyType);
2111     EXPECT_EQ(ret, E_OK);
2112 }
2113 
2114 /**
2115  * @tc.name: GetCurNode
2116  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
2117  * @tc.type: FUNC
2118  * @tc.require: SR000HRKKA
2119  */
HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest1, TestSize.Level1)2120 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest1, TestSize.Level1)
2121 {
2122     CacheNode curNode;
2123     std::string cloudId = "";
2124     auto rdb = make_shared<RdbStoreMock>();
2125     clouddiskrdbStore_->rdbStore_ = rdb;
2126     int32_t ret = clouddiskrdbStore_->GetCurNode(cloudId, curNode);
2127     EXPECT_EQ(ret, E_INVAL_ARG);
2128 }
2129 
2130 /**
2131  * @tc.name: GetCurNode
2132  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
2133  * @tc.type: FUNC
2134  * @tc.require: SR000HRKKA
2135  */
HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest2, TestSize.Level1)2136 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest2, TestSize.Level1)
2137 {
2138     CacheNode curNode;
2139     std::string cloudId = "100";
2140     auto rdb = make_shared<RdbStoreMock>();
2141     clouddiskrdbStore_->rdbStore_ = rdb;
2142     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2143     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
2144 
2145     int32_t ret = clouddiskrdbStore_->GetCurNode(cloudId, curNode);
2146     EXPECT_EQ(ret, E_RDB);
2147 }
2148 
2149 /**
2150  * @tc.name: GetCurNode
2151  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
2152  * @tc.type: FUNC
2153  * @tc.require: SR000HRKKA
2154  */
HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest3, TestSize.Level1)2155 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest3, TestSize.Level1)
2156 {
2157     CacheNode curNode;
2158     std::string cloudId = "100";
2159     auto rdb = make_shared<RdbStoreMock>();
2160     clouddiskrdbStore_->rdbStore_ = rdb;
2161     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2162     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2163     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2164     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
2165 
2166     int32_t ret = clouddiskrdbStore_->GetCurNode(cloudId, curNode);
2167     EXPECT_EQ(ret, E_RDB);
2168 }
2169 
2170 /**
2171  * @tc.name: GetCurNode
2172  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
2173  * @tc.type: FUNC
2174  * @tc.require: SR000HRKKA
2175  */
HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest4, TestSize.Level1)2176 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest4, TestSize.Level1)
2177 {
2178     CacheNode curNode;
2179     std::string cloudId = "100";
2180     auto rdb = make_shared<RdbStoreMock>();
2181     clouddiskrdbStore_->rdbStore_ = rdb;
2182     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2183     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2184     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2185     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2186     EXPECT_CALL(*rset, GetRow(_)).WillRepeatedly(Return(E_RDB));
2187 
2188     int32_t ret = clouddiskrdbStore_->GetCurNode(cloudId, curNode);
2189     EXPECT_EQ(ret, E_RDB);
2190 }
2191 
2192 /**
2193  * @tc.name: GetCurNode
2194  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
2195  * @tc.type: FUNC
2196  * @tc.require: SR000HRKKA
2197  */
HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest5, TestSize.Level1)2198 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest5, TestSize.Level1)
2199 {
2200     CacheNode curNode;
2201     std::string cloudId = "100";
2202     auto rdb = make_shared<RdbStoreMock>();
2203     clouddiskrdbStore_->rdbStore_ = rdb;
2204     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2205     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2206     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2207     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2208     EXPECT_CALL(*rset, GetRow(_)).WillRepeatedly(Return(E_OK));
2209 
2210     int32_t ret = clouddiskrdbStore_->GetCurNode(cloudId, curNode);
2211     EXPECT_EQ(ret, E_OK);
2212 }
2213 
2214 /**
2215  * @tc.name: GetParentNode
2216  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
2217  * @tc.type: FUNC
2218  * @tc.require: SR000HRKKA
2219  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest1, TestSize.Level1)2220 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest1, TestSize.Level1)
2221 {
2222     const std::string parentCloudId = "";
2223     std::string nextCloudId = "100";
2224     std::string fileName = "test";
2225     auto rdb = make_shared<RdbStoreMock>();
2226     clouddiskrdbStore_->rdbStore_ = rdb;
2227 
2228     int32_t ret = clouddiskrdbStore_->GetParentNode(parentCloudId, nextCloudId, fileName);
2229     EXPECT_EQ(ret, E_INVAL_ARG);
2230 }
2231 
2232 /**
2233  * @tc.name: GetParentNode
2234  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
2235  * @tc.type: FUNC
2236  * @tc.require: SR000HRKKA
2237  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest2, TestSize.Level1)2238 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest2, TestSize.Level1)
2239 {
2240     const std::string parentCloudId = "100";
2241     std::string nextCloudId = "100";
2242     std::string fileName = "test";
2243     auto rdb = make_shared<RdbStoreMock>();
2244     clouddiskrdbStore_->rdbStore_ = rdb;
2245     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2246     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
2247 
2248     int32_t ret = clouddiskrdbStore_->GetParentNode(parentCloudId, nextCloudId, fileName);
2249     EXPECT_EQ(ret, E_RDB);
2250 }
2251 
2252 /**
2253  * @tc.name: GetParentNode
2254  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
2255  * @tc.type: FUNC
2256  * @tc.require: SR000HRKKA
2257  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest3, TestSize.Level1)2258 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest3, TestSize.Level1)
2259 {
2260     const std::string parentCloudId = "100";
2261     std::string nextCloudId = "100";
2262     std::string fileName = "test";
2263     auto rdb = make_shared<RdbStoreMock>();
2264     clouddiskrdbStore_->rdbStore_ = rdb;
2265     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2266     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2267     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2268     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_RDB));
2269 
2270     int32_t ret = clouddiskrdbStore_->GetParentNode(parentCloudId, nextCloudId, fileName);
2271     EXPECT_EQ(ret, E_RDB);
2272 }
2273 
2274 /**
2275  * @tc.name: GetParentNode
2276  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
2277  * @tc.type: FUNC
2278  * @tc.require: SR000HRKKA
2279  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest4, TestSize.Level1)2280 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest4, TestSize.Level1)
2281 {
2282     const std::string parentCloudId = "100";
2283     std::string nextCloudId = "100";
2284     std::string fileName = "test";
2285     auto rdb = make_shared<RdbStoreMock>();
2286     clouddiskrdbStore_->rdbStore_ = rdb;
2287     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2288     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2289     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2290     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2291     EXPECT_CALL(*rset, GetRow(_)).WillRepeatedly(Return(E_RDB));
2292 
2293     int32_t ret = clouddiskrdbStore_->GetParentNode(parentCloudId, nextCloudId, fileName);
2294     EXPECT_EQ(ret, E_RDB);
2295 }
2296 
2297 /**
2298  * @tc.name: GetParentNode
2299  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
2300  * @tc.type: FUNC
2301  * @tc.require: SR000HRKKA
2302  */
HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest5, TestSize.Level1)2303 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest5, TestSize.Level1)
2304 {
2305     const std::string parentCloudId = "100";
2306     std::string nextCloudId = "100";
2307     std::string fileName = "test";
2308     auto rdb = make_shared<RdbStoreMock>();
2309     clouddiskrdbStore_->rdbStore_ = rdb;
2310     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2311     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2312     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2313     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2314     EXPECT_CALL(*rset, GetRow(_)).WillRepeatedly(Return(E_OK));
2315 
2316     int32_t ret = clouddiskrdbStore_->GetParentNode(parentCloudId, nextCloudId, fileName);
2317     EXPECT_EQ(ret, E_OK);
2318 }
2319 
2320 /**
2321  * @tc.name: GetUriFromDB
2322  * @tc.desc: Verify the CloudDiskRdbStore::GetUriFromDB function
2323  * @tc.type: FUNC
2324  * @tc.require: SR000HRKKA
2325  */
HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest1, TestSize.Level1)2326 HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest1, TestSize.Level1)
2327 {
2328     const std::string parentCloudId = "";
2329     std::string uri = "100";
2330     auto rdb = make_shared<RdbStoreMock>();
2331     clouddiskrdbStore_->rdbStore_ = rdb;
2332 
2333     int32_t ret = clouddiskrdbStore_->GetUriFromDB(parentCloudId, uri);
2334     EXPECT_EQ(ret, E_OK);
2335 }
2336 
2337 /**
2338  * @tc.name: GetUriFromDB
2339  * @tc.desc: Verify the CloudDiskRdbStore::GetUriFromDB function
2340  * @tc.type: FUNC
2341  * @tc.require: SR000HRKKA
2342  */
HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest2, TestSize.Level1)2343 HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest2, TestSize.Level1)
2344 {
2345     const std::string parentCloudId = "100";
2346     std::string uri = "100";
2347     auto rdb = make_shared<RdbStoreMock>();
2348     clouddiskrdbStore_->rdbStore_ = rdb;
2349     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2350     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
2351 
2352     int32_t ret = clouddiskrdbStore_->GetUriFromDB(parentCloudId, uri);
2353     EXPECT_EQ(ret, E_RDB);
2354 }
2355 
2356 /**
2357  * @tc.name: GetUriFromDB
2358  * @tc.desc: Verify the CloudDiskRdbStore::GetUriFromDB function
2359  * @tc.type: FUNC
2360  * @tc.require: SR000HRKKA
2361  */
HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest3, TestSize.Level1)2362 HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest3, TestSize.Level1)
2363 {
2364     const std::string parentCloudId = "100";
2365     std::string uri = "100";
2366     auto rdb = make_shared<RdbStoreMock>();
2367     clouddiskrdbStore_->rdbStore_ = rdb;
2368     std::shared_ptr<ResultSetMock> rset = std::make_shared<ResultSetMock>();
2369     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2370     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(rset)));
2371     EXPECT_CALL(*rset, GoToNextRow()).WillRepeatedly(Return(E_OK));
2372     EXPECT_CALL(*rset, GetRow(_)).WillRepeatedly(Return(E_OK));
2373 
2374     int32_t ret = clouddiskrdbStore_->GetUriFromDB(parentCloudId, uri);
2375     EXPECT_EQ(ret, E_OK);
2376 }
2377 
2378 /**
2379  * @tc.name: GetNotifyUri
2380  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyUri function
2381  * @tc.type: FUNC
2382  * @tc.require: SR000HRKKA
2383  */
HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest1, TestSize.Level1)2384 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest1, TestSize.Level1)
2385 {
2386     CacheNode cacheNode;
2387     std::string uri = "100";
2388     auto rdb = make_shared<RdbStoreMock>();
2389     clouddiskrdbStore_->rdbStore_ = rdb;
2390     clouddiskrdbStore_->rootId_ = "";
2391     int32_t ret = clouddiskrdbStore_->GetNotifyUri(cacheNode, uri);
2392     EXPECT_EQ(ret, E_INVAL_ARG);
2393 }
2394 
2395 /**
2396  * @tc.name: GetNotifyUri
2397  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyUri function
2398  * @tc.type: FUNC
2399  * @tc.require: SR000HRKKA
2400  */
HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest2, TestSize.Level1)2401 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest2, TestSize.Level1)
2402 {
2403     CacheNode cacheNode;
2404     std::string uri = "test";
2405     auto rdb = make_shared<RdbStoreMock>();
2406     clouddiskrdbStore_->rdbStore_ = rdb;
2407     clouddiskrdbStore_->rootId_ = "rootId";
2408     int32_t ret = clouddiskrdbStore_->GetNotifyUri(cacheNode, uri);
2409     EXPECT_EQ(ret, E_OK);
2410 }
2411 
2412 /**
2413  * @tc.name: GetNotifyUri
2414  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyUri function
2415  * @tc.type: FUNC
2416  * @tc.require: SR000HRKKA
2417  */
HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest3, TestSize.Level1)2418 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest3, TestSize.Level1)
2419 {
2420     CacheNode cacheNode;
2421     std::string uri = "mock";
2422     auto rdb = make_shared<RdbStoreMock>();
2423     clouddiskrdbStore_->rdbStore_ = rdb;
2424     clouddiskrdbStore_->rootId_ = "rootId";
2425     int32_t ret = clouddiskrdbStore_->GetNotifyUri(cacheNode, uri);
2426     EXPECT_EQ(ret, E_OK);
2427 }
2428 
2429 /**
2430  * @tc.name: GetNotifyUri
2431  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyUri function
2432  * @tc.type: FUNC
2433  * @tc.require: SR000HRKKA
2434  */
HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest4, TestSize.Level1)2435 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest4, TestSize.Level1)
2436 {
2437     CacheNode cacheNode;
2438     cacheNode.parentCloudId = "root";
2439     std::string uri = "mock";
2440     auto rdb = make_shared<RdbStoreMock>();
2441     clouddiskrdbStore_->rdbStore_ = rdb;
2442     clouddiskrdbStore_->rootId_ = "rootId";
2443     EXPECT_CALL(*rdb, QueryByStep(An<const AbsRdbPredicates &>(),
2444     An<const std::vector<std::string> &>())).WillOnce(Return(ByMove(nullptr)));
2445 
2446     int32_t ret = clouddiskrdbStore_->GetNotifyUri(cacheNode, uri);
2447     EXPECT_EQ(ret, E_RDB);
2448 }
2449 
2450 /**
2451  * @tc.name: GetNotifyData
2452  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyData function
2453  * @tc.type: FUNC
2454  * @tc.require: SR000HRKKA
2455  */
HWTEST_F(CloudDiskRdbStoreTest, GetNotifyDataTest1, TestSize.Level1)2456 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyDataTest1, TestSize.Level1)
2457 {
2458     CacheNode cacheNode;
2459     NotifyData notifyData;
2460     notifyData.uri = "mock";
2461     auto rdb = make_shared<RdbStoreMock>();
2462     clouddiskrdbStore_->rdbStore_ = rdb;
2463     clouddiskrdbStore_->rootId_ = "";
2464 
2465     int32_t ret = clouddiskrdbStore_->GetNotifyData(cacheNode, notifyData);
2466     EXPECT_EQ(ret, E_INVAL_ARG);
2467 }
2468 
2469 /**
2470  * @tc.name: GetNotifyData
2471  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyData function
2472  * @tc.type: FUNC
2473  * @tc.require: SR000HRKKA
2474  */
HWTEST_F(CloudDiskRdbStoreTest, GetNotifyDataTest2, TestSize.Level1)2475 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyDataTest2, TestSize.Level1)
2476 {
2477     CacheNode cacheNode;
2478     NotifyData notifyData;
2479     notifyData.uri = "mock";
2480     auto rdb = make_shared<RdbStoreMock>();
2481     clouddiskrdbStore_->rdbStore_ = rdb;
2482     clouddiskrdbStore_->rootId_ = "rootId";
2483 
2484     int32_t ret = clouddiskrdbStore_->GetNotifyData(cacheNode, notifyData);
2485     EXPECT_EQ(ret, E_OK);
2486 }
2487 
2488 /**
2489  * @tc.name: CheckRootIdValid
2490  * @tc.desc: Verify the CloudDiskRdbStore::CheckRootIdValid function
2491  * @tc.type: FUNC
2492  * @tc.require: SR000HRKKA
2493  */
HWTEST_F(CloudDiskRdbStoreTest, CheckRootIdValidTest1, TestSize.Level1)2494 HWTEST_F(CloudDiskRdbStoreTest, CheckRootIdValidTest1, TestSize.Level1)
2495 {
2496     auto rdb = make_shared<RdbStoreMock>();
2497     clouddiskrdbStore_->rdbStore_ = rdb;
2498     clouddiskrdbStore_->rootId_ = "rootId";
2499 
2500     int32_t ret = clouddiskrdbStore_->CheckRootIdValid();
2501     EXPECT_EQ(ret, E_OK);
2502 }
2503 
2504 /**
2505  * @tc.name: CheckRootIdValid
2506  * @tc.desc: Verify the CloudDiskDataCallBack::CheckRootIdValid function
2507  * @tc.type: FUNC
2508  * @tc.require: SR000HRKKA
2509  */
HWTEST_F(CloudDiskRdbStoreTest, CheckRootIdValidTest2, TestSize.Level1)2510 HWTEST_F(CloudDiskRdbStoreTest, CheckRootIdValidTest2, TestSize.Level1)
2511 {
2512     auto rdb = make_shared<RdbStoreMock>();
2513     clouddiskrdbStore_->rdbStore_ = rdb;
2514     clouddiskrdbStore_->rootId_ = "";
2515 
2516     int32_t ret = clouddiskrdbStore_->CheckRootIdValid();
2517     EXPECT_EQ(ret, E_INVAL_ARG);
2518 }
2519 
2520 /**
2521  * @tc.name: OnCreate
2522  * @tc.desc: Verify the CloudDiskDataCallBack::OnCreate function
2523  * @tc.type: FUNC
2524  * @tc.require: SR000HRKKA
2525  */
HWTEST_F(CloudDiskRdbStoreTest, OnCreateTest1, TestSize.Level1)2526 HWTEST_F(CloudDiskRdbStoreTest, OnCreateTest1, TestSize.Level1)
2527 {
2528     RdbStoreMock store;
2529     CloudDiskDataCallBack CloudDiskDataCallBack;
2530     int32_t ret = CloudDiskDataCallBack.OnCreate(store);
2531     EXPECT_EQ(ret, E_OK);
2532 }
2533 
2534 /**
2535  * @tc.name: OnUpgrade
2536  * @tc.desc: Verify the CloudDiskDataCallBack::OnUpgrade function
2537  * @tc.type: FUNC
2538  * @tc.require: SR000HRKKA
2539  */
HWTEST_F(CloudDiskRdbStoreTest, OnUpgradeTest1, TestSize.Level1)2540 HWTEST_F(CloudDiskRdbStoreTest, OnUpgradeTest1, TestSize.Level1)
2541 {
2542     RdbStoreMock store;
2543     int32_t oldVersion = 13;
2544     int32_t newVersion = 14;
2545     CloudDiskDataCallBack CloudDiskDataCallBack;
2546     int32_t ret = CloudDiskDataCallBack.OnUpgrade(store, oldVersion, newVersion);
2547     EXPECT_EQ(ret, E_OK);
2548 }
2549 
2550 /**
2551  * @tc.name: OnUpgrade
2552  * @tc.desc: Verify the CloudDiskDataCallBack::OnUpgrade function
2553  * @tc.type: FUNC
2554  * @tc.require: SR000HRKKA
2555  */
HWTEST_F(CloudDiskRdbStoreTest, OnUpgradeTest2, TestSize.Level1)2556 HWTEST_F(CloudDiskRdbStoreTest, OnUpgradeTest2, TestSize.Level1)
2557 {
2558     RdbStoreMock store;
2559     int32_t oldVersion = 8;
2560     int32_t newVersion = 14;
2561     CloudDiskDataCallBack CloudDiskDataCallBack;
2562     int32_t ret = CloudDiskDataCallBack.OnUpgrade(store, oldVersion, newVersion);
2563     EXPECT_EQ(ret, E_OK);
2564 }
2565 } // namespace OHOS::FileManagement::CloudDisk::Test