1 /*
2  * Copyright (c) 2023 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 <mutex>
17 #include <string>
18 #include <memory>
19 #include "gtest/gtest.h"
20 #include "rdb_adapter.h"
21 #include "distributed_device_profile_constants.h"
22 #include "distributed_device_profile_errors.h"
23 #include "distributed_device_profile_log.h"
24 #include "rdb_helper.h"
25 #include "rdb_store.h"
26 #include "result_set.h"
27 #include "rdb_open_callback.h"
28 
29 namespace OHOS {
30 namespace DistributedDeviceProfile {
31 using namespace testing::ext;
32 using namespace OHOS::NativeRdb;
33 
34 namespace {
35     const std::string TAG = "rdbAdapterTest";
36     const std::string SUCCESS_CREATE_TABLE_SQL = "CREATE TABLE IF NOT EXISTS trust_device_table\n"
37             "(\n"
38             "    deviceId     TEXT PRIMARY KEY,\n"
39             "    deviceIdType INTEGER,\n"
40             "    deviceIdHash TEXT,\n"
41             "    status       INTEGER\n"
42             ");";
43     const std::string UN_SUCCESS_CREATE_TABLE_SQL = "NOT EXISTS \n"
44             "(\n"
45             "    deviceId     TEXT PRIMARY KEY,\n"
46             "    deviceIdType INTEGER,\n"
47             "    deviceIdHash TEXT,\n"
48             "    status       INTEGER\n"
49             ");";
50     std::shared_ptr<RdbAdapter> store = nullptr;
51     std::mutex g_rdbAdapterTestMtx;
52 }
53 
54 class RdbAdapterTest : public testing::Test {
55 public:
56     static void SetUpTestCase(void);
57     static void TearDownTestCase(void);
58     void SetUp();
59     void TearDown();
60 };
61 
SetUpTestCase(void)62 void RdbAdapterTest::SetUpTestCase(void)
63 {
64     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
65     store = std::make_shared<RdbAdapter>();
66 }
67 
TearDownTestCase(void)68 void RdbAdapterTest::TearDownTestCase(void)
69 {
70     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
71     store->Init();
72     store->CreateTable("DROP TABLE IF EXISTS trust_device_table");
73     store->UnInit();
74 }
75 
SetUp()76 void RdbAdapterTest::SetUp()
77 {
78     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
79     store->Init();
80     store->CreateTable("DROP TABLE IF EXISTS trust_device_table");
81 }
82 
TearDown()83 void RdbAdapterTest::TearDown()
84 {
85     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
86     store->UnInit();
87 }
88 
89 
90 /**
91  * @tc.name:
92  * @tc.desc: GetRDBPtr success
93  * @tc.type: FUNC
94  * @tc.require:
95  */
96 HWTEST_F(RdbAdapterTest, GetRDBPtr001, TestSize.Level1)
97 {
98     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
99     store->UnInit();
100     int32_t errCode = store->GetRDBPtr();
101     EXPECT_EQ(errCode, DP_SUCCESS);
102 }
103 
104 
105 /**
106  * @tc.name:
107  * @tc.desc: Init success
108  * @tc.type: FUNC
109  * @tc.require:
110  */
111 HWTEST_F(RdbAdapterTest, Init001, TestSize.Level1)
112 {
113     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
114     store->UnInit();
115     int32_t errCode = store->Init();
116     EXPECT_EQ(errCode, DP_SUCCESS);
117 }
118 
119 /**
120  * @tc.name:
121  * @tc.desc: UnInit success
122  * @tc.type: FUNC
123  * @tc.require:
124  */
125 HWTEST_F(RdbAdapterTest, UnInit001, TestSize.Level1)
126 {
127     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
128     int32_t errCode = store->UnInit();
129     EXPECT_EQ(errCode, DP_SUCCESS);
130 }
131 
132 /**
133  * @tc.name:
134  * @tc.desc: CreateTable success
135  * @tc.type: FUNC
136  * @tc.require:
137  */
138 HWTEST_F(RdbAdapterTest, CreateTable001, TestSize.Level1)
139 {
140     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
141     int32_t errCode = store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
142     EXPECT_EQ(errCode, DP_SUCCESS);
143 }
144 
145 /**
146  * @tc.name:
147  * @tc.desc: CreateTable failed
148  * @tc.type: FUNC
149  * @tc.require:
150  */
151 HWTEST_F(RdbAdapterTest, CreateTable002, TestSize.Level1)
152 {
153     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
154     int32_t errCode = store->CreateTable(UN_SUCCESS_CREATE_TABLE_SQL);
155     EXPECT_EQ(errCode, DP_RDBADAPTER_CREATE_TABLE_FAIL);
156 }
157 
158 /**
159  * @tc.name: CreateTable003
160  * @tc.desc: CreateTable failed, RDBStore_ is null.
161  * @tc.type: FUNC
162  * @tc.require:
163  */
164 HWTEST_F(RdbAdapterTest, CreateTable003, TestSize.Level1)
165 {
166     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
167     store->UnInit();
168     int32_t errCode = store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
169     EXPECT_EQ(errCode, DP_RDB_DB_PTR_NULL);
170     store->Init();
171 }
172 
173 /**
174  * @tc.name:
175  * @tc.desc: Put Success
176  * @tc.type: FUNC
177  * @tc.require:
178  */
179 HWTEST_F(RdbAdapterTest, Put001, TestSize.Level1)
180 {
181     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
182     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
183     int64_t outRowId = 0;
184     std::string table = "trust_device_table";
185     ValuesBucket values;
186     values.Clear();
187     values.PutString("deviceId", std::string("111aaa"));
188     values.PutInt("deviceIdType", 3);
189     values.PutString("deviceIdHash", std::string("222bbb"));
190     values.PutInt("status", 1);
191     int32_t putErrCode = store->Put(outRowId, table, values);
192     EXPECT_EQ(putErrCode, DP_SUCCESS);
193     EXPECT_EQ(outRowId, 1);
194 }
195 
196 /**
197  * @tc.name:
198  * @tc.desc: Put table does not exist failed
199  * @tc.type: FUNC
200  * @tc.require:
201  */
202 HWTEST_F(RdbAdapterTest, Put002, TestSize.Level1)
203 {
204     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
205     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
206     int64_t outRowId = 0;
207     std::string table = "trust_xxxdevice_table";
208     ValuesBucket values;
209     values.Clear();
210     values.PutString("deviceId", std::string("111aaa"));
211     values.PutInt("deviceIdType", 3);
212     values.PutString("deviceIdHash", std::string("222bbb"));
213     values.PutInt("status", 1);
214     int32_t putErrCode = store->Put(outRowId, table, values);
215     EXPECT_EQ(putErrCode, DP_RDBADAPTER_TABLE_NOT_EXIST);
216 }
217 
218 /**
219  * @tc.name:
220  * @tc.desc: Put failed
221  * @tc.type: FUNC
222  * @tc.require:
223  */
224 HWTEST_F(RdbAdapterTest, Put003, TestSize.Level1)
225 {
226     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
227     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
228     int64_t outRowId1 = 0;
229     int64_t outRowId2 = 0;
230     std::string table = "trust_device_table";
231     ValuesBucket value1;
232     value1.Clear();
233     value1.PutString("deviceId", std::string("111aaa"));
234     value1.PutInt("deviceIdType", 3);
235     value1.PutString("deviceIdHash", std::string("222bbb"));
236     value1.PutInt("status", 1);
237     int32_t putErrCode1 = store->Put(outRowId1, table, value1);
238     EXPECT_EQ(putErrCode1, DP_SUCCESS);
239     EXPECT_EQ(outRowId1, 1);
240     ValuesBucket value2;
241     value2.Clear();
242     value2.PutString("deviceId", std::string("111aaa"));
243     value2.PutInt("deviceIdType", 3);
244     value2.PutString("deviceIdHash", std::string("222bbb"));
245     value2.PutInt("status", 1);
246     int32_t putErrCode2 = store->Put(outRowId2, table, value2);
247     EXPECT_EQ(putErrCode2, DP_RDBADAPTER_PUT_FAIL);
248     EXPECT_EQ(outRowId2, 0);
249 }
250 
251 /**
252  * @tc.name: Put004
253  * @tc.desc: Put failed, RDBStore_ is null.
254  * @tc.type: FUNC
255  * @tc.require:
256  */
257 HWTEST_F(RdbAdapterTest, Put004, TestSize.Level1)
258 {
259     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
260     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
261     int64_t outRowId = 0;
262     std::string table = "trust_device_table";
263     ValuesBucket values;
264     values.Clear();
265     values.PutString("deviceId", std::string("111aaa"));
266     values.PutInt("deviceIdType", 3);
267     values.PutString("deviceIdHash", std::string("222bbb"));
268     values.PutInt("status", 1);
269     store->UnInit();
270     int32_t putErrCode = store->Put(outRowId, table, values);
271     EXPECT_EQ(putErrCode, DP_RDB_DB_PTR_NULL);
272     store->Init();
273 }
274 
275 /**
276  * @tc.name:
277  * @tc.desc: Delete success
278  * @tc.type: FUNC
279  * @tc.require:
280  */
281 HWTEST_F(RdbAdapterTest, Delete001, TestSize.Level1)
282 {
283     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
284     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
285     int64_t outRowId = 0;
286     std::string table = "trust_device_table";
287     ValuesBucket values;
288     values.Clear();
289     values.PutString("deviceId", std::string("111aaa"));
290     values.PutInt("deviceIdType", 3);
291     values.PutString("deviceIdHash", std::string("222bbb"));
292     values.PutInt("status", 1);
293     store->Put(outRowId, table, values);
294 
295     int32_t deleteRows = 0;
296     std::string whereClause = "deviceId = ?";
297     ValueObject valueObject(std::string("111aaa"));
298     const std::vector<ValueObject>& bindArgs = {valueObject};
299 
300     int32_t deleteErrCode = store->Delete(deleteRows, table, whereClause, bindArgs);
301     EXPECT_EQ(deleteErrCode, DP_SUCCESS);
302     EXPECT_EQ(deleteRows, 1);
303 }
304 
305 /**
306  * @tc.name:
307  * @tc.desc: Delete table does not exist failed
308  * @tc.type: FUNC
309  * @tc.require:
310  */
311 HWTEST_F(RdbAdapterTest, Delete002, TestSize.Level1)
312 {
313     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
314     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
315     int64_t outRowId = 0;
316     std::string table = "trust_device_table";
317     ValuesBucket values;
318     values.Clear();
319     values.PutString("deviceId", std::string("111aaa"));
320     values.PutInt("deviceIdType", 3);
321     values.PutString("deviceIdHash", std::string("222bbb"));
322     values.PutInt("status", 1);
323     store->Put(outRowId, table, values);
324 
325     int32_t deleteRows = 0;
326     std::string deleteTable = "trust_xxxdevice_table";
327     std::string whereClause = "deviceId = ?";
328     ValueObject valueObject(std::string("111aaa"));
329     const std::vector<ValueObject>& bindArgs = {valueObject};
330 
331     int32_t deleteErrCode = store->Delete(deleteRows, deleteTable, whereClause, bindArgs);
332     EXPECT_EQ(deleteErrCode, DP_RDBADAPTER_TABLE_NOT_EXIST);
333 }
334 
335 /**
336  * @tc.name:
337  * @tc.desc: Delete failed
338  * @tc.type: FUNC
339  * @tc.require:
340  */
341 HWTEST_F(RdbAdapterTest, Delete003, TestSize.Level1)
342 {
343     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
344     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
345     int64_t outRowId = 0;
346     std::string table = "trust_device_table";
347     ValuesBucket values;
348     values.Clear();
349     values.PutString("deviceId", std::string("111aaa"));
350     values.PutInt("deviceIdType", 3);
351     values.PutString("deviceIdHash", std::string("222bbb"));
352     values.PutInt("status", 1);
353     store->Put(outRowId, table, values);
354 
355     int32_t deleteRows = 0;
356     std::string deleteTable = "trust_device_table";
357     std::string whereClause = "xxxdeviceId = ?";
358     ValueObject valueObject(std::string("111aaa"));
359     const std::vector<ValueObject>& bindArgs = {valueObject};
360 
361     int32_t deleteErrCode = store->Delete(deleteRows, deleteTable, whereClause, bindArgs);
362     EXPECT_EQ(deleteErrCode, DP_RDBADAPTER_DELETE_FAIL);
363 }
364 
365 /**
366  * @tc.name: Delete004
367  * @tc.desc: Delete failed, RDBStore_ is null.
368  * @tc.type: FUNC
369  * @tc.require:
370  */
371 HWTEST_F(RdbAdapterTest, Delete004, TestSize.Level1)
372 {
373     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
374     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
375     int64_t outRowId = 0;
376     std::string table = "trust_device_table";
377     ValuesBucket values;
378     values.Clear();
379     values.PutString("deviceId", std::string("111aaa"));
380     values.PutInt("deviceIdType", 3);
381     values.PutString("deviceIdHash", std::string("222bbb"));
382     values.PutInt("status", 1);
383     store->Put(outRowId, table, values);
384 
385     int32_t deleteRows = 0;
386     std::string whereClause = "deviceId = ?";
387     ValueObject valueObject(std::string("111aaa"));
388     const std::vector<ValueObject>& bindArgs = {valueObject};
389 
390     store->UnInit();
391     int32_t deleteErrCode = store->Delete(deleteRows, table, whereClause, bindArgs);
392     EXPECT_EQ(deleteErrCode, DP_RDB_DB_PTR_NULL);
393     store->Init();
394 }
395 
396 /**
397  * @tc.name:
398  * @tc.desc: Update success
399  * @tc.type: FUNC
400  * @tc.require:
401  */
402 HWTEST_F(RdbAdapterTest, Update001, TestSize.Level1)
403 {
404     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
405     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
406     int64_t outRowId = 0;
407     std::string table = "trust_device_table";
408     ValuesBucket value1;
409     value1.Clear();
410     value1.PutString("deviceId", std::string("111aaa"));
411     value1.PutInt("deviceIdType", 3);
412     value1.PutString("deviceIdHash", std::string("abcdef"));
413     value1.PutInt("status", 1);
414     store->Put(outRowId, table, value1);
415     ValuesBucket value2;
416     value2.Clear();
417     value2.PutString("deviceId", std::string("222bbb"));
418     value2.PutInt("deviceIdType", 3);
419     value2.PutString("deviceIdHash", std::string("abcdef"));
420     value2.PutInt("status", 1);
421     store->Put(outRowId, table, value2);
422 
423     ValuesBucket newValues;
424     newValues.Clear();
425     newValues.PutString("deviceId", std::string("111aaa"));
426     newValues.PutInt("deviceIdType", 3);
427     newValues.PutString("deviceIdHash", std::string("222bbb"));
428     newValues.PutInt("status", 2);
429 
430     int32_t changedRows = 0;
431     std::string whereClause = "deviceId = ?";
432     ValueObject valueObject(std::string("111aaa"));
433     const std::vector<ValueObject>& bindArgs = {valueObject};
434 
435     int32_t updateErrCode = store->Update(changedRows, table, newValues, whereClause, bindArgs);
436     EXPECT_EQ(updateErrCode, DP_SUCCESS);
437     std::shared_ptr<ResultSet> resultSet = store->Get("SELECT * FROM trust_device_table where deviceId = '111aaa'");
438     resultSet->GoToFirstRow();
439     RowEntity rowEntity;
440     resultSet->GetRow(rowEntity);
441     int32_t status = rowEntity.Get("status");
442     EXPECT_EQ(status, 2);
443 }
444 
445 /**
446  * @tc.name:
447  * @tc.desc: Update table does not exist failed
448  * @tc.type: FUNC
449  * @tc.require:
450  */
451 HWTEST_F(RdbAdapterTest, Update002, TestSize.Level1)
452 {
453     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
454     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
455     int64_t outRowId = 0;
456     std::string table = "trust_device_table";
457     ValuesBucket value1;
458     value1.Clear();
459     value1.PutString("deviceId", std::string("111aaa"));
460     value1.PutInt("deviceIdType", 3);
461     value1.PutString("deviceIdHash", std::string("abcdef"));
462     value1.PutInt("status", 1);
463     store->Put(outRowId, table, value1);
464 
465     ValuesBucket newValues;
466     newValues.Clear();
467     newValues.PutString("deviceId", std::string("111aaa"));
468     newValues.PutInt("deviceIdType", 3);
469     newValues.PutString("deviceIdHash", std::string("222bbb"));
470     newValues.PutInt("status", 2);
471 
472     std::string failTable = "trust_xxxdevice_table";
473     int32_t changedRows = 0;
474     std::string whereClause = "deviceId = ?";
475     ValueObject valueObject(std::string("111aaa"));
476     const std::vector<ValueObject>& bindArgs = {valueObject};
477 
478     int32_t updateErrCode = store->Update(changedRows, failTable, newValues, whereClause, bindArgs);
479     EXPECT_EQ(updateErrCode, DP_RDBADAPTER_TABLE_NOT_EXIST);
480 }
481 
482 /**
483  * @tc.name:
484  * @tc.desc: Update failed
485  * @tc.type: FUNC
486  * @tc.require:
487  */
488 HWTEST_F(RdbAdapterTest, Update003, TestSize.Level1)
489 {
490     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
491     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
492     int64_t outRowId = 0;
493     std::string table = "trust_device_table";
494     ValuesBucket value1;
495     value1.Clear();
496     value1.PutString("deviceId", std::string("111aaa"));
497     value1.PutInt("deviceIdType", 3);
498     value1.PutString("deviceIdHash", std::string("abcdef"));
499     value1.PutInt("status", 1);
500     store->Put(outRowId, table, value1);
501 
502     ValuesBucket newValues;
503     newValues.Clear();
504     newValues.PutString("deviceId", std::string("111aaa"));
505     newValues.PutInt("deviceIdType", 3);
506     newValues.PutString("deviceIdHash", std::string("222bbb"));
507     newValues.PutInt("status", 2);
508 
509     int32_t changedRows = 0;
510     std::string whereClause = "xxxdeviceId = ?";
511     ValueObject valueObject(std::string("111aaa"));
512     const std::vector<ValueObject>& bindArgs = {valueObject};
513 
514     int32_t updateErrCode = store->Update(changedRows, table, newValues, whereClause, bindArgs);
515 
516     EXPECT_EQ(updateErrCode, DP_RDBADAPTER_UPDATE_FAIL);
517 }
518 
519 /**
520  * @tc.name: Update004
521  * @tc.desc: Update failed, RDBStore_ is null.
522  * @tc.type: FUNC
523  * @tc.require:
524  */
525 HWTEST_F(RdbAdapterTest, Update004, TestSize.Level1)
526 {
527     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
528     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
529     int64_t outRowId = 0;
530     std::string table = "trust_device_table";
531     ValuesBucket value1;
532     value1.Clear();
533     value1.PutString("deviceId", std::string("111aaa"));
534     value1.PutInt("deviceIdType", 3);
535     value1.PutString("deviceIdHash", std::string("abcdef"));
536     value1.PutInt("status", 1);
537     store->Put(outRowId, table, value1);
538     ValuesBucket value2;
539     value2.Clear();
540     value2.PutString("deviceId", std::string("222bbb"));
541     value2.PutInt("deviceIdType", 3);
542     value2.PutString("deviceIdHash", std::string("abcdef"));
543     value2.PutInt("status", 1);
544     store->Put(outRowId, table, value2);
545 
546     ValuesBucket newValues;
547     newValues.Clear();
548     newValues.PutString("deviceId", std::string("111aaa"));
549     newValues.PutInt("deviceIdType", 3);
550     newValues.PutString("deviceIdHash", std::string("222bbb"));
551     newValues.PutInt("status", 2);
552 
553     int32_t changedRows = 0;
554     std::string whereClause = "deviceId = ?";
555     ValueObject valueObject(std::string("111aaa"));
556     const std::vector<ValueObject>& bindArgs = {valueObject};
557 
558     store->UnInit();
559     int32_t updateErrCode = store->Update(changedRows, table, newValues, whereClause, bindArgs);
560     EXPECT_EQ(updateErrCode, DP_RDB_DB_PTR_NULL);
561     store->Init();
562 }
563 
564 /**
565  * @tc.name:
566  * @tc.desc: Get success
567  * @tc.type: FUNC
568  * @tc.require:
569  */
570 HWTEST_F(RdbAdapterTest, Get001, TestSize.Level1)
571 {
572     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
573     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
574     int64_t outRowId = 0;
575     std::string table = "trust_device_table";
576     ValuesBucket value1;
577     value1.Clear();
578     value1.PutString("deviceId", std::string("111aaa"));
579     value1.PutInt("deviceIdType", 3);
580     value1.PutString("deviceIdHash", std::string("abcdef"));
581     value1.PutInt("status", 1);
582     store->Put(outRowId, table, value1);
583 
584     std::shared_ptr<ResultSet> resultSet = store->Get("SELECT * FROM trust_device_table where deviceId = '111aaa'");
585     EXPECT_NE(resultSet, nullptr);
586 }
587 
588 /**
589  * @tc.name: Get002
590  * @tc.desc: Get failed, RDBStore_ is null.
591  * @tc.type: FUNC
592  * @tc.require:
593  */
594 HWTEST_F(RdbAdapterTest, Get002, TestSize.Level1)
595 {
596     std::lock_guard<std::mutex> lock(g_rdbAdapterTestMtx);
597     store->CreateTable(SUCCESS_CREATE_TABLE_SQL);
598     int64_t outRowId = 0;
599     std::string table = "trust_device_table";
600     ValuesBucket value1;
601     value1.Clear();
602     value1.PutString("deviceId", std::string("111aaa"));
603     value1.PutInt("deviceIdType", 3);
604     value1.PutString("deviceIdHash", std::string("abcdef"));
605     value1.PutInt("status", 1);
606     store->Put(outRowId, table, value1);
607 
608     store->UnInit();
609     std::shared_ptr<ResultSet> resultSet = store->Get("SELECT * FROM trust_device_table where deviceId = '111aaa'");
610     EXPECT_EQ(resultSet, nullptr);
611     store->Init();
612 }
613 } // namespace DistributedDeviceProfile
614 } // namespace OHOS
615