diff --git a/distributeddatamgr/BUILD.gn b/distributeddatamgr/BUILD.gn
index 67048ff556cda60d5033bc36e59b14a175a5d151..dfbe9f096a508a1a47bf1aa0690355f43a725efc 100644
--- a/distributeddatamgr/BUILD.gn
+++ b/distributeddatamgr/BUILD.gn
@@ -18,6 +18,7 @@ group("distributeddatamgr") {
deps = [
"dataObjectjstest/hap:dataObject_js_test",
"dataSharejstest/hap:dataShare_js_test",
+ "distributedKVStoretest:distributedKVStoretest",
"kvStoretest:kvStoretest",
"preferencesjstest/hap:preferences_js_test",
"relationalStorejstest/hap:relationalstore_js_test",
diff --git a/distributeddatamgr/distributedKVStoretest/BUILD.gn b/distributeddatamgr/distributedKVStoretest/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..1bf108b80a42d3110234cd5310b69da635c156a8
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//test/xts/tools/build/suite.gni")
+
+group("distributedKVStoretest") {
+ testonly = true
+ if (is_standard_system) {
+ deps = [ "distributedKVStorejstest/hap:distributedKvStore_js_test" ]
+ }
+}
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/BUILD.gn b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..5cbcab92b2ad2d1ea71bef28cd06a804ddf66a9f
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/BUILD.gn
@@ -0,0 +1,35 @@
+# Copyright (C) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//test/xts/tools/build/suite.gni")
+
+ohos_js_hap_suite("distributedKvStore_js_test") {
+ hap_profile = "./src/main/config.json"
+ deps = [
+ ":distributedkvStore_js_assets",
+ ":distributedkvStore_resources",
+ ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActsDistributedKvStoreJsTest"
+ subsystem_name = "distributeddatamgr"
+ part_name = "kv_store"
+}
+ohos_js_assets("distributedkvStore_js_assets") {
+ js2abc = true
+ hap_profile = "./src/main/config.json"
+ source_dir = "./src/main/js"
+}
+ohos_resources("distributedkvStore_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/Test.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..2e559469188b2aebdd66345dbe88ad3729452897
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/Test.json
@@ -0,0 +1,20 @@
+{
+ "description": "Configuration for hjunit demo Tests",
+ "driver": {
+ "type": "OHJSUnitTest",
+ "test-timeout": "1200000",
+ "testcase-timeout": 60000,
+ "bundle-name": "ohos.acts.distributedKvStore",
+ "package-name": "ohos.acts.distributedKvStore",
+ "shell-timeout": "60000"
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "ActsDistributedKvStoreJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/signature/openharmony_sx.p7b b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5
Binary files /dev/null and b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/signature/openharmony_sx.p7b differ
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/config.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..4eb191549f534c9a2de1f7641f9b57f3f80e2595
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/config.json
@@ -0,0 +1,95 @@
+{
+ "app": {
+ "bundleName": "ohos.acts.distributedKvStore",
+ "vendor": "example",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.acts.distributedKvStore",
+ "name": ".entry",
+ "mainAbility": ".MainAbility",
+ "srcPath":"",
+ "deviceType": [
+ "default",
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "srcLanguage": "js",
+ "srcPath": "MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:MainAbility_desc",
+ "label": "$string:MainAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".TestAbility",
+ "srcLanguage": "js",
+ "srcPath": "TestAbility",
+ "icon": "$media:icon",
+ "description": "$string:TestAbility_desc",
+ "label": "$string:TestAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ }
+ },
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": ".TestAbility",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ],
+ "testRunner": {
+ "name": "OpenHarmonyTestRunner",
+ "srcPath": "TestRunner"
+ }
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/app.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..6a06f7f6cad18519bf28b42a2a171b69d2140f32
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/app.js
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate');
+ },
+ onDestroy() {
+ console.info('TestApplication onDestroy');
+ }
+};
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/i18n/en-US.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/i18n/en-US.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/i18n/zh-CN.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/i18n/zh-CN.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.css b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..e19021816bc61bc4cb5128677386b9789132e270
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.css
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 100px;
+}
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.hml b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..1c26cf73deab18390844a53a103458b10ed11e93
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{title}}
+
+
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..0e75afd47524c4d9ccc955483c69d1d21cda999a
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/MainAbility/pages/index/index.js
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+const injectRef = Object.getPrototypeOf(global) || global
+injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
+
+export default {
+ data: {
+ title: ''
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/app.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/app.js
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+import { Hypium } from '@ohos/hypium'
+import testsuite from '../test/List.test'
+
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate')
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ console.info('start run testcase!!!')
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ },
+ onDestroy() {
+ console.info("TestApplication onDestroy");
+ }
+};
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/i18n/en-US.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/i18n/en-US.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/i18n/zh-CN.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/i18n/zh-CN.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.css b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..b1bcd43387ba131cc1d30975ff7508a6f8084a4b
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.css
@@ -0,0 +1,30 @@
+.container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 60px;
+ text-align: center;
+ width: 100%;
+ height: 40%;
+ margin: 10px;
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.hml b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f629c71a9be857db6cdf94149652a191b9b272ea
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestAbility/pages/index/index.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
+
+
+
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestRunner/OpenHarmonyTestRunner.js
new file mode 100644
index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/TestRunner/OpenHarmonyTestRunner.js
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+
+function translateParamsToString(parameters) {
+ const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s itName',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s package', '-s dryRun'
+ ])
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams += ' ' + key + ' ' + parameters[key]
+ }
+ }
+ return targetParams.trim()
+}
+
+ export default {
+ onPrepare() {
+ console.info('OpenHarmonyTestRunner OnPrepare')
+ },
+ onRun() {
+ console.log('OpenHarmonyTestRunner onRun run')
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+
+ var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
+
+ var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
+ cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
+ var debug = abilityDelegatorArguments.parameters["-D"]
+ console.info('debug value : '+debug)
+ if (debug == 'true')
+ {
+ cmd += ' -D'
+ }
+ console.info('cmd : '+cmd)
+ abilityDelegator.executeShellCommand(cmd, (err, data) => {
+ console.info('executeShellCommand : err : ' + JSON.stringify(err));
+ console.info('executeShellCommand : data : ' + data.stdResult);
+ console.info('executeShellCommand : data : ' + data.exitCode);
+ })
+ }
+};
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/DeviceKvStoreKVCallbackJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/DeviceKvStoreKVCallbackJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..b112b791c3666df9570e861bdcc6a48f962d53a6
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/DeviceKvStoreKVCallbackJsTest.js
@@ -0,0 +1,2425 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import dataSharePredicates from '@ohos.data.dataSharePredicates';
+import abilityFeatureAbility from '@ohos.ability.featureAbility'
+
+var context = abilityFeatureAbility.getContext();
+const KEY_TEST_INT_ELEMENT = 'key_test_int_2';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float_2';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean_2';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
+const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
+
+const VALUE_TEST_INT_ELEMENT = 1234;
+const VALUE_TEST_FLOAT_ELEMENT = 4321.12;
+const VALUE_TEST_BOOLEAN_ELEMENT = true;
+const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
+const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
+
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'dstoreId';
+var kvManager = null;
+var kvStore = null;
+var localDeviceId = null;
+const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
+const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
+var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
+
+function sleep(ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+}
+
+function putBatchString(len, prefix) {
+ let entries = [];
+ for (let i = 0; i < len; i++) {
+ var entry = {
+ key : prefix + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ return entries;
+}
+export default function deviceKvStoreCallbackTest(){
+describe('deviceKvStoreCallbackTest', function () {
+ const config = {
+ bundleName : TEST_BUNDLE_NAME,
+ context:context
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll config:'+ JSON.stringify(config));
+ await factory.createKVManager(config).then((manager) => {
+ kvManager = manager;
+ console.info('beforeAll createKVManager success');
+ }).catch((err) => {
+ console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
+ kvStore = store;
+ console.info('beforeAll getKVStore for getDeviceId success');
+ }).catch((err) => {
+ console.error('beforeAll getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ var getDeviceId = new Promise((resolve, reject) => {
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('beforeAll on data change: ' + JSON.stringify(data));
+ resolve(data.deviceId);
+ });
+ kvStore.put("getDeviceId", "byPut").then((data) => {
+ console.info('beforeAll put success');
+ expect(data == undefined).assertTrue();
+ });
+ setTimeout(() => {
+ reject(new Error('not resolved in 2 second, reject it.'))
+ }, 2000);
+ });
+ await getDeviceId.then(function(deviceId) {
+ console.info('beforeAll getDeviceId ' + JSON.stringify(deviceId));
+ localDeviceId = deviceId;
+ }).catch((error) => {
+ console.error('beforeAll can NOT getDeviceId, fail: ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID);
+ kvStore = null;
+ console.info('beforeAll end');
+ done();
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ kvManager = null;
+ kvStore = null;
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach' + JSON.stringify(options));
+ await kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
+ kvStore = store;
+ console.info('beforeEach getKVStore success');
+ done();
+ });
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, async function (err, data) {
+ console.info('afterEach closeKVStore success');
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err, data) {
+ console.info('afterEach deleteKVStore success');
+ done();
+ });
+ });
+ kvStore = null;
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(String) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(String) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0100 put success');
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0100 put fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch (e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0100 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(String) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(String) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0200');
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4095; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT+'102', str, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT+'102', function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0200 get success');
+ expect(str == data).assertTrue();
+ done();
+ });
+ });
+ }catch (e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTSTRING_0200 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETSTRING_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(String) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(String) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0100');
+ try{
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0100 get success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0100 get fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0100 get e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETSTRING_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(String) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(String) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0200');
+ try{
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0200 get success');
+ expect((err == undefined) && (VALUE_TEST_STRING_ELEMENT == data)).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETSTRING_0200 get e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTINT_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTINT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0100 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0100 get success');
+ expect((err == undefined) && (VALUE_TEST_INT_ELEMENT == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTINT_0100 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTINT_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTINT_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0200');
+ try {
+ var intValue = 987654321;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0200 get success');
+ expect((err == undefined) && (intValue == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTINT_0200 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTINT_0300
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTINT_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0300');
+ try {
+ var intValue = Number.MIN_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0300 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0300 get success');
+ expect((err == undefined) && (intValue == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTINT_0300 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTINT_0400
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTINT_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0400');
+ try {
+ var intValue = Number.MAX_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0400 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTINT_0400 get success');
+ expect((err == undefined) && (intValue == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTINT_0400 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETINT_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(Int) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Int) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETINT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETINT_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETINT_0100 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETINT_0100 get success');
+ expect((err == undefined) && (VALUE_TEST_INT_ELEMENT == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETINT_0100 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETINT_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(Int) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Int) testcase 00
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETINT_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETINT_0200');
+ try {
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETINT_0200 get success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETINT_0200 get fail');
+ }
+ done();
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETINT_0200 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBOOLEAN_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Bool) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Bool) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBOOLEAN_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBOOLEAN_0100');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBOOLEAN_0100 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBOOLEAN_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(Bool) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Bool) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0100');
+ try {
+ await kvStore.get(localDeviceId, KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0100 get success');
+ expect(null).assertFail();
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0100 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(Bool) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Bool) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0200');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0200 get success');
+ expect((err == undefined) && (VALUE_TEST_BOOLEAN_ELEMENT == data)).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETBOOLEAN_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Float) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Float) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0100');
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0100 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(Float) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Float) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0200');
+ try {
+ var floatValue = 123456.654321;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0200 get success');
+ expect((err == undefined) && (floatValue == data)).assertTrue();
+ done();
+ })
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0300
+ * @tc.desc Test Js Api DeviceKvStore.Put(Float) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Float) testcase 00
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0300');
+ try {
+ var floatValue = 123456.0;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0300 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0300 get success');
+ expect((err == undefined) && (floatValue == data)).assertTrue();
+ done();
+ })
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0300 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0400
+ * @tc.desc Test Js Api DeviceKvStore.Put(Float) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Float) testcase 00
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0400');
+ try {
+ var floatValue = 123456.00;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0400 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0400 get success');
+ expect((err == undefined) && (floatValue == data)).assertTrue();
+ done();
+ })
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTFLOAT_0400 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETFLOAT_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(Float) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Float) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETFLOAT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETFLOAT_0100');
+ try {
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETFLOAT_0100 get success');
+ expect(null).assertFail();
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETFLOAT_0100 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETFLOAT_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteString() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteString() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0100');
+ try {
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0100 delete success');
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0100 delete fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteString() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteString() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0200');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0200 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETESTRING_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEINT_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteInt() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteInt() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0100');
+ try{
+ await kvStore.delete(KEY_TEST_INT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0100 get success');
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0100 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEINT_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteInt() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteInt() testcase 00
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0200');
+ try{
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0200 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEINT_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteFloat() testcase 001
+ * @tc.type: FUNC
+ * @tc.name issueNumber
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0100');
+ try{
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0100 get success');
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0100 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteFloat() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteFloat() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0200');
+ try{
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0200 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEFLOAT_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteBool() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteBool() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0100');
+ try{
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0100 get success');
+ } else {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0100 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteBool() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteBool() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0200');
+ try{
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0200 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0200 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEBOOLEAN_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.OnChange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.OnChange() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0100');
+ try {
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0100 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0100 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.OnChange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.OnChange() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0200');
+ try {
+ kvStore.on('dataChange', 1, function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0200 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0200 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.OnChange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.OnChange() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0300');
+ try {
+ kvStore.on('dataChange', 2, function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0300 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0300 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONCHANGE_0300 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.OnSyncComplete() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.OnSyncComplete() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100 put failed:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PULL_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode);
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0100 no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.OnSyncComplete() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.OnSyncComplete() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200 put failed:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode);
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0200 no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.OnSyncComplete() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.OnSyncComplete() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300 put failed:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_PULL;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode);
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ONSYNCCOMPLETE_0300 no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.SetSyncRange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.SetSyncRange() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0100');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['C', 'D'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0100 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.SetSyncRange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.SetSyncRange() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0200');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['B', 'C'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0200 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.SetSyncRange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.SetSyncRange() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0300');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['A', 'B'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0300 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_SETSYNCRANGE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_string_key', function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 'batch_test_string_value').assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.INTEGER,
+ value : 222
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_number_key', function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 222).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.FLOAT,
+ value : 2.0
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_number_key', function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.0).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.DOUBLE,
+ value : 2.00
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_number_key', function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.00).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 005
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500');
+ try {
+ var bo = false;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BOOLEAN,
+ value : bo
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_bool_key', function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == bo).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 006
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_bool_key', function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_PUTBATCH_0600 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteBatch() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteBatch() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100');
+ try {
+ let entries = [];
+ let keys = [];
+ for (var i = 0; i < 5; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ keys.push(key + i);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteBatch() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteBatch() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0200');
+ try {
+ let keys = ['batch_test_string_key1', 'batch_test_string_key2'];
+ await kvStore.deleteBatch(keys, function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0200 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.DeleteBatch() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.DeleteBatch() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = ['batch_test_string_key1', 'batch_test_string_keya'];
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_DELETEBATCH_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.startTransaction() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.startTransaction() testcase 00
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 0' + data)
+ count++;
+ });
+ await kvStore.startTransaction(async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 startTransaction success');
+ expect(err == undefined).assertTrue();
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.commit(async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 commit success');
+ expect(err == undefined).assertTrue();
+ await sleep(2000);
+ expect(count == 1).assertTrue();
+ done();
+ });
+ });
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.startTransaction() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.startTransaction() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 0' + data)
+ count++;
+ });
+ await kvStore.startTransaction(async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 startTransaction success');
+ expect(err == undefined).assertTrue();
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.rollback(async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 rollback success');
+ expect(err == undefined).assertTrue();
+ await sleep(2000);
+ expect(count == 0).assertTrue();
+ done();
+ });
+ });
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.startTransaction() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.startTransaction() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0300');
+ try {
+ await kvStore.startTransaction(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0300 startTransaction success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0300 startTransaction fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0400
+ * @tc.desc Test Js Api DeviceKvStore.9.startTransaction() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.startTransaction() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0400');
+ try {
+ await kvStore.startTransaction('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0400 startTransaction success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0400 startTransaction fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0500
+ * @tc.desc Test Js Api DeviceKvStore.9.startTransaction() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.startTransaction() testcase 005
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0500');
+ try {
+ await kvStore.startTransaction(2.000, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0500 startTransaction success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0500 startTransaction fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_STARTTRANSACTION_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_COMMIT_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.Commit() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.Commit() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_COMMIT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0100');
+ try {
+ await kvStore.commit(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0100 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0100 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_COMMIT_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_COMMIT_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.Commit() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.Commit() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_COMMIT_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0200');
+ try {
+ await kvStore.commit('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0200 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0200 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_COMMIT_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_COMMIT_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.Commit() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.Commit() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_COMMIT_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0300');
+ try {
+ await kvStore.commit(2.000, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0300 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_COMMIT_0300 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_COMMIT_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.Rollback() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.Rollback() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0100');
+ try {
+ await kvStore.rollback(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0100 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0100 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.Rollback() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.Rollback() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0200');
+ try {
+ await kvStore.rollback('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0200 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0200 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.Rollback() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.Rollback() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0300');
+ try {
+ await kvStore.rollback(2.000, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0300 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0300 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ROLLBACK_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.EnableSync() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.EnableSync() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0100');
+ try {
+ await kvStore.enableSync(true, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0100 enableSync success');
+ expect(err == undefined).assertTrue();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0100 enableSync fail');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.EnableSync() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.EnableSync() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0200');
+ try {
+ await kvStore.enableSync(false, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0200 enableSync success');
+ expect(err == undefined).assertTrue();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0200 enableSync fail');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.EnableSync() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.EnableSync() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0300');
+ try {
+ await kvStore.enableSync(function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0300 enableSync success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0300 enableSync fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0400
+ * @tc.desc Test Js Api DeviceKvStore.9.EnableSync() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.EnableSync() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0400');
+ try {
+ await kvStore.enableSync(null, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0400 enableSync success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0400 enableSync fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_ENABLESYNC_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100 put success');
+ expect(err == undefined).assertTrue();
+ var deviceid = 'no_exist_device_id';
+ await kvStore.removeDeviceData(deviceid, async function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100 removeDeviceData success');
+ expect(null).assertFail();
+ done();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100 removeDeviceData fail');
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100 get success');
+ expect(data == VALUE_TEST_STRING_ELEMENT).assertTrue();
+ done();
+ });
+ }
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0200');
+ try {
+ await kvStore.removeDeviceData(function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0200 removeDeviceData success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0200 removeDeviceData fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0300');
+ try {
+ await kvStore.removeDeviceData('', function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0300 removeDeviceData success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0300 removeDeviceData fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0400
+ * @tc.desc Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.RemoveDeviceData() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0400');
+ try {
+ await kvStore.removeDeviceData(null, function (err,data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0400 removeDeviceData success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0400 removeDeviceData fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_REMOVEDEVICEDATA_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getResultSet(localDeviceId, 'batch_test_string_key', async function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0200
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0200');
+ try {
+ let resultSet;
+ await kvStore.getResultSet(localDeviceId, 'batch_test_string_key', async function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0200 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 0).assertTrue();
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0200 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0300
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0300');
+ try {
+ let resultSet;
+ await kvStore.getResultSet(function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0300 getResultSet success');
+ expect(err != undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0400
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0400');
+ try {
+ let resultSet;
+ await kvStore.getResultSet('test_key_string', 123, function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0400 getResultSet success');
+ expect(err != undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 005
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSet(localDeviceId, query, async function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 006
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ query.deviceId(localDeviceId);
+ await kvStore.getResultSet(query, async function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0600 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 007
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetResultSet() testcase 007
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 putBatch success');
+ expect(err == undefined).assertTrue();
+ let predicates = new dataSharePredicates.DataSharePredicates();
+ predicates.inKeys("batch_test");
+ await kvStore.getResultSet(localDeviceId, predicates, async function (err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100
+ * @tc.desc Test Js Api DeviceKvStore.9.CloseResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.CloseResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100');
+ try {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100 success');
+ let resultSet = null;
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100 closeResultSet success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100 closeResultSet fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200
+ * @tc.desc Test Js Api DeviceKvStore.9.CloseResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.CloseResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200');
+ try {
+ let resultSet = null;
+ await kvStore.getResultSet(localDeviceId, 'batch_test_string_key', async function(err, result) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200 getResultSet success');
+ resultSet = result;
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200 closeResultSet fail');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300
+ * @tc.desc Test Js Api DeviceKvStore.9.CloseResultSet() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.CloseResultSet() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300');
+ try {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300 success');
+ await kvStore.closeResultSet(function (err, data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300 closeResultSet success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300 closeResultSet fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400
+ * @tc.desc Test Js Api DeviceKvStore.9.CloseResultSet() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.9.CloseResultSet() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400');
+ try {
+ console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(ResultSize) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(ResultSize) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0100');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ query.deviceId(localDeviceId);
+ await kvStore.getResultSize(query, async function (err, resultSize) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0100 getResultSet success');
+ expect(resultSize == 10).assertTrue();
+ done();
+ });
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(ResultSize) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(ResultSize) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0200');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSize(localDeviceId, query, async function (err, resultSize) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0200 getResultSet success');
+ expect(resultSize == 10).assertTrue();
+ done();
+ });
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETRESULTSIZE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100
+ * @tc.desc Test Js Api DeviceKvStore.GetEntries() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetEntries() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.deviceId(localDeviceId);
+ query.prefixKey("batch_test");
+ await kvStore.getEntries(localDeviceId, query, function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ done();
+ });
+ });
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200
+ * @tc.desc Test Js Api DeviceKvStore.GetEntries() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetEntries() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ query.deviceId(localDeviceId);
+ await kvStore.getEntries(query, function (err,entrys) {
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ done();
+ });
+ });
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 success');
+ console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/DeviceKvStoreKVPromiseJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/DeviceKvStoreKVPromiseJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..0e893bd2bfb2a8ebfb84bad417ac60030b956a18
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/DeviceKvStoreKVPromiseJsTest.js
@@ -0,0 +1,2663 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+import abilityFeatureAbility from '@ohos.ability.featureAbility'
+
+var context = abilityFeatureAbility.getContext();
+const KEY_TEST_INT_ELEMENT = 'key_test_int';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string';
+const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
+
+const VALUE_TEST_INT_ELEMENT = 123;
+const VALUE_TEST_FLOAT_ELEMENT = 321.12;
+const VALUE_TEST_BOOLEAN_ELEMENT = true;
+const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
+const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
+
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'dstoreId';
+var kvManager = null;
+var kvStore = null;
+var localDeviceId = null;
+const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
+const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
+var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
+
+function sleep(ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+}
+
+function putBatchString(len, prefix) {
+ let entries = [];
+ for (var i = 0; i < len; i++) {
+ var entry = {
+ key : prefix + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ return entries;
+}
+export default function deviceKvStorePromiseTest(){
+describe('deviceKvStorePromiseTest', function () {
+ const config = {
+ bundleName : TEST_BUNDLE_NAME,
+ context: context
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll config:'+ JSON.stringify(config));
+ await factory.createKVManager(config).then((manager) => {
+ kvManager = manager;
+ console.info('beforeAll createKVManager success');
+ }).catch((err) => {
+ console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
+ kvStore = store;
+ console.info('beforeAll getKVStore for getDeviceId success');
+ }).catch((err) => {
+ console.error('beforeAll getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ var getDeviceId = new Promise((resolve, reject) => {
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('beforeAll on data change: ' + JSON.stringify(data));
+ resolve(data.deviceId);
+ });
+ kvStore.put("getDeviceId", "byPut").then((data) => {
+ console.info('beforeAll put success');
+ expect(data == undefined).assertTrue();
+ });
+ setTimeout(() => {
+ reject(new Error('not resolved in 2 second, reject it.'))
+ }, 2000);
+ });
+ await getDeviceId.then(function(deviceId) {
+ console.info('beforeAll getDeviceId ' + JSON.stringify(deviceId));
+ localDeviceId = deviceId;
+ }).catch((error) => {
+ console.error('beforeAll can NOT getDeviceId, fail: ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID);
+ kvStore = null;
+ console.info('beforeAll end');
+ done();
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ kvManager = null;
+ kvStore = null;
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach' + JSON.stringify(options));
+ await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
+ kvStore = store;
+ console.info('beforeEach getKVStore success');
+ }).catch((err) => {
+ console.error('beforeEach getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ console.info('beforeEach end');
+ done();
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => {
+ console.info('afterEach closeKVStore success');
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
+ console.info('afterEach deleteKVStore success');
+ }).catch((err) => {
+ console.error('afterEach deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('afterEach closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ kvStore = null;
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(String) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(String) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, null).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0100 put success');
+ expect(null).assertFail();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0100 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(String) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(String) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0200');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, '').then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0200 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.Put(String) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(String) testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0300');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0300 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.Put(String) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(String) testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400');
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4095; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, str).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400 get success data ' + data);
+ expect(str == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTSTRING_PROMISE_0400 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DEVICEKVSTORE_PUTSTRING_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(String) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(String) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100 get success');
+ expect(VALUE_TEST_STRING_ELEMENT == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DEVICEKVSTORE_GETSTRING_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(String) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(String) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0200');
+ try {
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0200 get success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0200 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETSTRING_PROMISE_0200 get e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200');
+ try {
+ var intValue = 987654321;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200 get success');
+ expect(intValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300');
+ try {
+ var intValue = Number.MAX_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300 get success');
+ expect(intValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.Put(Int) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Int) testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400');
+ try {
+ var intValue = Number.MIN_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400 get success');
+ expect(intValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTINT_PROMISE_0400 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(Int) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Int) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100 get success');
+ expect(VALUE_TEST_INT_ELEMENT == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETINT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBOOLEAN_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Bool) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Bool) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBOOLEAN_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBOOLEAN_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBOOLEAN_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBOOLEAN_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBOOLEAN_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(Bool) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Bool) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100');
+ try {
+ var boolValue = false;
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, boolValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_BOOLEAN_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100 get success');
+ expect(boolValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETBOOLEAN_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTFLOAT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Float) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Float) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTFLOAT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTFLOAT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTFLOAT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTFLOAT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTFLOAT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(Float) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Float) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100');
+ try {
+ var floatValue = 123456.654321;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100 get success');
+ expect(floatValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(Float) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Float) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200');
+ try {
+ var floatValue = 123456.0;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200 get success');
+ expect(floatValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.Get(Float) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(Float) testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300');
+ try {
+ var floatValue = 123456.00;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(localDeviceId, KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300 get success');
+ expect(floatValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETFLOAT_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.DeleteString() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteString() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100');
+ try {
+ var str = 'this is a test string';
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, str).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.DeleteString() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteString() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200');
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4096; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, str).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.DeleteString() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteString() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0300');
+ try {
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0300 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETESTRING_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.DeleteInt() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteInt() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEINT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.DeleteFloat() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteFloat() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEFLOAT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.DeleteBool() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteBool() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBOOLEAN_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.OnChange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OnChange() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0100', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0100 0' + JSON.stringify(data))
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0100 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.OnChange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OnChange() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0200', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 1, function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0200 0' + JSON.stringify(data))
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0200 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.OnChange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OnChange() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0300', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 2, function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0300 0' + JSON.stringify(data))
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0300 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONCHANGE_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.OnSyncComplete() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OnSyncComplete() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 0' + data)
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 put failed:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PULL_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode);
+ } catch (e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.OnSyncComplete() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OnSyncComplete() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 0' + data)
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 put failed:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode);
+ } catch(error) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 no peer device :e:' + `, error code is ${error.code}, message is ${error.message}`);
+ }
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.OnSyncComplete() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OnSyncComplete() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 0' + data)
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 put failed:' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_PULL;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode);
+ } catch(error) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 no peer device :e:' + `, error code is ${error.code}, message is ${error.message}`);
+ }
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.OffChange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffChange() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0100');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0100 0' + data)
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.off('dataChange', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.OffChange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffChange() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0200');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0200 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0200 0' + data)
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.on('dataChange', 0, func1);
+ kvStore.off('dataChange', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.OffChange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffChange() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0300');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0300 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0300 0' + data)
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.on('dataChange', 0, func1);
+ kvStore.off('dataChange', func);
+ kvStore.off('dataChange', func1);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.OffChange() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffChange() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0400');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0400 0' + data)
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.off('dataChange');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFCHANGE_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.OffSyncComplete() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffSyncComplete() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.off('syncComplete', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.OffSyncComplete() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffSyncComplete() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.on('syncComplete', func1);
+ kvStore.off('syncComplete', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.OffSyncComplete() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffSyncComplete() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.on('syncComplete', func1);
+ kvStore.off('syncComplete', func);
+ kvStore.off('syncComplete', func1);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.OffSyncComplete() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.OffSyncComplete() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.off('syncComplete');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.SetSyncRange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.SetSyncRange() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0100');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['C', 'D'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0100 setSyncRange success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.SetSyncRange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.SetSyncRange() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0200');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['B', 'C'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0200 setSyncRange success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0200 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.SetSyncRange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.SetSyncRange() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0300');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['A', 'B'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0300 setSyncRange success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_SETSYNCRANGE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100');
+ try {
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_string_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 getEntries success');
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 entrys.length: ' + entrys.length);
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 entrys[0]: ' + JSON.stringify(entrys[0]));
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 entrys[0].value: ' + JSON.stringify(entrys[0].value));
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 entrys[0].value.value: ' + entrys[0].value.value);
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 'batch_test_string_value').assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.INTEGER,
+ value : 222
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_number_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 222).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.FLOAT,
+ value : 2.0
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_number_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.0).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.DOUBLE,
+ value : 2.00
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_number_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.00).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 005
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500');
+ try {
+ var bo = false;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BOOLEAN,
+ value : bo
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_bool_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == bo).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600
+ * @tc.desc Test Js Api DeviceKvStore.Put(Batch) testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Put(Batch) testcase 006
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries(localDeviceId, 'batch_test_bool_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0600 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.DeleteBatch() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteBatch() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100');
+ try {
+ let entries = [];
+ let keys = [];
+ for (var i = 0; i < 5; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ keys.push(key + i);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.DeleteBatch() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteBatch() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0200');
+ try {
+ let keys = ['batch_test_string_key1', 'batch_test_string_key2'];
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0200 deleteBatch success');
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0200 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.DeleteBatch() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.DeleteBatch() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = ['batch_test_string_key1', 'batch_test_string_keya'];
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300 deleteBatch success');
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_DELETEBATCH_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.startTransaction() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.startTransaction() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100' + JSON.stringify(data))
+ count++;
+ });
+ await kvStore.startTransaction().then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 startTransaction success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.commit().then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 commit success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await sleep(2000);
+ expect(count == 1).assertTrue();
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.startTransaction() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.startTransaction() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200' + JSON.stringify(data))
+ count++;
+ });
+ await kvStore.startTransaction().then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 startTransaction success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.rollback().then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 rollback success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await sleep(2000);
+ expect(count == 0).assertTrue();
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.startTransaction() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.startTransaction() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0200');
+ try {
+ await kvStore.startTransaction(1).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0300 startTransaction success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0300 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.startTransaction() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.startTransaction() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0400');
+ try {
+ await kvStore.startTransaction('test_string').then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0400 startTransaction success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0400 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0500
+ * @tc.desc Test Js Api DeviceKvStore.startTransaction() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.startTransaction() testcase 005
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0500');
+ try {
+ await kvStore.startTransaction(2.000).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0500 startTransaction success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0500 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_STARTTRANSACTION_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Commit() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Commit() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0100');
+ try {
+ await kvStore.commit(1).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0100 commit success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0100 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Commit() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Commit() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0200');
+ try {
+ await kvStore.commit('test_string').then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0200 commit success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0200 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.Commit() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Commit() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0300');
+ try {
+ await kvStore.commit(2.000).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0300 commit success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0300 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_COMMIT_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Rollback() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Rollback() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0100');
+ try {
+ await kvStore.rollback(1).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0100 rollback success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0100 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Rollback() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Rollback() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0200');
+ try {
+ await kvStore.rollback('test_string').then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0200 rollback success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0200 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.Rollback() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Rollback() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0300');
+ try {
+ await kvStore.rollback(2.000).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0300 rollback success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0300 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ROOLBACK_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.EnableSync() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.EnableSync() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0100');
+ try {
+ await kvStore.enableSync(true).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0100 enableSync success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0100 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.EnableSync() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.EnableSync() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0200');
+ try {
+ await kvStore.enableSync(false).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0200 enableSync success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0200 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.EnableSync() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.EnableSync() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0300');
+ try {
+ await kvStore.enableSync().then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0300 enableSync success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0300 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.EnableSync() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.EnableSync() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0400');
+ try {
+ await kvStore.enableSync(null).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0400 enableSync success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0400 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_ENABLESYNC_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.RemoveDeviceData() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.RemoveDeviceData() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 put success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var deviceid = 'no_exist_device_id';
+ await kvStore.removeDeviceData(deviceid).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvStore.get(localDeviceId, KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 get success data:' + data);
+ expect(data == VALUE_TEST_STRING_ELEMENT).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.RemoveDeviceData() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.RemoveDeviceData() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200');
+ try {
+ await kvStore.removeDeviceData().then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.RemoveDeviceData() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.RemoveDeviceData() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300');
+ try {
+ await kvStore.removeDeviceData('').then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.RemoveDeviceData() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.RemoveDeviceData() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400');
+ try {
+ await kvStore.removeDeviceData(null).then((data) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.getResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.getResultSet(localDeviceId, 'batch_test_string_key').then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.getResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200');
+ try {
+ let resultSet;
+ await kvStore.getResultSet(localDeviceId, 'batch_test_string_key').then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 0).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.getResultSet() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0300');
+ try {
+ let resultSet;
+ await kvStore.getResultSet().then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0300 getResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0300 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.getResultSet() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0400');
+ try {
+ let resultSet;
+ await kvStore.getResultSet('test_key_string', 123).then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0400 getResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0400 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500
+ * @tc.desc Test Js Api DeviceKvStore.getResultSet() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 005
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSet(localDeviceId, query).then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ query.deviceId(localDeviceId);
+ console.info("testDeviceKvStoreGetResultSet005 " + query.getSqlLike());
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600
+ * @tc.desc Test Js Api DeviceKvStore.getResultSet() testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 006
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.deviceId(localDeviceId);
+ query.prefixKey("batch_test");
+ console.info("testDeviceKvStoreGetResultSet006 " + query.getSqlLike());
+ await kvStore.getResultSet(query).then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0600 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700
+ * @tc.desc Test Js Api DeviceKvStore.GetResultSet() testcase 007
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.getResultSet() testcase 007
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then( async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch success');
+ expect(err == undefined).assertTrue();
+ let predicates = new dataSharePredicates.DataSharePredicates();
+ predicates.inKeys("batch_test");
+ await kvStore.getResultSet(localDeviceId, predicates).then( async (result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ await kvStore.closeResultSet(resultSet).then(err => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.CloseResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.CloseResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100');
+ try {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100 success');
+ let resultSet = null;
+ await kvStore.closeResultSet(resultSet).then(() => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100 closeResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.CloseResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.CloseResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200');
+ try {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200 success');
+ let resultSet = null;
+ await kvStore.getResultSet(localDeviceId, 'batch_test_string_key').then((result) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200 getResultSet success');
+ resultSet = result;
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300
+ * @tc.desc Test Js Api DeviceKvStore.CloseResultSet() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.CloseResultSet() testcase 003
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300');
+ try {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300 success');
+ let resultSet = null;
+ await kvStore.closeResultSet().then(() => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300 closeResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400
+ * @tc.desc Test Js Api DeviceKvStore.CloseResultSet() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.CloseResultSet() testcase 004
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400');
+ try {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.Get(ResultSize) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(ResultSize) testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_PUTBATCH_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ query.deviceId(localDeviceId);
+ await kvStore.getResultSize(query).then((resultSize) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100 getResultSet success');
+ expect(resultSize == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.Get(ResultSize) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.Get(ResultSize) testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSize(localDeviceId, query).then((resultSize) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200 getResultSet success');
+ expect(resultSize == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSIZE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100
+ * @tc.desc Test Js Api DeviceKvStore.GetEntries() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetEntries() testcase 001
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.deviceId(localDeviceId);
+ query.prefixKey("batch_test");
+ await kvStore.getEntries(localDeviceId, query).then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 getEntries success');
+ console.info(entrys.length);
+ console.info(entrys[0].value.value.toString());
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200
+ * @tc.desc Test Js Api DeviceKvStore.GetEntries() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api DeviceKvStore.GetEntries() testcase 002
+ */
+ it('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ query.deviceId(localDeviceId);
+ await kvStore.getEntries(query).then((entrys) => {
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_DEVICEKVSTORE_GETENTRIES_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvManagerKVCallbackJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvManagerKVCallbackJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..e86aefe067ad0205d771d8cb809a1821fe708081
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvManagerKVCallbackJsTest.js
@@ -0,0 +1,502 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import abilityFeatureAbility from '@ohos.ability.featureAbility'
+
+var context = abilityFeatureAbility.getContext();
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'storeId';
+const STORE_KEY = 'key_test_string';
+const STORE_VALUE = 'value-test-string';
+var kvManager = null;
+var kvStore = null;
+export default function kvManagerCallbackTest(){
+describe('kvManagerCallbackTest', function () {
+ const config = {
+ bundleName : TEST_BUNDLE_NAME,
+ context: context
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.SINGLE_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll');
+ await factory.createKVManager(config, function (err, manager) {
+ kvManager = manager;
+ done();
+ });
+ console.info('beforeAll end');
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach');
+ done();
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, async function () {
+ console.info('afterEach closeKVStore success');
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function () {
+ console.info('afterEach deleteKVStore success');
+ done();
+ });
+ });
+ kvStore = null;
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 00
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100 getKVStore success');
+ kvStore = store;
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200');
+ try {
+ await kvManager.getKVStore(options, function (err, store) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore fail');
+ }
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0300
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 003
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0300');
+ const optionsInfo = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.SINGLE_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0300 getKVStore success');
+ expect((err == undefined) && (store != null)).assertTrue();
+ kvStore = store;
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0300 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 004
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400');
+ const optionsInfo = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.MULTI_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S1,
+ }
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400 getKVStore success');
+ expect(true).assertTrue();
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 005
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500');
+ const optionsInfo = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.MULTI_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500 getKVStore success');
+ expect(true).assertTrue();
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 006
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600');
+ const optionsInfo = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.MULTI_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S3,
+ }
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600 getKVStore success');
+ expect(true).assertTrue();
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0700
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 007
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 007
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0700', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0700');
+ const optionsInfo = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.MULTI_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S4,
+ }
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0700 getKVStore success');
+ expect(true).assertTrue();
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100
+ * @tc.desc Test Js Api KVManager.CloseKVStore() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.CloseKVStore() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 getKVStore success');
+ kvStore = store;
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, function (err, data) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 closeKVStore success');
+ expect((err == undefined) && (data == undefined)).assertTrue();
+ done();
+ });
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200
+ * @tc.desc Test Js Api KVManager.CloseKVStore() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.CloseKVStore() testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 getKVStore success');
+ kvStore = store;
+ try {
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, function (err, data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore fail');
+ }
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ });
+ } catch (ee) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 getKVStore ee ' + `, error code is ${ee.code}, message is ${ee.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300
+ * @tc.desc Test Js Api KVManager.CloseKVStore() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.CloseKVStore() testcase 003
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, async function (err) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 getKVStore success');
+ try {
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore success');
+ expect(true).assertTrue();
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore fail');
+ }
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ });
+ } catch (ee) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 getKVStore ee ' + `, error code is ${ee.code}, message is ${ee.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400
+ * @tc.desc Test Js Api KVManager.CloseKVStore() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.CloseKVStore() testcase 004
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 getKVStore success');
+ kvStore = store;
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
+ });
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore redo.');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, function (err, data) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore twice ' + `, error code is ${err.code}, message is ${err.message}`);
+ if (err == undefined) {
+ expect(null).assertFail();
+ }
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore twice e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100
+ * @tc.desc Test Js Api KVManager.DeleteKVStore() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.DeleteKVStore() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 getKVStore success');
+ kvStore = store;
+ try {
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, function (err, data) {
+ if (err == undefined) {
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore fail');
+ }
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ });
+ } catch (ee) {
+ console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 getKVStore ee ' + `, error code is ${ee.code}, message is ${ee.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200
+ * @tc.desc Test Js Api KVManager.DeleteKVStore() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.DeleteKVStore() testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200');
+ try {
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err, data) {
+ if (err == undefined){
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 deleteKVStore success');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 deleteKVStore fail');
+ }
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100
+ * @tc.desc Test Js Api KVManager.GetAllKVStoreId() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetAllKVStoreId() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100');
+ try {
+ await kvManager.getAllKVStoreId(TEST_BUNDLE_NAME, function (err, data) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 getAllKVStoreId success');
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 size = ' + data.length);
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 err is: ' + err);
+ expect(0).assertEqual(data.length);
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_PUT_0100
+ * @tc.desc Test Js Api KVStore.Put() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVStore.Put() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_PUT_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 getKVStore success');
+ kvStore = store;
+ await kvStore.put(STORE_KEY, STORE_VALUE, function (err, data) {
+ if (err != undefined){
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 put callback fail');
+ expect(null).assertFail();
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 put callback success');
+ expect(true).assertTrue();
+ }
+ done();
+ });
+ });
+
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_PUT_0100 callback e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvManagerKVPromiseJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvManagerKVPromiseJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..c7b019ee3db8c2b87cf081a5df1beef4122a9f0f
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvManagerKVPromiseJsTest.js
@@ -0,0 +1,473 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import abilityFeatureAbility from '@ohos.ability.featureAbility';
+
+var context = abilityFeatureAbility.getContext();
+var contextApplication = context.getApplicationContext()
+
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'storeId';
+var kvManager = null;
+var kvStore = null;
+const STORE_KEY = 'key_test_string';
+const STORE_VALUE = 'value-test-string';
+var kvStoreNew = null;
+export default function KVManagerPromiseTest(){
+describe('KVManagerPromiseTest', function () {
+ const config = {
+ bundleName: TEST_BUNDLE_NAME,
+ context:context
+ }
+
+ const options = {
+ createIfMissing: true,
+ encrypt: false,
+ backup: false,
+ autoSync: true,
+ kvStoreType: factory.KVStoreType.SINGLE_VERSION,
+ schema: '',
+ securityLevel: factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll');
+ await factory.createKVManager(config).then((manager) => {
+ kvManager = manager;
+ console.info('beforeAll createKVManager success');
+ kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
+ console.info("beforeAll getKVStore success");
+ kvStoreNew = store;
+ }).catch((err) => {
+ console.info("beforeAll getKVStore err: " + JSON.stringify(err));
+ });
+ }).catch((err) => {
+ console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ console.info('beforeAll end');
+ done();
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach');
+ done();
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(async () => {
+ console.info('afterEach closeKVStore success');
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
+ console.info('afterEach deleteKVStore success');
+ }).catch((err) => {
+ console.error('afterEach deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('afterEach closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ kvStore = null;
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0100
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0100');
+ try {
+ await kvManager.getKVStore(TEST_STORE_ID).then((store) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0100 getKVStore success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0100 getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0100 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0200
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0200');
+ try {
+ await kvManager.getKVStore(options).then((store) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0200 getKVStore success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0200 getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0200 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0300
+ * @tc.desc Test Js Api KVManager.GetKVStore() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetKVStore() testcase 03
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0300');
+ const optionsInfo = {
+ createIfMissing: false,
+ encrypt: false,
+ backup: false,
+ autoSync: true,
+ kvStoreType: factory.KVStoreType.SINGLE_VERSION,
+ schema: '',
+ securityLevel: factory.SecurityLevel.S1,
+ }
+ await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0300 getKVStore success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_PROMISE_0300 getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_PROMISE_0100
+ * @tc.desc Test Js Api KVManager.CloseKVStore() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.CloseKVStore() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_PROMISE_0100', 0, async function (done) {
+ console.info('KVManagerCloseKVStorePromiseTest004');
+ await kvManager.getKVStore(TEST_STORE_ID, options).then( async () => {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_PROMISE_0100 getKVStore success');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
+ console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_PROMISE_0100 closeKVStore success');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_PROMISE_0100 closeKVStore twice err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_GETALLKVSTORE_PROMISE_0100
+ * @tc.desc Test Js Api KVManager.GetAllKVStoreId() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.GetAllKVStoreId() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_GETALLKVSTORE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTORE_PROMISE_0100');
+ await kvManager.getAllKVStoreId(TEST_BUNDLE_NAME).then((data) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTORE_PROMISE_0100 getAllKVStoreId success');
+ console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTORE_PROMISE_0100 size = ' + data.length);
+ expect(0).assertEqual(data.length);
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_GETALLKVSTORE_PROMISE_0100 getAllKVStoreId err ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ done();
+ })
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0100
+ * @tc.desc Test Js Api KVManager.On() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.On() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0100', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0100');
+ var deathCallback = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback);
+ kvManager.off('distributedDataServiceDie', deathCallback);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0200
+ * @tc.desc Test Js Api KVManager.On() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.On() testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0200', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0200');
+ var deathCallback1 = function () {
+ console.info('death callback call');
+ }
+ var deathCallback2 = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback1);
+ kvManager.on('distributedDataServiceDie', deathCallback2);
+ kvManager.off('distributedDataServiceDie', deathCallback1);
+ kvManager.off('distributedDataServiceDie', deathCallback2);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0300
+ * @tc.desc Test Js Api KVManager.On() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.On() testcase 003
+ */
+ it('SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0300', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_ON_PROMISE_0300');
+ var deathCallback = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback);
+ kvManager.on('distributedDataServiceDie', deathCallback);
+ kvManager.off('distributedDataServiceDie', deathCallback);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0100
+ * @tc.desc Test Js Api KVManager.Off() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.Off() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0100', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0100');
+ var deathCallback = function () {
+ console.info('death callback call');
+ }
+ kvManager.off('distributedDataServiceDie', deathCallback);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0200
+ * @tc.desc Test Js Api KVManager.Off() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.Off() testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0200', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0200');
+ var deathCallback = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback);
+ kvManager.off('distributedDataServiceDie', deathCallback);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0300
+ * @tc.desc Test Js Api KVManager.Off() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.Off() testcase 003
+ */
+ it('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0300', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0300');
+ var deathCallback1 = function () {
+ console.info('death callback call');
+ }
+ var deathCallback2 = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback1);
+ kvManager.on('distributedDataServiceDie', deathCallback2);
+ kvManager.off('distributedDataServiceDie', deathCallback1);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0400
+ * @tc.desc Test Js Api KVManager.Off() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.Off() testcase 004
+ */
+ it('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0400', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0400');
+ var deathCallback = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback);
+ kvManager.off('distributedDataServiceDie', deathCallback);
+ kvManager.off('distributedDataServiceDie', deathCallback);
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0500
+ * @tc.desc Test Js Api KVManager.Off() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.Off() testcase 005
+ */
+ it('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0500', 0, function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_OFF_PROMISE_0100');
+ var deathCallback = function () {
+ console.info('death callback call');
+ }
+ kvManager.on('distributedDataServiceDie', deathCallback);
+ kvManager.off('distributedDataServiceDie');
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVMANAGER_PUT_PROMISE_0100
+ * @tc.desc Test Js Api KVStore.Put() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVStore.Put() testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_PUT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_PROMISE_0100');
+ try {
+ await kvStoreNew.put(TEST_BUNDLE_NAME, TEST_STORE_ID).then((data) => {
+ if (err != undefined){
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_PROMISE_0100 put promise fail');
+ } else {
+ console.info('SUB_DDM_DKV_KVMANAGER_PUT_PROMISE_0100 put promise success');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_PUT_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100
+ * @tc.desc: Test Js Api KVManager.Delete testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KVManager.Delete testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100');
+ try {
+ kvStoreNew.put(STORE_KEY, STORE_VALUE).then((data) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100 getKVStore success');
+ kvStoreNew.delete(STORE_KEY).then((data) => {
+ console.info("testKVStoreDelete001 promise delete success");
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_DELETE_PROMISE_0100 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100
+ * @tc.desc: Test Js Api createKVManager testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api createKVManager testcase 001
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100');
+ const config = {
+ bundleName: TEST_BUNDLE_NAME,
+ context:context
+ }
+ try {
+ await factory.createKVManager(config).then(async (manager) => {
+ kvManager = manager;
+ expect(manager !=null).assertTrue();
+ console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 createKVManager success');
+ await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
+ console.info("testcreateKVManager001 getKVStore success");
+ await store.put(STORE_KEY, STORE_VALUE).then(async (data) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 put data success');
+ await store.get(STORE_KEY).then((data) => {
+ console.info("testcreateKVManager001 get data success");
+ expect(data).assertEqual(STORE_VALUE);
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 get data err' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 put data err' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.info("testcreateKVManager001 getKVStore err: " + JSON.stringify(err));
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail()
+ });
+ }catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200
+ * @tc.desc: Test Js Api createKVManager testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api createKVManager testcase 002
+ */
+ it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200');
+ const config = {
+ bundleName: TEST_BUNDLE_NAME,
+ context:contextApplication
+ }
+ try {
+ await factory.createKVManager(config).then(async (manager) => {
+ kvManager = manager;
+ console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 createKVManager success');
+ await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
+ console.info("testcreateKVManager002 getKVStore success");
+ await store.put(STORE_KEY, STORE_VALUE).then(async (data) => {
+ console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 put data success');
+ await store.get(STORE_KEY).then((data) => {
+ console.info("testcreateKVManager002 get data success");
+ expect(data).assertEqual(STORE_VALUE);
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 get data err' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 put data err' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.info("testcreateKVManager002 getKVStore err: " + JSON.stringify(err));
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail()
+ });
+ }catch (e) {
+ console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreResultSetKVJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreResultSetKVJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..20186700ba1580c580b55e60fbc7ba9a42810740
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreResultSetKVJsTest.js
@@ -0,0 +1,1107 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import abilityFeatureAbility from '@ohos.ability.featureAbility';
+
+var context = abilityFeatureAbility.getContext();
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'storeId';
+var kvManager = null;
+var kvStore = null;
+var resultSet = null;
+export default function KvStoreResultSetTest(){
+ describe('KvStoreResultSetTest', function() {
+ const config = {
+ bundleName : TEST_BUNDLE_NAME,
+ context: context
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.SINGLE_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll');
+ console.info('beforeAll config:' + JSON.stringify(config));
+ await factory.createKVManager(config).then((manager) => {
+ kvManager = manager;
+ console.info('beforeAll createKVManager success');
+ }).catch((err) => {
+ console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvManager.getAllKVStoreId(TEST_BUNDLE_NAME).then(async (data) => {
+ console.info('beforeAll getAllKVStoreId size = ' + data.length);
+ for (var i = 0; i < data.length; i++) {
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, data[i]).then(() => {
+ console.info('beforeAll deleteKVStore success ' + data[i]);
+ }).catch((err) => {
+ console.info('beforeAll deleteKVStore store: ' + data[i]);
+ console.error('beforeAll deleteKVStore error ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }
+ }).catch((err) => {
+ console.error('beforeAll getAllKVStoreId err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+
+ console.info('beforeAll end');
+ done();
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ kvManager = null;
+ kvStore = null;
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach');
+ await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
+ kvStore = store;
+ console.info('beforeEach getKVStore success');
+ }).catch((err) => {
+ console.error('beforeEach getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('beforeEach putBatch success');
+ }).catch((err) => {
+ console.error('beforeEach putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvStore.getResultSet('batch_test_string_key').then((result) => {
+ console.info('beforeEach getResultSet success');
+ resultSet = result;
+ }).catch((err) => {
+ console.error('beforeEach getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ console.info('beforeEach end');
+ done();
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('afterEach closeResultSet success');
+ }).catch((err) => {
+ console.error('afterEach closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(async () => {
+ console.info('afterEach closeKVStore success');
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
+ console.info('afterEach deleteKVStore success');
+ }).catch((err) => {
+ console.error('afterEach deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('afterEach closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ kvStore = null;
+ resultSet = null;
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0100
+ * @tc.desc Test Js Api KvStoreResultSet.GetCount() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetCount() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0100', 0, async function(done) {
+ try {
+ var count = resultSet.getCount();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0100 getCount " + count);
+ expect(count == 10).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200
+ * @tc.desc Test Js Api KvStoreResultSet.GetCount() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetCount() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200', 0, async function(done) {
+ try {
+ var rs;
+ await kvStore.getResultSet('test').then((result) => {
+ console.info('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200 getResultSet success');
+ rs = result;
+ expect(rs.getCount() == 0).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(rs).then((err) => {
+ console.info('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200 closeResultSet success');
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0300
+ * @tc.desc Test Js Api KvStoreResultSet.GetCount() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetCount() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0300', 0, async function(done) {
+ try {
+ var count = resultSet.getCount(123);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0300 getCount " + count);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0400
+ * @tc.desc Test Js Api KvStoreResultSet.GetCount() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetCount() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0400', 0, async function(done) {
+ try {
+ var count = resultSet.getCount(123, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0400 getCount " + count);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETCOUNT_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0100
+ * @tc.desc Test Js Api KvStoreResultSet.GetPosition() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetPosition() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0100', 0, async function(done) {
+ try {
+ var position = resultSet.getPosition();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0100 getPosition " + position);
+ expect(position == -1).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0200
+ * @tc.desc Test Js Api KvStoreResultSet.GetPosition() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetPosition() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0200', 0, async function(done) {
+ try {
+ var position = resultSet.getPosition();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0200 getPosition " + position);
+ expect(position).assertEqual(-1);
+ var flag = resultSet.moveToLast();
+ expect(flag).assertTrue();
+ position = resultSet.getPosition();
+ expect(position).assertEqual(9);
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0300
+ * @tc.desc Test Js Api KvStoreResultSet.GetPosition() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetPosition() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0300', 0, async function(done) {
+ try {
+ var position = resultSet.getPosition(123);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0300 getPosition " + position);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0400
+ * @tc.desc Test Js Api KvStoreResultSet.GetPosition() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetPosition() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0400', 0, async function(done) {
+ try {
+ var position = resultSet.getPosition(123, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0400 getPosition " + position);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETPOSITION_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0100
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToFirst() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToFirst() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0100 moveToFirst " + moved);
+ expect(moved).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0200
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToFirst() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToFirst() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0200 moveToFirst " + moved);
+ expect(moved).assertTrue();
+ var pos = resultSet.getPosition();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0200 getPosition " + pos);
+ expect(pos == 0).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0300
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToFirst() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToFirst() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0300', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToFirst(123);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0300 moveToFirst " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0400
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToFirst() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToFirst() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0400', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToFirst(123, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0400 moveToFirst " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0500
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToFirst() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToFirst() testcase 005
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0500', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0500 moveToFirst " + moved);
+ expect(moved && (resultSet.getPosition() == 9)).assertTrue();
+ moved = resultSet.moveToFirst();
+ expect(moved && (resultSet.getPosition() == 0)).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOFIRST_0500 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0100
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToLast() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToLast() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0100 moveToLast " + moved);
+ expect(moved).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0200
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToLast() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToLast() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0200 moveToLast " + moved);
+ expect(moved && (resultSet.getPosition() == 9)).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0300
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToLast() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToLast() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0300', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToLast(123);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0300 moveToLast " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0400
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToLast() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToLast() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0400', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToLast(123, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0400 moveToLast " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOLAST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0100
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToNext() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToNext() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToNext();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0100 moveToNext " + moved);
+ expect(moved && (resultSet.getPosition() == 0)).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0200
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToNext() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToNext() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToNext();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0200 moveToNext " + moved);
+ expect(moved && (resultSet.getPosition() == 0)).assertTrue();
+ moved = resultSet.moveToNext();
+ expect(moved && (resultSet.getPosition() == 1)).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0300
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToNext() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToNext() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0300', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToNext(123);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0300 moveToNext " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0400
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToNext() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToNext() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0400', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToNext(123, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0400 moveToNext " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETONEXT_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0100
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPrevious() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPrevious() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToPrevious();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0100 moveToPrevious " + moved);
+ expect(!moved).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0200
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPrevious() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPrevious() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToFirst();
+ expect(moved && (resultSet.getPosition() == 0)).assertTrue();
+ moved = resultSet.moveToNext();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0200 moveToNext " + moved);
+ expect(moved && (resultSet.getPosition() == 1)).assertTrue();
+ moved = resultSet.moveToPrevious();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0200 moveToPrevious " + moved);
+ expect(moved && (resultSet.getPosition() == 0)).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0300
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPrevious() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPrevious() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0300', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToPrevious(123);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0300 moveToPrevious " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0400
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPrevious() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPrevious() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0400', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToPrevious(123, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0400 moveToPrevious " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0500
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPrevious() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPrevious() testcase 005
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0500', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToFirst();
+ expect(moved && (resultSet.getPosition() == 0)).assertTrue();
+ moved = resultSet.moveToPrevious();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0500 from 0 to -1 return" + moved);
+ expect(moved == false).assertTrue();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0500 from 0 to " + resultSet.getPosition());
+ expect(-1).assertEqual(resultSet.getPosition());
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVETOPREVIOUS_0500 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0100
+ * @tc.desc Test Js Api KvStoreResultSet.Move() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.Move() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.move();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0100 move " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0200
+ * @tc.desc Test Js Api KvStoreResultSet.Move() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.Move() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0200', 0, async function(done) {
+ try {
+ resultSet.moveToFirst();
+ expect(resultSet.getPosition() == 0).assertTrue();
+ var moved = resultSet.move(3);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0200 move " + moved);
+ expect(moved).assertTrue();
+ expect(3).assertEqual(resultSet.getPosition());
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0300
+ * @tc.desc Test Js Api KvStoreResultSet.Move() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.Move() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0300', 0, async function(done) {
+ try {
+ expect(resultSet.getPosition() == -1).assertTrue();
+ var moved = resultSet.move(3);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0300 move " + moved);
+ expect(moved && (resultSet.getPosition() == 2)).assertTrue();
+ moved = resultSet.move(2);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0300 move " + moved);
+ expect(moved && (resultSet.getPosition() == 4)).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_SETMOVE_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0100
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPosition() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPosition() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToPosition();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0100 moveToPosition " + moved);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0200
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPosition() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPosition() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToPosition(5);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0200 moveToPosition " + moved);
+ expect(moved && (resultSet.getPosition() == 5)).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0300
+ * @tc.desc Test Js Api KvStoreResultSet.MoveToPosition() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.MoveToPosition() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0300', 0, async function(done) {
+ try {
+ var moved = resultSet.move(3);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0300 moveToPosition " + moved);
+ expect(moved && (resultSet.getPosition() == 2)).assertTrue();
+ moved = resultSet.moveToPosition(5);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0300 moveToPosition " + moved);
+ expect(moved && (resultSet.getPosition() == 5)).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_MOVETOPOSITION_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0100
+ * @tc.desc Test Js Api KvStoreResultSet.IsFirst() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsFirst() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0100', 0, async function(done) {
+ try {
+ var flag = resultSet.isFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0100 isFirst " + flag);
+ expect(!flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0200
+ * @tc.desc Test Js Api KvStoreResultSet.IsFirst() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsFirst() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0200', 0, async function(done) {
+ try {
+ var flag = resultSet.isFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0200 isFirst " + flag);
+ expect(!flag).assertTrue();
+ resultSet.move(3);
+ flag = resultSet.isFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0200 isFirst " + flag);
+ expect(!flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0300
+ * @tc.desc Test Js Api KvStoreResultSet.IsFirst() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsFirst() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0300', 0, async function(done) {
+ try {
+ var flag = resultSet.isFirst(1);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0300 isFirst " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0400
+ * @tc.desc Test Js Api KvStoreResultSet.IsFirst() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsFirst() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0400', 0, async function(done) {
+ try {
+ var flag = resultSet.isFirst(1, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0400 isFirst " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0100
+ * @tc.desc Test Js Api KvStoreResultSet.IsLast() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsLast() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0100', 0, async function(done) {
+ try {
+ var flag = resultSet.isLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0100 isLast " + flag);
+ expect(!flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISFIRST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0200
+ * @tc.desc Test Js Api KvStoreResultSet.IsLast() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsLast() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0200', 0, async function(done) {
+ try {
+ resultSet.moveToLast();
+ var flag = resultSet.isLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0200 isLast " + flag);
+ expect(flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0300
+ * @tc.desc Test Js Api KvStoreResultSet.IsLast() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsLast() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0300', 0, async function(done) {
+ try {
+ var flag = resultSet.isLast(1);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0300 isLast " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0400
+ * @tc.desc Test Js Api KvStoreResultSet.IsLast() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsLast() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0400', 0, async function(done) {
+ try {
+ var flag = resultSet.isLast(1, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0400 isLast " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISLAST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0100
+ * @tc.desc Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0100', 0, async function(done) {
+ try {
+ var flag = resultSet.isBeforeFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0100 isBeforeFirst " + flag);
+ expect(flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0200
+ * @tc.desc Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToPrevious();
+ expect(!moved).assertTrue();
+ var flag = resultSet.isBeforeFirst();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0200 isBeforeFirst " + flag);
+ expect(flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0300
+ * @tc.desc Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0300', 0, async function(done) {
+ try {
+ var flag = resultSet.isBeforeFirst(1);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0300 isBeforeFirst " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0400
+ * @tc.desc Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsBeforeFirst() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0400', 0, async function(done) {
+ try {
+ var flag = resultSet.isBeforeFirst(1, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0400 isBeforeFirst " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISBEFOREFIRST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0100
+ * @tc.desc Test Js Api KvStoreResultSet.IsAfterLast() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsAfterLast() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0100', 0, async function(done) {
+ try {
+ var flag = resultSet.isAfterLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0100 isAfterLast " + flag);
+ expect(!flag).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0200
+ * @tc.desc Test Js Api KvStoreResultSet.IsAfterLast() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsAfterLast() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0200 moveToLast moved=" + moved);
+ expect(moved).assertTrue();
+ moved = resultSet.moveToNext();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0200 moveToNext moved=" + moved);
+ expect(moved == false).assertTrue();
+ var flag = resultSet.isAfterLast();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0200 isAfterLast true=" + flag);
+ expect(flag).assertTrue();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0300
+ * @tc.desc Test Js Api KvStoreResultSet.IsAfterLast() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsAfterLast() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0300', 0, async function(done) {
+ try {
+ var flag = resultSet.isAfterLast(1);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0300 isAfterLast " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0400
+ * @tc.desc Test Js Api KvStoreResultSet.IsAfterLast() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.IsAfterLast() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0400', 0, async function(done) {
+ try {
+ var flag = resultSet.isAfterLast(1, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0400 isAfterLast " + flag);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_ISAFTERLAST_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0100
+ * @tc.desc Test Js Api KvStoreResultSet.GetEntry() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetEntry() testcase 001
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0100', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToNext();
+ var entry = resultSet.getEntry();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0100 getEntry " + entry);
+ expect(moved && (entry.key == 'batch_test_string_key0')).assertTrue();
+ expect(moved && (entry.value.value == 'batch_test_string_value')).assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0100 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0200
+ * @tc.desc Test Js Api KvStoreResultSet.GetEntry() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetEntry() testcase 002
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0200', 0, async function(done) {
+ try {
+ var moved = resultSet.moveToNext();
+ var entry = resultSet.getEntry();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0200 getEntry " + entry);
+ expect(entry.key == 'batch_test_string_key0').assertTrue();
+ expect(entry.value.value == 'batch_test_string_value').assertTrue();
+ moved = resultSet.moveToNext();
+ expect(moved).assertTrue();
+ entry = resultSet.getEntry();
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0200 getEntry " + entry);
+ expect(entry.key == 'batch_test_string_key1').assertTrue();
+ expect(entry.value.value == 'batch_test_string_value').assertTrue();
+ } catch (e) {
+ expect(null).assertFail();
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0200 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0300
+ * @tc.desc Test Js Api KvStoreResultSet.GetEntry() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetEntry() testcase 003
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0300', 0, async function(done) {
+ try {
+ var entry = resultSet.getEntry(1);
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0300 getEntry " + entry);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0300 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0400
+ * @tc.desc Test Js Api KvStoreResultSet.GetEntry() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api KvStoreResultSet.GetEntry() testcase 004
+ */
+ it('SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0400', 0, async function(done) {
+ try {
+ var entry = resultSet.getEntry(1, 'test_string');
+ console.info("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0400 getEntry " + entry);
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("SUB_DDM_DKV_KVSTORERESULTSET_GETENTRY_0400 fail " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/List.test.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..95b441d8f07216ca027dbc63fb9c9b68831c8988
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/List.test.js
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import SingleKvStorePromiseTest from './SingleKvStoreKVPromiseJsTest.js'
+import deviceKvStoreCallbackTest from './DeviceKvStoreKVCallbackJsTest.js'
+import deviceKvStorePromiseTest from './DeviceKvStoreKVPromiseJsTest.js'
+import kvManagerCallbackTest from './KvManagerKVCallbackJsTest.js'
+import KVManagerPromiseTest from './KvManagerKVPromiseJsTest.js'
+import KvStoreResultSetTest from './KvStoreResultSetKVJsTest.js'
+import queryTest from './QueryKVJsTest.js'
+import SingleKvStoreCallbackTest from './SingleKvStoreKVCallbackJsTest.js'
+export default function testsuite() {
+ SingleKvStorePromiseTest()
+ deviceKvStoreCallbackTest()
+ deviceKvStorePromiseTest()
+ kvManagerCallbackTest()
+ KVManagerPromiseTest()
+ KvStoreResultSetTest()
+ queryTest()
+ SingleKvStoreCallbackTest()
+}
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/QueryKVJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/QueryKVJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..d2fe2745fdecab9fd637d407fc1cd0cb875757f8
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/QueryKVJsTest.js
@@ -0,0 +1,2170 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import ddm from '@ohos.data.distributedKVStore';
+export default function queryTest(){
+describe('queryTest', function() {
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_RESET_PROMISE_0100
+ * @tc.desc: Test Js Api Query.reset() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.reset() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_RESET_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("test", 3);
+ console.info("query is " + query.getSqlLike());
+ expect(query.getSqlLike() !== "").assertTrue();
+ query.reset();
+ expect("").assertEqual(query.getSqlLike());
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("simply calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_RESET_PROMISE_0200
+ * @tc.desc: Test Js Api Query.reset() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.reset() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_RESET_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("number", 5);
+ query.equalTo("string", 'v');
+ query.equalTo("boolean", false);
+ console.info("query is " + query.getSqlLike());
+ expect(query.getSqlLike() !== "").assertTrue();
+ query.reset();
+ query.reset();
+ query.reset();
+ expect("").assertEqual(query.getSqlLike());
+ console.info("sql after reset: " + query.getSqlLike());
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_RESET_PROMISE_0300
+ * @tc.desc: Test Js Api Query.reset() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.reset() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_RESET_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key", "value");
+ expect(query.getSqlLike() !== "").assertTrue();
+ let sql = query.getSqlLike();
+ query.reset().equalTo("key", "value");
+ console.info("query is " + query.getSqlLike());
+ expect(sql === query.getSqlLike()).assertTrue();
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_RESET_PROMISE_0400
+ * @tc.desc: Test Js Api Query.reset() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.reset() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_RESET_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key", "value");
+ expect(query.getSqlLike() !== "").assertTrue();
+ query.reset(3);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_EQUALTO_PROMISE_0100
+ * @tc.desc: Test Js Api Query.equalTo() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.equalTo() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_EQUALTO_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key1", 5);
+ query.equalTo("key2", 5.0);
+ query.equalTo("key3", false);
+ query.equalTo("key3", "string");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_EQUALTO_PROMISE_0200
+ * @tc.desc: Test Js Api Query.equalTo() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.equalTo() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_EQUALTO_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key1", 1).equalTo("key2", 2).equalTo("key3", 3);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_EQUALTO_PROMISE_0300
+ * @tc.desc: Test Js Api Query.equalTo() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.equalTo() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_EQUALTO_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key2", NaN);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0100
+ * @tc.desc: Test Js Api Query.notEqualTo() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.notEqualTo() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key1", 5);
+ query.notEqualTo("key2", 5.0);
+ query.notEqualTo("key3", false);
+ query.notEqualTo("key4", "string");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0200
+ * @tc.desc: Test Js Api Query.notEqualTo() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.notEqualTo() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 5);
+ query.reset();
+ query.notEqualTo("key0", 5).equalTo("key1", 5).notEqualTo("key2", "str").notEqualTo("key3", false);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0300
+ * @tc.desc: Test Js Api Query.notEqualTo() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.notEqualTo() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key2", NaN);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0400
+ * @tc.desc: Test Js Api Query.notEqualTo() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.notEqualTo() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_NOTEQUALTO_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key1", "value", "too more", 4);
+ console.info("should throw exception on invalid arguments");
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GREATERTHAN_PROMISE_0100
+ * @tc.desc: Test Js Api Query.greaterThan() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.greaterThan() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_GREATERTHAN_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.greaterThan("key1", 5);
+ query.greaterThan("key2", 5.0);
+ query.greaterThan("key3", true);
+ query.greaterThan("key4", "string");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GREATERTHAN_PROMISE_0200
+ * @tc.desc: Test Js Api Query.GreatThan() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.greaterThan() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_GREATERTHAN_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.greaterThan("key", 5);
+ query.reset();
+ query.greaterThan("key0", 5).greaterThan("key1", "v5").greaterThan("key3", false);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GREATERTHAN_PROMISE_0300
+ * @tc.desc: Test Js Api Query.GreatThan() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GreatThan() testcase 00
+ */
+ it('SUB_DDM_DKV_QUERY_GREATERTHAN_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.greaterThan("key2", NaN);
+ console.info("should throw exception on invalid arguments");
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LESSTHAN_PROMISE_0100
+ * @tc.desc: Test Js Api Query.LessThan() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.LessThan() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_LESSTHAN_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.lessThan("key1", 5);
+ query.lessThan("key2", 5.0);
+ query.lessThan("key3", true);
+ query.lessThan("key4", "string");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LESSTHAN_PROMISE_0200
+ * @tc.desc: Test Js Api Query.LessThan() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.LessThan() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_LESSTHAN_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.lessThan("key", 5);
+ query.reset();
+ query.lessThan("key0", 5).lessThan("key1", "v5").lessThan("key3", false);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertTrue();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LESSTHAN_PROMISE_0300
+ * @tc.desc: Test Js Api Query.LessThan() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.LessThan() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_LESSTHAN_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.lessThan("key2", NaN);
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GREATETHANOREQUALTO_PROMISE_0100
+ * @tc.desc: Test Js Api Query.GreaterThanOrEqualTo() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GreaterThanOrEqualTo() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_GREATETHANOREQUALTO_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.greaterThanOrEqualTo("key1", 5);
+ query.greaterThanOrEqualTo("key2", 5.0);
+ query.greaterThanOrEqualTo("key3", true);
+ query.greaterThanOrEqualTo("key4", "string");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GREATETHANOREQUALTO_PROMISE_0200
+ * @tc.desc: Test Js Api Query.GreaterThanOrEqualTo() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GreaterThanOrEqualTo() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_GREATETHANOREQUALTO_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.greaterThanOrEqualTo("key", 5);
+ query.reset();
+ query.greaterThanOrEqualTo("key0", 5)
+ .greaterThanOrEqualTo("key1", "v5")
+ .greaterThanOrEqualTo("key3", false);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GREATETHANOREQUALTO_PROMISE_0300
+ * @tc.desc: Test Js Api Query.GreaterThanOrEqualTo() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GreaterThanOrEqualTo() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_GREATETHANOREQUALTO_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.greaterThanOrEqualTo("key2", NaN);
+ expect(query.getSqlLike() !== "").assertTrue();
+ } catch (e) {
+ console.error(`failed, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LESSTHANOREQUALTO_PROMISE_0100
+ * @tc.desc: Test Js Api Query.LessThanOrEqualTo() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.LessThanOrEqualTo() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_LESSTHANOREQUALTO_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.lessThanOrEqualTo("key1", 5);
+ query.lessThanOrEqualTo("key2", 5.0);
+ query.lessThanOrEqualTo("key3", true);
+ query.lessThanOrEqualTo("key4", "string");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LESSTHANOREQUALTO_PROMISE_0200
+ * @tc.desc: Test Js Api Query.LessThanOrEqualTo() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.LessThanOrEqualTo() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_LESSTHANOREQUALTO_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.lessThanOrEqualTo("key", 5);
+ query.reset();
+ query.lessThanOrEqualTo("key0", 5).lessThanOrEqualTo("key1", "v5").lessThanOrEqualTo("key3", false);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LESSTHANOREQUALTO_PROMISE_0300
+ * @tc.desc: Test Js Api Query.LessThanOrEqualTo() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.LessThanOrEqualTo() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_LESSTHANOREQUALTO_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.lessThanOrEqualTo("key2", NaN);
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNULL_PROMISE_0100
+ * @tc.desc: Test Js Api Query.IsNull() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.IsNull() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_ISNULL_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.isNull("key");
+ query.isNull("key2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNULL_PROMISE_0200
+ * @tc.desc: Test Js Api Query.IsNull() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.IsNull() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_ISNULL_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.isNull("key").notEqualTo("key1", 4).isNull("key2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNULL_PROMISE_0300
+ * @tc.desc: Test Js Api Query.IsNull() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.IsNull() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_ISNULL_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.isNull(0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0100
+ * @tc.desc: Test Js Api Query.InNumber() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InNumber() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ console.info("testInNumber001 start ");
+ var i8 = new Int8Array([-21,31]);
+ query.reset().inNumber("key", i8);
+ console.info("inNumber(Int8Array([-21,31]) => " + query.getSqlLike());
+ var u8 = new Uint8Array([-21,31]);
+ query.reset().inNumber("key", u8);
+ console.info("inNumber(Uint8Array([-21,31]) => " + query.getSqlLike());
+ var c8 = new Uint8ClampedArray([-21,31]);
+ query.reset().inNumber("key", c8);
+ console.info("inNumber(Uint8Array([-21,31]) => " + query.getSqlLike());
+ var i16 = new Int16Array([-21,31]);
+ query.reset().inNumber("key", i16);
+ console.info("inNumber(Int16Array([-21,31]) => " + query.getSqlLike());
+ var u16 = new Uint16Array([-21,31]);
+ query.reset().inNumber("key", u16);
+ console.info("inNumber(Uint16Array([-21,31]) => " + query.getSqlLike());
+ var i32 = new Int32Array([-21, 31]);
+ query.reset().inNumber("key", i32);
+ console.info("inNumber(Int32Array([-21,31]) => " + query.getSqlLike());
+ var u32 = new Uint32Array([-21, 31]);
+ query.reset().inNumber("key", u32);
+ console.info("inNumber(UInt32Array([-21,31]) => " + query.getSqlLike());
+ var f32 = new Float32Array([-21, 31]);
+ query.reset().inNumber("key", f32);
+ console.info("inNumber(Float32Array([-21,31]) => " + query.getSqlLike());
+ var f32e = new Float32Array([21, 31, "a"]);
+ query.reset().inNumber("key", f32e);
+ console.info("inNumber(Float32Array([-21,31, 'a']) => " + query.getSqlLike());
+ var f64 = new Float64Array([-21, 31]);
+ query.reset().inNumber("key", f64);
+ console.info("inNumber(Float64Array([-21,31]) => " + query.getSqlLike());
+ query.reset();
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0200
+ * @tc.desc: Test Js Api Query.InNumber() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InNumber() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inNumber("key", [1, 2.3, 987654]).
+ inNumber("key2", [0x10abcdef]).
+ inNumber("key2", [0xf0123456]).
+ inNumber("key2", [0b10101]);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0300
+ * @tc.desc: Test Js Api Query.InNumber() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InNumber() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inNumber("key", 0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0400
+ * @tc.desc: Test Js Api Query.InNumber() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InNumber() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inNumber([0, 1]);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0500
+ * @tc.desc: Test Js Api Query.InNumber() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InNumber() testcase 005
+ */
+ it('SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0500', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ var u64 = new BigUint64Array([21, 31]);
+ query.inNumber("key", u64);
+ var b64 = new BigInt64Array([21, 31]);
+ query.inNumber("key", b64);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0600
+ * @tc.desc: Test Js Api Query.InNumber() testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InNumber() testcase 006
+ */
+ it('SUB_DDM_DKV_QUERY_ISNUMBER_PROMISE_0600', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ console.info("typeof([1, 2, 97])" + typeof([1, 2, 97]))
+ console.info("typeof([1, 2, 97][0])" + typeof([1, 2, 97][0]))
+ query.inNumber("key", [1, 2, 97]);
+ console.info("inNumber([1, 2, 97]) => " + query.getSqlLike());
+ query.reset();
+ query.inNumber("key1", [-1, 3, 987654.123, 0xabc123456]);
+ console.info("inNumber([1, 2, 0xa1234567890123456]) => " + query.getSqlLike());
+ query.reset();
+ query.inNumber("key2", [-1, 3, -987654.123, 0xabc123456]);
+ console.info("inNumber([1, 2, 0xa1234567890123456]) => " + query.getSqlLike());
+ query.reset();
+ query.inNumber("key3", [-1, 4, -987654.123, Number.MAX_VALUE]);
+ console.info("inNumber([1, 2, Number.MAX_VALUE]) => " + query.getSqlLike());
+ query.reset();
+ query.inNumber("key4", [1, -2.3, Number.MIN_VALUE, Number.MAX_VALUE]);
+ console.info("inNumber([1, -2.3, Number.MAX_VALUE]) => " + query.getSqlLike());
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ query.reset();
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0100
+ * @tc.desc: Test Js Api Query.InString() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InString() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inString("key", ["a2z" , 'z2a']);
+ query.inString("key2", ["AAA" ]);
+ console.info("query is " + query.getSqlLike());
+ expect(query.getSqlLike() !== "").assertTrue();
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0200
+ * @tc.desc: Test Js Api Query.InString() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InString() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inString("key", ["a2z" , 'z2a'])
+ .inString("key2", ["AAA" ])
+ .inString("key2", ["AAA", "AAABBB","CCCAAA" ]);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0300
+ * @tc.desc: Test Js Api Query.InString() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InString() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inString("key", 0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0400
+ * @tc.desc: Test Js Api Query.InString() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.InString() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_ISSTRING_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inString("key", [0, 1]);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTINNUMBER_PROMISE_0100
+ * @tc.desc: Test Js Api Query.NotInNumber() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.NotInNumber() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_NOTINNUMBER_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notInNumber("key", [1, 2]);
+ query.notInNumber("key", [1000]);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTINNUMBER_PROMISE_0200
+ * @tc.desc: Test Js Api Query.NotInNumber() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.NotInNumber() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_NOTINNUMBER_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notInNumber("key", [1, 2, 3]).notInNumber("key", [1, 7, 8]).notEqualTo("kkk", 5);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTINNUMBER_PROMISE_0300
+ * @tc.desc: Test Js Api Query.NotInNumber() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.NotInNumber() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_NOTINNUMBER_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notInNumber("key", ["string"]);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTINSTRING_PROMISE_0100
+ * @tc.desc: Test Js Api Query.NotInString() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.NotInString() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_NOTINSTRING_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notInString("key", ["v1", "v2"]);
+ query.notInString("key", ["v1", "NaN"]);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTINSTRING_PROMISE_0200
+ * @tc.desc: Test Js Api Query.NotInString() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.NotInString() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_NOTINSTRING_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notInString("key", ["v1", "v2", "v3"]).notEqualTo("kkk", "v3");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTINSTRING_PROMISE_0300
+ * @tc.desc: Test Js Api Query.NotInString() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.NotInString() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_NOTINSTRING_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notInString("key", [1, 2]);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIKE_PROMISE_0100
+ * @tc.desc: Test Js Api Query.Like() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Like() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_LIKE_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.like("key", "v1");
+ query.like("key2", "v2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIKE_PROMISE_0200
+ * @tc.desc: Test Js Api Query.Like() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Like() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_LIKE_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.like("key", "v1").like("key", "v3").like("key", "v2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIKE_PROMISE_0300
+ * @tc.desc: Test Js Api Query.Like() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Like() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_LIKE_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.like("key", 0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_UNLIKE_PROMISE_0100
+ * @tc.desc: Test Js Api Query.Unlike() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Unlike() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_UNLIKE_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.unlike("key", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_UNLIKE_PROMISE_0200
+ * @tc.desc: Test Js Api Query.Unlike() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Unlike() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_UNLIKE_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.unlike("key", "v1").unlike("key", "v3").unlike("key", "v2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_UNLIKE_PROMISE_0300
+ * @tc.desc: Test Js Api Query.Unlike() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Unlike() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_UNLIKE_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.unlike("key", 0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_AND_PROMISE_0100
+ * @tc.desc: Test Js Api Query.And() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.And() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_AND_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0);
+ query.and();
+ query.notEqualTo("key", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_AND_PROMISE_0200
+ * @tc.desc: Test Js Api Query.And() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.And() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_AND_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key1", 0).and().equalTo("key2", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_AND_PROMISE_0300
+ * @tc.desc: Test Js Api Query.And() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.And() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_AND_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0).and().notEqualTo("key", 1).and();
+ expect(query.getSqlLike() !== "").assertTrue();
+ query.reset();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_AND_PROMISE_0400
+ * @tc.desc: Test Js Api Query.And() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.And() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_AND_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0).and(1).notInNumber("key", [1, 3]);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_OR_PROMISE_0100
+ * @tc.desc: Test Js Api Query.Or() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Or() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_OR_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0);
+ query.or();
+ query.notEqualTo("key", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_OR_PROMISE_0200
+ * @tc.desc: Test Js Api Query.Or() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Or() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_OR_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.equalTo("key1", 0).or().equalTo("key2", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ query.reset();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_OR_PROMISE_0300
+ * @tc.desc: Test Js Api Query.Or() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Or() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_OR_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0).or();
+ console.info("or ... sql:" + query.getSqlLike());
+ expect(query.getSqlLike() !== "").assertTrue();
+ query.reset();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_OR_PROMISE_0400
+ * @tc.desc: Test Js Api Query.Or() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Or() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_OR_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0).or(1).notInNumber("key", [1, 3]);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0100
+ * @tc.desc: Test Js Api Query.OrderByAsc() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByAsc() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0);
+ query.orderByAsc("sortbykey");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0200
+ * @tc.desc: Test Js Api Query.OrderByAsc() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByAsc() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", "V0").orderByAsc("sortbykey1").orderByAsc("sortbykey2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0300
+ * @tc.desc: Test Js Api Query.OrderByAsc() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByAsc() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", false).orderByAsc(1);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0400
+ * @tc.desc: Test Js Api Query.OrderByAsc() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByAsc() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYASC_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.orderByAsc();
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0100
+ * @tc.desc: Test Js Api Query.OrderByDesc() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByDesc() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", 0);
+ query.orderByDesc("sortbykey");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0200
+ * @tc.desc: Test Js Api Query.OrderByDesc() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByDesc() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", "V0").orderByDesc("sortbykey1").orderByDesc("sortbykey2");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0300
+ * @tc.desc: Test Js Api Query.OrderByDesc() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByDesc() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", false).orderByDesc(1);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0400
+ * @tc.desc: Test Js Api Query.OrderByDesc() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.OrderByDesc() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_ORDERBYDESC_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.orderByDesc();
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0100
+ * @tc.desc: Test Js Api Query.Limit() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Limit() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", "vx");
+ query.limit(10, 2);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0200
+ * @tc.desc: Test Js Api Query.Limit() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Limit() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", "vx").limit(10, 2)
+ .equalTo("key2", 2).limit(10, 2);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0300
+ * @tc.desc: Test Js Api Query.Limit() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Limit() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", false).limit(10);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0400
+ * @tc.desc: Test Js Api Query.Limit() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.Limit() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_LIMIT_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.notEqualTo("key", false).limit("any", 10);
+ console.info("should throw exception on invalid arguments");
+ console.info("query is " + query.getSqlLike());
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTNULL_PROMISE_0100
+ * @tc.desc: Test Js Api Query.IsNotNull() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.IsNotNull() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_NOTNULL_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.isNotNull("key");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTNULL_PROMISE_0200
+ * @tc.desc: Test Js Api Query.IsNotNull() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.IsNotNull() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_NOTNULL_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.isNotNull("key1").and().notEqualTo("key1", 123);
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_NOTNULL_PROMISE_0300
+ * @tc.desc: Test Js Api Query.IsNotNull() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.IsNotNull() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_NOTNULL_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.isNotNull(1);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0100
+ * @tc.desc: Test Js Api Query.BeginGroup() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.BeginGroup() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.beginGroup();
+ query.isNotNull("$.name");
+ query.endGroup();
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0200
+ * @tc.desc: Test Js Api Query.BeginGroup() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.BeginGroup() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.beginGroup();
+ query.beginGroup();
+ query.notEqualTo("$.name", 0);
+ query.endGroup();
+ query.beginGroup();
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0300
+ * @tc.desc: Test Js Api Query.BeginGroup() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.BeginGroup() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.beginGroup(1);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0400
+ * @tc.desc: Test Js Api Query.BeginGroup() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.BeginGroup() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_BEGINGROUP_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.beginGroup("any", 1);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0100
+ * @tc.desc: Test Js Api Query.EndGroup() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.EndGroup() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.beginGroup();
+ query.isNotNull("$.name");
+ query.endGroup();
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0200
+ * @tc.desc: Test Js Api Query.EndGroup() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.EndGroup() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.endGroup();
+ query.beginGroup();
+ query.isNotNull("$.name");
+ query.endGroup();
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0300
+ * @tc.desc: Test Js Api Query.EndGroup() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.EndGroup() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.endGroup(0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0400
+ * @tc.desc: Test Js Api Query.EndGroup() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.EndGroup() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_ENDGROUP_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.endGroup("any");
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0100
+ * @tc.desc: Test Js Api Query.PrefixKey() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.PrefixKey() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.prefixKey("$.name");
+ query.prefixKey("0");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0200
+ * @tc.desc: Test Js Api Query.PrefixKey() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.PrefixKey() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.prefixKey("kx1").or().prefixKey("kx2").or().prefixKey("kx3");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300
+ * @tc.desc: Test Js Api Query.PrefixKey() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.PrefixKey() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.prefixKey(123);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_SETSUGGESTINDEX_PROMISE_0100
+ * @tc.desc: Test Js Api Query.SetSuggestIndex() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.SetSuggestIndex() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.setSuggestIndex("$.name");
+ query.setSuggestIndex("0");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0200
+ * @tc.desc: Test Js Api Query.SetSuggestIndex() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.SetSuggestIndex() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.setSuggestIndex("kxx").or().equalTo("key2", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300
+ * @tc.desc: Test Js Api Query.SetSuggestIndex() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.SetSuggestIndex() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_PREFIXKEY_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.setSuggestIndex(123);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_DEVICEID_PROMISE_0100
+ * @tc.desc: Test Js Api Query.DeviceId() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.DeviceId() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_DEVICEID_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.deviceId("$.name");
+ query.deviceId("0");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_DEVICEID_PROMISE_0200
+ * @tc.desc: Test Js Api Query.DeviceId() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.DeviceId() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_DEVICEID_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.deviceId("kxx").equalTo("key2", "v1");
+ expect(query.getSqlLike() !== "").assertTrue();
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_DEVICEID_PROMISE_0300
+ * @tc.desc: Test Js Api Query.DeviceId() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.DeviceId() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_DEVICEID_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.deviceId(123);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0100
+ * @tc.desc: Test Js Api Query.GetSqlLike() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GetSqlLike() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0100', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ let sql1 = query.getSqlLike();
+ console.info("testGetSqlLike001 sql=" + sql1);
+ let sql2 = query.getSqlLike();
+ expect(sql1).assertEqual(sql2);
+ console.info("query is " + query.getSqlLike());
+ } catch (e) {
+ console.error("dumplicated calls should be ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0200
+ * @tc.desc: Test Js Api Query.GetSqlLike() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GetSqlLike() testcase 002
+ */
+ it('SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0200', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ let sql1 = query.getSqlLike();
+ console.info("testGetSqlLike002 sql=" + sql1);
+ query.inString("key1", ["AAA", "BBB"])
+ .or()
+ .notEqualTo("key2", 0);
+ let sql2 = query.getSqlLike();
+ console.info("testGetSqlLike002 sql=" + sql2);
+ console.info("query is " + query.getSqlLike());
+ expect(sql1 !== sql2).assertTrue();
+ } catch (e) {
+ console.error("should be ok on Method Chaining : " + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0300
+ * @tc.desc: Test Js Api Query.GetSqlLike() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GetSqlLike() testcase 003
+ */
+ it('SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0300', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inNumber("key");
+ query.getSqlLike(0);
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number: SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0400
+ * @tc.desc: Test Js Api Query.GetSqlLike() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api Query.GetSqlLike() testcase 004
+ */
+ it('SUB_DDM_DKV_QUERY_GETSQLLIKE_PROMISE_0400', 0, async function(done) {
+ var query = null;
+ try {
+ query = new ddm.Query();
+ expect("").assertEqual(query.getSqlLike());
+ query.inNumber("key");
+ query.getSqlLike("any");
+ console.info("should throw exception on invalid arguments");
+ expect(null).assertFail();
+ } catch (e) {
+ console.error("throw exception is ok : " + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ query = null;
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_QUERY_SCHEMA_0100
+ * @tc.name Schema.constructor()
+ * @tc.desc Test Js Api Schema.constructor() testcase 001
+ */
+ it('SUB_DDM_DKV_QUERY_SCHEMA_0100', 0, async function(done) {
+ try {
+ let first = new ddm.FieldNode('first');
+ first.type = ddm.ValueType.STRING;
+ first.nullable = false;
+ first.default = 'first name';
+
+ let second = new ddm.FieldNode('second');
+ second.type = ddm.ValueType.STRING;
+ second.nullable = false;
+ second.default = 'second name';
+
+ let english = new ddm.FieldNode('english');
+ english.type = ddm.ValueType.STRING;
+ english.appendChild(first);
+ english.appendChild(second);
+
+ let schema = new ddm.Schema();
+ schema.root.appendChild(english);
+ schema.indexes = ['$.english.first', '$.english.second'];
+ } catch (e) {
+ console.info("schema fail on exception: " + e);
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..5b0b1188612ebf321ddf411dbb54d1244ad6276b
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js
@@ -0,0 +1,2394 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import dataShare from '@ohos.data.dataSharePredicates';
+import abilityFeatureAbility from '@ohos.ability.featureAbility'
+
+var context = abilityFeatureAbility.getContext();
+const KEY_TEST_INT_ELEMENT = 'key_test_int_2';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float_2';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean_2';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
+const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
+
+const VALUE_TEST_INT_ELEMENT = 1234;
+const VALUE_TEST_FLOAT_ELEMENT = 4321.12;
+const VALUE_TEST_BOOLEAN_ELEMENT = true;
+const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
+const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
+
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'storeId';
+var kvManager = null;
+var kvStore = null;
+const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
+const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
+var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
+
+function sleep(ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+}
+
+function putBatchString(len, prefix) {
+ let entries = [];
+ for (var i = 0; i < len; i++) {
+ var entry = {
+ key : prefix + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ return entries;
+}
+export default function SingleKvStoreCallbackTest(){
+describe('SingleKvStoreCallbackTest', function () {
+ const config = {
+ bundleName : TEST_BUNDLE_NAME,
+ context:context
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.SINGLE_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll config:'+ JSON.stringify(config));
+ await factory.createKVManager(config, function (err, manager) {
+ kvManager = manager;
+ console.info('beforeAll createKVManager success');
+ done();
+ })
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ kvManager = null;
+ kvStore = null;
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach' + JSON.stringify(options));
+ await kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
+ kvStore = store;
+ console.info('beforeEach getKVStore success');
+ done();
+ });
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ try {
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, async function (err, data) {
+ console.info('afterEach closeKVStore success: err is: '+err);
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err, data) {
+ console.info('afterEach deleteKVStore success err is: '+err);
+ done();
+ });
+ });
+ kvStore = null;
+ } catch (e) {
+ console.error('afterEach closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_0100
+ * @tc.desc Test Js Api SingleKvStore.Put(String) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(String) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_0100', 0, async function (done) {
+ console.info('SingleKvStorePutStringCallbackTest001');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStorePutStringCallbackTest001 put success');
+ } else {
+ console.error('SingleKvStorePutStringCallbackTest001 put fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch (e) {
+ console.error('SingleKvStorePutStringCallbackTest001 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_0200
+ * @tc.desc Test Js Api SingleKvStore.Put(String) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(String) testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_0200', 0, async function (done) {
+ console.info('SingleKvStorePutStringCallbackTest002');
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4095; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT+'102', str, async function (err,data) {
+ console.info('SingleKvStorePutStringCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_STRING_ELEMENT+'102', function (err,data) {
+ console.info('SingleKvStorePutStringCallbackTest002 get success');
+ expect(str == data).assertTrue();
+ done();
+ });
+ });
+ }catch (e) {
+ console.error('SingleKvStorePutStringCallbackTest002 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0300
+ * @tc.desc Test Js Api SingleKvStore.GetString() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetString() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0300', 0, async function (done) {
+ console.info('SingleKvStoreGetStringCallbackTest001');
+ try{
+ await kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetStringCallbackTest001 get success');
+ expect(true).assertTrue();
+ } else {
+ console.info('SingleKvStoreGetStringCallbackTest001 get fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetStringCallbackTest001 get e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0400
+ * @tc.desc Test Js Api SingleKvStore.GetString() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetString() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0400', 0, async function (done) {
+ console.info('SingleKvStoreGetStringCallbackTest002');
+ try{
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
+ console.info('SingleKvStoreGetStringCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreGetStringCallbackTest002 get success');
+ expect((err == undefined) && (VALUE_TEST_STRING_ELEMENT == data)).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreGetStringCallbackTest002 get e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0500
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0500', 0, async function (done) {
+ console.info('SingleKvStorePutIntCallbackTest001');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, async function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest001 get success');
+ expect((err == undefined) && (VALUE_TEST_INT_ELEMENT == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutIntCallbackTest001 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0600
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0600', 0, async function (done) {
+ console.info('SingleKvStorePutIntCallbackTest002');
+ try {
+ var intValue = 987654321;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue, async function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest002 get success');
+ expect((err == undefined) && (intValue == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutIntCallbackTest002 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0700
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0700', 0, async function (done) {
+ console.info('SingleKvStorePutIntCallbackTest003');
+ try {
+ var intValue = Number.MIN_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue, async function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest003 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest003 get success');
+ expect((err == undefined) && (intValue == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutIntCallbackTest003 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0800
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0800', 0, async function (done) {
+ console.info('SingleKvStorePutIntCallbackTest004');
+ try {
+ var intValue = Number.MAX_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue, async function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest004 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SingleKvStorePutIntCallbackTest004 get success');
+ expect((err == undefined) && (intValue == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutIntCallbackTest004 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0900
+ * @tc.desc Test Js Api SingleKvStore.GetInt() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetInt() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_0900', 0, async function (done) {
+ console.info('SingleKvStoreGetIntCallbackTest001');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, async function (err,data) {
+ console.info('SingleKvStoreGetIntCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreGetIntCallbackTest001 get success');
+ expect((err == undefined) && (VALUE_TEST_INT_ELEMENT == data)).assertTrue();
+ done();
+ })
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetIntCallbackTest001 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1000
+ * @tc.desc Test Js Api SingleKvStore.GetInt() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetInt() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1000', 0, async function (done) {
+ console.info('SingleKvStoreGetIntCallbackTest002');
+ try {
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetIntCallbackTest002 get success');
+ expect(true).assertTrue();
+ } else {
+ console.info('SingleKvStoreGetIntCallbackTest002 get fail');
+ }
+ done();
+ })
+ }catch(e) {
+ console.error('SingleKvStoreGetIntCallbackTest002 put e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_1100
+ * @tc.desc Test Js Api SingleKvStore.Put(Bool) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Bool) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_1100', 0, async function (done) {
+ console.info('SingleKvStorePutBoolCallbackTest001');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ console.info('SingleKvStorePutBoolCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBoolCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1200
+ * @tc.desc Test Js Api SingleKvStore.GetBool() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetBool() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1200', 0, async function (done) {
+ console.info('SingleKvStoreGetBoolCallbackTest001');
+ try {
+ await kvStore.get(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetBoolCallbackTest001 get success');
+ expect(true).assertTrue();
+ } else {
+ console.error('SingleKvStoreGetBoolCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetBoolCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1300
+ * @tc.desc Test Js Api SingleKvStore.GetBool() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetBool() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1300', 0, async function (done) {
+ console.info('SingleKvStoreGetBoolCallbackTest002');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, async function (err, data) {
+ console.info('SingleKvStoreGetBoolCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreGetBoolCallbackTest002 get success');
+ expect((err == undefined) && (VALUE_TEST_BOOLEAN_ELEMENT == data)).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreGetBoolCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_1400
+ * @tc.desc Test Js Api SingleKvStore.Put(Float) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Float) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUT_CALLBACK_1400', 0, async function (done) {
+ console.info('SingleKvStorePutFloatCallbackTest001');
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SingleKvStorePutFloatCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutFloatCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1500
+ * @tc.desc Test Js Api SingleKvStore.Put(Float) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Float) testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1500', 0, async function (done) {
+ console.info('SingleKvStorePutFloatCallbackTest002');
+ try {
+ var floatValue = 123456.654321;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue, async function (err,data) {
+ console.info('SingleKvStorePutFloatCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT, function (err, data) {
+ console.info('SingleKvStorePutFloatCallbackTest002 get success');
+ expect((err == undefined) && (floatValue == data)).assertTrue();
+ done();
+ })
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutFloatCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1600
+ * @tc.desc Test Js Api SingleKvStore.Put(Float) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Float) testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1600', 0, async function (done) {
+ console.info('SingleKvStorePutFloatCallbackTest003');
+ try {
+ var floatValue = 123456.0;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue, async function (err,data) {
+ console.info('SingleKvStorePutFloatCallbackTest003 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT, function (err, data) {
+ console.info('SingleKvStorePutFloatCallbackTest003 get success');
+ expect((err == undefined) && (floatValue == data)).assertTrue();
+ done();
+ })
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutFloatCallbackTest003 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1700
+ * @tc.desc Test Js Api SingleKvStore.Put(Float) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Float) testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1700', 0, async function (done) {
+ console.info('SingleKvStorePutFloatCallbackTest004');
+ try {
+ var floatValue = 123456.00;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue, async function (err,data) {
+ console.info('SingleKvStorePutFloatCallbackTest004 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT, function (err, data) {
+ console.info('SingleKvStorePutFloatCallbackTest004 get success');
+ expect((err == undefined) && (floatValue == data)).assertTrue();
+ done();
+ })
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutFloatCallbackTest004 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1800
+ * @tc.desc Test Js Api SingleKvStore.GetFloat() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetFloat() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GET_CALLBACK_1800', 0, async function (done) {
+ console.info('SingleKvStoreGetFloatCallbackTest001');
+ try {
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetFloatCallbackTest001 get success');
+ expect(true).assertTrue();
+ } else {
+ console.error('SingleKvStoreGetFloatCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetFloatCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_1900
+ * @tc.desc Test Js Api SingleKvStore.DeleteString() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteString() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_1900', 0, async function (done) {
+ console.info('SingleKvStoreDeleteStringCallbackTest001');
+ try {
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreDeleteStringCallbackTest001 delete success');
+ } else {
+ console.error('SingleKvStoreDeleteStringCallbackTest001 delete fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteStringCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2000
+ * @tc.desc Test Js Api SingleKvStore.DeleteString() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteString() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2000', 0, async function (done) {
+ console.info('SingleKvStoreDeleteStringCallbackTest002');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) {
+ console.info('SingleKvStoreDeleteStringCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreDeleteStringCallbackTest002 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreDeleteStringCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2100
+ * @tc.desc Test Js Api SingleKvStore.DeleteInt() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteInt() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2100', 0, async function (done) {
+ console.info('SingleKvStoreDeleteIntCallbackTest001');
+ try{
+ await kvStore.delete(KEY_TEST_INT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreDeleteIntCallbackTest001 get success');
+ } else {
+ console.error('SingleKvStoreDeleteIntCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteIntCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2200
+ * @tc.desc Test Js Api SingleKvStore.DeleteInt() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteInt() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2200', 0, async function (done) {
+ console.info('SingleKvStoreDeleteIntCallbackTest002');
+ try{
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, async function (err,data) {
+ console.info('SingleKvStoreDeleteIntCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_INT_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreDeleteIntCallbackTest002 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreDeleteIntCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2300
+ * @tc.desc Test Js Api SingleKvStore.DeleteFloat() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteFloat() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2300', 0, async function (done) {
+ console.info('SingleKvStoreDeleteFloatCallbackTest001');
+ try{
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreDeleteFloatCallbackTest001 get success');
+ } else {
+ console.error('SingleKvStoreDeleteFloatCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteFloatCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2400
+ * @tc.desc Test Js Api SingleKvStore.DeleteFloat() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteFloat() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2400', 0, async function (done) {
+ console.info('SingleKvStoreDeleteFloatCallbackTest002');
+ try{
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, async function (err, data) {
+ console.info('SingleKvStoreDeleteFloatCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreDeleteFloatCallbackTest002 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreDeleteFloatCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2500
+ * @tc.desc Test Js Api SingleKvStore.DeleteBool() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteBool() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2500', 0, async function (done) {
+ console.info('SingleKvStoreDeleteBoolCallbackTest001');
+ try{
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreDeleteBoolCallbackTest001 get success');
+ } else {
+ console.error('SingleKvStoreDeleteBoolCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteBoolCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2600
+ * @tc.desc Test Js Api SingleKvStore.DeleteBool() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteBool() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2600', 0, async function (done) {
+ console.info('SingleKvStoreDeleteBoolCallbackTest002');
+ try{
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, async function (err, data) {
+ console.info('SingleKvStoreDeleteBoolCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreDeleteBoolCallbackTest002 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreDeleteBoolCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700
+ * @tc.desc Test Js Api SingleKvStore.Delete() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Delete() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700', 0, async function (done) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest001');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ await kvStore.delete(predicates, function (err,data) {
+ if (err == undefined) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest001 delete success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreDeletePredicatesCallbackTest001 delete fail' + err`, error code is ${err.code}, message is ${err.message}`);
+ expect(err != undefined).assertTrue();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeletePredicatesCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2800
+ * @tc.desc Test Js Api SingleKvStore.Delete() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Delete() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2800', 0, async function (done) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest002');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ let arr = ["name"];
+ predicates.inKeys(arr);
+ await kvStore.put("name", "Bob", async function (err, data) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(predicates, function (err,data) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest002 delete success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ }catch(e) {
+ console.error('SingleKvStoreDeletePredicatesCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900
+ * @tc.desc Test Js Api SingleKvStore.Delete() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Delete() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900', 0, async function (done) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest003');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ let arr = [null];
+ predicates.inKeys(arr);
+ await kvStore.put("name", "Bob", async function (err, data) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest003 put success');
+ expect(err == undefined).assertTrue();
+ await kvStore.delete(predicates, function (err,data) {
+ console.log('SingleKvStoreDeletePredicatesCallbackTest003 delete success: '+err);
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ })
+ } catch(e) {
+ console.error('SingleKvStoreDeletePredicatesCallbackTest003 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3000
+ * @tc.desc Test Js Api SingleKvStore.OnChange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.OnChange() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3000', 0, async function (done) {
+ console.info('SingleKvStoreOnChangeCallbackTest001');
+ try {
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SingleKvStoreOnChangeCallbackTest001 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreOnChangeCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreOnChangeCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3100
+ * @tc.desc Test Js Api SingleKvStore.OnChange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.OnChange() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3100', 0, async function (done) {
+ console.info('SingleKvStoreOnChangeCallbackTest002');
+ try {
+ kvStore.on('dataChange', 1, function (data) {
+ console.info('SingleKvStoreOnChangeCallbackTest002 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreOnChangeCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreOnChangeCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3200
+ * @tc.desc Test Js Api SingleKvStore.OnChange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.OnChange() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3200', 0, async function (done) {
+ console.info('SingleKvStoreOnChangeCallbackTest003');
+ try {
+ kvStore.on('dataChange', 2, function (data) {
+ console.info('SingleKvStoreOnChangeCallbackTest003 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreOnChangeCallbackTest003 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreOnChangeCallbackTest003 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3300
+ * @tc.desc Test Js Api SingleKvStore.OnSyncComplete() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.OnSyncComplete() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3300', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SingleKvStoreOnSyncCompleteCallbackTest001 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'Sync1Test001', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreOnSyncCompleteCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ });
+ try {
+ var mode = factory.SyncMode.PULL_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode, 10);
+ } catch (e) {
+ console.error('SingleKvStoreOnSyncCompleteCallbackTest001 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SingleKvStoreOnSyncCompleteCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3400
+ * @tc.desc Test Js Api SingleKvStore.OnSyncComplete() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.OnSyncComplete() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3400', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SingleKvStoreOnSyncCompleteCallbackTest002 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'Sync1Test002', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreOnSyncCompleteCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode, 10);
+ } catch (e) {
+ console.error('SingleKvStoreOnSyncCompleteCallbackTest002 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SingleKvStoreOnSyncCompleteCallbackTest002 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3500
+ * @tc.desc Test Js Api SingleKvStore.OnSyncComplete() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.OnSyncComplete() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ON_CALLBACK_3500', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SingleKvStoreOnSyncCompleteCallbackTest003 dataChange');
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'Sync1Test003', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
+ console.info('SingleKvStoreOnSyncCompleteCallbackTest003 put success');
+ expect(err == undefined).assertTrue();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_PULL;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode, 10);
+ } catch (e) {
+ console.error('SingleKvStoreOnSyncCompleteCallbackTest003 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SingleKvStoreOnSyncCompleteCallbackTest003 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_3600
+ * @tc.desc Test Js Api SingleKvStore.SetSyncRange() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncRange() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_3600', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncRangeCallbackTest001');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['C', 'D'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
+ console.info('SingleKvStoreSetSyncRangeCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncRangeCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_3700
+ * @tc.desc Test Js Api SingleKvStore.SetSyncRange() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncRange() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_3700', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncRangeCallbackTest002');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['B', 'C'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
+ console.info('SingleKvStoreSetSyncRangeCallbackTest002 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncRangeCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_3800
+ * @tc.desc Test Js Api SingleKvStore.SetSyncRange() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncRange() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_3800', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncRangeCallbackTest003');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['A', 'B'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
+ console.info('SingleKvStoreSetSyncRangeCallbackTest003 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncRangeCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_3900
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_3900', 0, async function (done) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest001');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStorePutBatchEntryCallbackTest001 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest001 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_string_key', function (err,entrys) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest001 getEntries success');
+ console.info('SingleKvStorePutBatchEntryCallbackTest001 entrys.length: ' + entrys.length);
+ console.info('SingleKvStorePutBatchEntryCallbackTest001 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 'batch_test_string_value').assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBatchEntryCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4000
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4000', 0, async function (done) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest002');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.INTEGER,
+ value : 222
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStorePutBatchEntryCallbackTest002 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest002 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_number_key', function (err,entrys) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest002 getEntries success');
+ console.info('SingleKvStorePutBatchEntryCallbackTest002 entrys.length: ' + entrys.length);
+ console.info('SingleKvStorePutBatchEntryCallbackTest002 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 222).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBatchEntryCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4100
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4100', 0, async function (done) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest003');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.FLOAT,
+ value : 2.0
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStorePutBatchEntryCallbackTest003 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest003 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_number_key', function (err,entrys) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest003 getEntries success');
+ console.info('SingleKvStorePutBatchEntryCallbackTest003 entrys.length: ' + entrys.length);
+ console.info('SingleKvStorePutBatchEntryCallbackTest003 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.0).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBatchEntryCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4200
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4200', 0, async function (done) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest004');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.DOUBLE,
+ value : 2.00
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStorePutBatchEntryCallbackTest004 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest004 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_number_key', function (err,entrys) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest004 getEntries success');
+ console.info('SingleKvStorePutBatchEntryCallbackTest004 entrys.length: ' + entrys.length);
+ console.info('SingleKvStorePutBatchEntryCallbackTest004 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.00).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBatchEntryCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4300
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 005
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4300', 0, async function (done) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest005');
+ try {
+ var bo = false;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BOOLEAN,
+ value : bo
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStorePutBatchEntryCallbackTest005 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest005 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_bool_key', function (err,entrys) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest005 getEntries success');
+ console.info('SingleKvStorePutBatchEntryCallbackTest005 entrys.length: ' + entrys.length);
+ console.info('SingleKvStorePutBatchEntryCallbackTest005 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == bo).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBatchEntryCallbackTest005 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4400
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 006
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4400', 0, async function (done) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest006');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStorePutBatchEntryCallbackTest006 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest006 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_bool_key', function (err,entrys) {
+ console.info('SingleKvStorePutBatchEntryCallbackTest006 getEntries success');
+ console.info('SingleKvStorePutBatchEntryCallbackTest006 entrys.length: ' + entrys.length);
+ console.info('SingleKvStorePutBatchEntryCallbackTest006 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorePutBatchEntryCallbackTest006 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4500
+ * @tc.desc Test Js Api SingleKvStore.DeleteBatch() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteBatch() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCH_CALLBACK_4500', 0, async function (done) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest001');
+ try {
+ let entries = [];
+ let keys = [];
+ for (var i = 0; i < 5; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ keys.push(key + i);
+ }
+ console.info('SingleKvStoreDeleteBatchCallbackTest001 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest001 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest001 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteBatchCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCH_CALLBACK_4600
+ * @tc.desc Test Js Api SingleKvStore.DeleteBatch() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteBatch() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCH_CALLBACK_4600', 0, async function (done) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest002');
+ try {
+ let keys = ['batch_test_string_key1', 'batch_test_string_key2'];
+ await kvStore.deleteBatch(keys, function (err,data) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest002 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteBatchCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCH_CALLBACK_4700
+ * @tc.desc Test Js Api SingleKvStore.DeleteBatch() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.DeleteBatch() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCH_CALLBACK_4700', 0, async function (done) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest003');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStoreDeleteBatchCallbackTest003 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest003 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = ['batch_test_string_key1', 'batch_test_string_keya'];
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SingleKvStoreDeleteBatchCallbackTest003 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStoreDeleteBatchCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_4800
+ * @tc.desc Test Js Api SingleKvStore.startTransaction() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.startTransaction() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_4800', 0, async function (done) {
+ console.info('SingleKvStorestartTransactionCallbackTest001');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SingleKvStorestartTransactionCallbackTest001 0' + data)
+ count++;
+ });
+ await kvStore.startTransaction(async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest001 startTransaction success');
+ expect(err == undefined).assertTrue();
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SingleKvStorestartTransactionCallbackTest001 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest001 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest001 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.commit(async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest001 commit success');
+ expect(err == undefined).assertTrue();
+ await sleep(2000);
+ expect(count == 1).assertTrue();
+ done();
+ });
+ });
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorestartTransactionCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_4900
+ * @tc.desc Test Js Api SingleKvStore.startTransaction() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.startTransaction() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_4900', 0, async function (done) {
+ console.info('SingleKvStorestartTransactionCallbackTest002');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SingleKvStorestartTransactionCallbackTest002 0' + data)
+ count++;
+ });
+ await kvStore.startTransaction(async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest002 startTransaction success');
+ expect(err == undefined).assertTrue();
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SingleKvStorestartTransactionCallbackTest002 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest002 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys, async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest002 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.rollback(async function (err,data) {
+ console.info('SingleKvStorestartTransactionCallbackTest002 rollback success');
+ expect(err == undefined).assertTrue();
+ await sleep(2000);
+ expect(count == 0).assertTrue();
+ done();
+ });
+ });
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStorestartTransactionCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_5000
+ * @tc.desc Test Js Api SingleKvStore.startTransaction() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.startTransaction() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_5000', 0, async function (done) {
+ console.info('SingleKvStorestartTransactionCallbackTest003');
+ try {
+ await kvStore.startTransaction(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStorestartTransactionCallbackTest003 startTransaction success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStorestartTransactionCallbackTest003 startTransaction fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorestartTransactionCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_5100
+ * @tc.desc Test Js Api SingleKvStore.startTransaction() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.startTransaction() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_5100', 0, async function (done) {
+ console.info('SingleKvStorestartTransactionCallbackTest004');
+ try {
+ await kvStore.startTransaction('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStorestartTransactionCallbackTest004 startTransaction success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStorestartTransactionCallbackTest004 startTransaction fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorestartTransactionCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_5200
+ * @tc.desc Test Js Api SingleKvStore.startTransaction() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.startTransaction() testcase 005
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_TRANS_CALLBACK_5200', 0, async function (done) {
+ console.info('SingleKvStorestartTransactionCallbackTest005');
+ try {
+ await kvStore.startTransaction(2.000, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStorestartTransactionCallbackTest005 startTransaction success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStorestartTransactionCallbackTest005 startTransaction fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStorestartTransactionCallbackTest005 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_CALLBACK_5300
+ * @tc.desc Test Js Api SingleKvStore.Commit() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Commit() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_CALLBACK_5300', 0, async function (done) {
+ console.info('SingleKvStoreCommitCallbackTest001');
+ try {
+ await kvStore.commit(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreCommitCallbackTest001 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreCommitCallbackTest001 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreCommitCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_CALLBACK_5400
+ * @tc.desc Test Js Api SingleKvStore.Commit() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Commit() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_CALLBACK_5400', 0, async function (done) {
+ console.info('SingleKvStoreCommitCallbackTest002');
+ try {
+ await kvStore.commit('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreCommitCallbackTest002 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreCommitCallbackTest002 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreCommitCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_CALLBACK_5500
+ * @tc.desc Test Js Api SingleKvStore.Commit() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Commit() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_CALLBACK_5500', 0, async function (done) {
+ console.info('SingleKvStoreCommitCallbackTest003');
+ try {
+ await kvStore.commit(2.000, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreCommitCallbackTest003 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreCommitCallbackTest003 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreCommitCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ROLLBACK_CALLBACK_5600
+ * @tc.desc Test Js Api SingleKvStore.Rollback() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Rollback() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ROLLBACK_CALLBACK_5600', 0, async function (done) {
+ console.info('SingleKvStoreRollbackCallbackTest001');
+ try {
+ await kvStore.rollback(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRollbackCallbackTest001 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreRollbackCallbackTest001 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRollbackCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ROLLBACK_CALLBACK_5700
+ * @tc.desc Test Js Api SingleKvStore.Rollback() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Rollback() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ROLLBACK_CALLBACK_5700', 0, async function (done) {
+ console.info('SingleKvStoreRollbackCallbackTest002');
+ try {
+ await kvStore.rollback('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRollbackCallbackTest002 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreRollbackCallbackTest002 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRollbackCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ROLLBACK_CALLBACK_5800
+ * @tc.desc Test Js Api SingleKvStore.Rollback() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Rollback() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ROLLBACK_CALLBACK_5800', 0, async function (done) {
+ console.info('SingleKvStoreRollbackCallbackTest003');
+ try {
+ await kvStore.rollback(2.000, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRollbackCallbackTest003 commit success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreRollbackCallbackTest003 commit fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRollbackCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_5900
+ * @tc.desc Test Js Api SingleKvStore.EnableSync() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.EnableSync() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_5900', 0, async function (done) {
+ console.info('SingleKvStoreEnableSyncCallbackTest001');
+ try {
+ await kvStore.enableSync(true, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreEnableSyncCallbackTest001 enableSync success');
+ expect(err == undefined).assertTrue();
+ } else {
+ console.info('SingleKvStoreEnableSyncCallbackTest001 enableSync fail');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreEnableSyncCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_6000
+ * @tc.desc Test Js Api SingleKvStore.EnableSync() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.EnableSync() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_6000', 0, async function (done) {
+ console.info('SingleKvStoreEnableSyncCallbackTest002');
+ try {
+ await kvStore.enableSync(false, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreEnableSyncCallbackTest002 enableSync success');
+ expect(err == undefined).assertTrue();
+ } else {
+ console.info('SingleKvStoreEnableSyncCallbackTest002 enableSync fail');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreEnableSyncCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_6100
+ * @tc.desc Test Js Api SingleKvStore.EnableSync() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.EnableSync() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_6100', 0, async function (done) {
+ console.info('SingleKvStoreEnableSyncCallbackTest003');
+ try {
+ await kvStore.enableSync(function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreEnableSyncCallbackTest003 enableSync success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreEnableSyncCallbackTest003 enableSync fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreEnableSyncCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_6200
+ * @tc.desc Test Js Api SingleKvStore.EnableSync() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.EnableSync() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLE_CALLBACK_6200', 0, async function (done) {
+ console.info('SingleKvStoreEnableSyncCallbackTest004');
+ try {
+ await kvStore.enableSync(null, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreEnableSyncCallbackTest004 enableSync success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreEnableSyncCallbackTest004 enableSync fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreEnableSyncCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6300
+ * @tc.desc Test Js Api SingleKvStore.RemoveDeviceData() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.RemoveDeviceData() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6300', 0, async function (done) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest001');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ var deviceid = 'no_exist_device_id';
+ await kvStore.removeDeviceData(deviceid, async function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest001 removeDeviceData success');
+ expect(null).assertFail();
+ done();
+ } else {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest001 removeDeviceData fail');
+ await kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err,data) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest001 get success');
+ expect(data == VALUE_TEST_STRING_ELEMENT).assertTrue();
+ done();
+ });
+ }
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRemoveDeviceDataCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6400
+ * @tc.desc Test Js Api SingleKvStore.RemoveDeviceData() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.RemoveDeviceData() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6400', 0, async function (done) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest002');
+ try {
+ await kvStore.removeDeviceData(function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest002 removeDeviceData success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest002 removeDeviceData fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRemoveDeviceDataCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6500
+ * @tc.desc Test Js Api SingleKvStore.RemoveDeviceData() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.RemoveDeviceData() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6500', 0, async function (done) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest003');
+ try {
+ await kvStore.removeDeviceData('', function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest003 removeDeviceData success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest003 removeDeviceData fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRemoveDeviceDataCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6600
+ * @tc.desc Test Js Api SingleKvStore.RemoveDeviceData() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.RemoveDeviceData() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVE_CALLBACK_6600', 0, async function (done) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest004');
+ try {
+ await kvStore.removeDeviceData(null, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest004 removeDeviceData success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreRemoveDeviceDataCallbackTest004 removeDeviceData fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreRemoveDeviceDataCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_6700
+ * @tc.desc Test Js Api SingleKvStore.SetSyncParam() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncParam() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_6700', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest001');
+ try {
+ var defaultAllowedDelayMs = 500;
+ await kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest001 put success');
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncParamCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_6800
+ * @tc.desc Test Js Api SingleKvStore.SetSyncParam() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncParam() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_6800', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest002');
+ try {
+ await kvStore.setSyncParam(function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest002 put success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreSetSyncParamCallbackTest002 put err' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncParamCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_6900
+ * @tc.desc Test Js Api SingleKvStore.SetSyncParam() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncParam() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_6900', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest003');
+ try {
+ await kvStore.setSyncParam('', function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest003 put success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreSetSyncParamCallbackTest003 put err' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncParamCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_7000
+ * @tc.desc Test Js Api SingleKvStore.SetSyncParam() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.SetSyncParam() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNC_CALLBACK_7000', 0, async function (done) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest004');
+ try {
+ await kvStore.setSyncParam(null, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreSetSyncParamCallbackTest004 put success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreSetSyncParamCallbackTest004 put err' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreSetSyncParamCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7100
+ * @tc.desc Test Js Api SingleKvStore.GetSecurityLevel() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetSecurityLevel() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7100', 0, async function (done) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest001');
+ try {
+ await kvStore.getSecurityLevel(function (err,data) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest001 getSecurityLevel success: ' + data);
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest001 getSecurityLevel success: ' + factory.SecurityLevel.S2);
+ expect(data == factory.SecurityLevel.S2).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7200
+ * @tc.desc Test Js Api SingleKvStore.GetSecurityLevel() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetSecurityLevel() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7200', 0, async function (done) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest002');
+ try {
+ await kvStore.getSecurityLevel(1, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest002 getSecurityLevel success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest002 getSecurityLevel fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7300
+ * @tc.desc Test Js Api SingleKvStore.GetSecurityLevel() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetSecurityLevel() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7300', 0, async function (done) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest003');
+ try {
+ await kvStore.getSecurityLevel('test_string', function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest003 getSecurityLevel success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest003 getSecurityLevel fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7400
+ * @tc.desc Test Js Api SingleKvStore.GetSecurityLevel() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetSecurityLevel() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITY_CALLBACK_7400', 0, async function (done) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest004');
+ try {
+ await kvStore.getSecurityLevel(2.00, function (err,data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreGetSecurityLevelCallbackTest004 getSecurityLevel success');
+ expect(null).assertFail();
+ } else {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest004 getSecurityLevel fail' + `, error code is ${err.code}, message is ${err.message}`);
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetSecurityLevelCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7500
+ * @tc.desc Test Js Api SingleKvStore.GetResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7500', 0, async function (done) {
+ console.info('SingleKvStoreGetResultSetCallbackTest001');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries, async function (err, data) {
+ console.info('SingleKvStoreGetResultSetCallbackTest001 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getResultSet('batch_test_string_key', async function (err, result) {
+ console.info('SingleKvStoreGetResultSetCallbackTest001 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ console.info('SingleKvStoreGetResultSetCallbackTest001 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ done();
+ })
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetResultSetCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7600
+ * @tc.desc Test Js Api SingleKvStore.GetResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7600', 0, async function (done) {
+ console.info('SingleKvStoreGetResultSetCallbackTest002');
+ try {
+ let resultSet;
+ await kvStore.getResultSet(function (err, result) {
+ console.info('SingleKvStoreGetResultSetCallbackTest002 getResultSet success');
+ expect(null).assertFail();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetResultSetCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7700
+ * @tc.desc Test Js Api SingleKvStore.GetResultSet() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetResultSet() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7700', 0, async function (done) {
+ console.info('SingleKvStoreGetResultSetCallbackTest003');
+ try {
+ let resultSet;
+ await kvStore.getResultSet('test_key_string', 123, function (err, result) {
+ console.info('SingleKvStoreGetResultSetCallbackTest003 getResultSet success: '+err);
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreGetResultSetCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7800
+ * @tc.desc Test Js Api SingleKvStore.GetResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7800', 0, async function (done) {
+ console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ await kvStore.getResultSet(predicates).then((result) => {
+ console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet success');
+ }).catch((err) => {
+ console.error('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ });
+ } catch(e) {
+ console.error('SingleKvStoreGetResultSetPredicatesCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_7900
+ * @tc.desc Test Js Api SingleKvStore.CloseResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.CloseResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_7900', 0, async function (done) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest001');
+ try {
+ console.info('SingleKvStoreCloseResultSetCallbackTest001 success');
+ let resultSet = null;
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest001 closeResultSet success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreCloseResultSetCallbackTest001 closeResultSet fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreCloseResultSetCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8000
+ * @tc.desc Test Js Api SingleKvStore.CloseResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.CloseResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8000', 0, async function (done) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest002');
+ try {
+ let resultSet = null;
+ await kvStore.getResultSet('batch_test_string_key', async function(err, result) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest002 getResultSet success');
+ resultSet = result;
+ await kvStore.closeResultSet(resultSet, function (err, data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest002 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ } else {
+ console.info('SingleKvStoreCloseResultSetCallbackTest002 closeResultSet fail');
+ expect(null).assertFail();
+ }
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SingleKvStoreCloseResultSetCallbackTest002 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8100
+ * @tc.desc Test Js Api SingleKvStore.CloseResultSet() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.CloseResultSet() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8100', 0, async function (done) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest003');
+ try {
+ console.info('SingleKvStoreCloseResultSetCallbackTest003 success');
+ await kvStore.closeResultSet(function (err, data) {
+ if (err == undefined) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest003 closeResultSet success');
+ expect(null).assertFail();
+ } else {
+ console.info('SingleKvStoreCloseResultSetCallbackTest003 closeResultSet fail');
+ }
+ done();
+ });
+ }catch(e) {
+ console.error('SingleKvStoreCloseResultSetCallbackTest003 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8200
+ * @tc.desc Test Js Api SingleKvStore.CloseResultSet() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.CloseResultSet() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8200', 0, async function (done) {
+ console.info('SingleKvStoreCloseResultSetCallbackTest004');
+ try {
+ console.info('SingleKvStoreCloseResultSetCallbackTest004 success');
+ }catch(e) {
+ console.error('SingleKvStoreCloseResultSetCallbackTest004 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETENTRIES_CALLBACK_8300
+ * @tc.desc Test Js Api SingleKvStore.GetEntries() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetEntries() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETENTRIES_CALLBACK_8300', 0, async function (done) {
+ console.info('SingleKvStoreGetEntriesCallbackTest001');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SingleKvStoreGetEntriesCallbackTest001 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries, async function (err,data) {
+ console.info('SingleKvStoreGetEntriesCallbackTest001 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getEntries(query, function (err,entrys) {
+ console.info('SingleKvStoreGetEntriesCallbackTest001 getEntries success');
+ console.info('SingleKvStoreGetEntriesCallbackTest001 entrys.length: ' + entrys.length);
+ console.info('SingleKvStoreGetEntriesCallbackTest001 entrys[0]: ' + JSON.stringify(entrys[0]));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ done();
+ });
+ });
+ console.info('SingleKvStoreGetEntriesCallbackTest001 success');
+ }catch(e) {
+ console.error('SingleKvStoreGetEntriesCallbackTest001 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVPromiseJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVPromiseJsTest.js
new file mode 100644
index 0000000000000000000000000000000000000000..e89e37d227199a18fce0a8dadaa3fde9a0b5b51b
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVPromiseJsTest.js
@@ -0,0 +1,3039 @@
+/*
+* Copyright (c) 2022 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+import factory from '@ohos.data.distributedKVStore'
+import dataShare from '@ohos.data.dataSharePredicates'
+import abilityFeatureAbility from '@ohos.ability.featureAbility'
+
+var context = abilityFeatureAbility.getContext();
+const KEY_TEST_INT_ELEMENT = 'key_test_int';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string';
+const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
+
+const VALUE_TEST_INT_ELEMENT = 123;
+const VALUE_TEST_FLOAT_ELEMENT = 321.12;
+const VALUE_TEST_BOOLEAN_ELEMENT = true;
+const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
+const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
+
+const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
+const TEST_STORE_ID = 'storeId';
+var kvManager = null;
+var kvStore = null;
+const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
+const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
+var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
+
+function sleep(ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+}
+
+function putBatchString(len, prefix) {
+ let entries = [];
+ for (var i = 0; i < len; i++) {
+ var entry = {
+ key : prefix + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ return entries;
+}
+export default function SingleKvStorePromiseTest(){
+describe('SingleKvStorePromiseTest', function () {
+ const config = {
+ bundleName : TEST_BUNDLE_NAME,
+ context: context
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : factory.KVStoreType.SINGLE_VERSION,
+ schema : '',
+ securityLevel : factory.SecurityLevel.S2,
+ }
+
+ beforeAll(async function (done) {
+ console.info('beforeAll config:'+ JSON.stringify(config));
+ await factory.createKVManager(config).then((manager) => {
+ kvManager = manager;
+ console.info('beforeAll createKVManager success');
+ }).catch((err) => {
+ console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ console.info('beforeAll end');
+ done();
+ })
+
+ afterAll(async function (done) {
+ console.info('afterAll');
+ kvManager = null;
+ kvStore = null;
+ done();
+ })
+
+ beforeEach(async function (done) {
+ console.info('beforeEach' + JSON.stringify(options));
+ await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
+ kvStore = store;
+ console.info('beforeEach getKVStore success');
+ }).catch((err) => {
+ console.error('beforeEach getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ console.info('beforeEach end');
+ done();
+ })
+
+ afterEach(async function (done) {
+ console.info('afterEach');
+ await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => {
+ console.info('afterEach closeKVStore success');
+ await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
+ console.info('afterEach deleteKVStore success');
+ }).catch((err) => {
+ console.error('afterEach deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }).catch((err) => {
+ console.error('afterEach closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ kvStore = null;
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.Put(String) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(String) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, null).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0100 put success');
+ expect(null).assertFail();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0100 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStore.Put(String) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(String) testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0200');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, '').then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0200 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStore.Put(String) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(String) testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0300');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0300 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStore.Put(String) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(String) testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400');
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4095; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, str).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400 get success data ' + data);
+ expect(str == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTSTRING_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetString testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetString testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100 get success');
+ expect(VALUE_TEST_STRING_ELEMENT == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100 put error' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreGetString testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetString testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0200');
+ try {
+ await kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0200 get success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0200 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSTRING_PROMISE_0200 get e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200');
+ try {
+ var intValue = 987654321;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200 get success');
+ expect(intValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300');
+ try {
+ var intValue = Number.MAX_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300 get success');
+ expect(intValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStore.Put(Int) testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Int) testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400');
+ try {
+ var intValue = Number.MIN_VALUE;
+ await kvStore.put(KEY_TEST_INT_ELEMENT, intValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400 get success');
+ expect(intValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTINT_PROMISE_0400 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetInt testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetInt testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100 get success');
+ expect(VALUE_TEST_INT_ELEMENT == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETINT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBOOLEAN_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.Put(Bool) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Bool) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBOOLEAN_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBOOLEAN_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBOOLEAN_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBOOLEAN_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBOOLEAN_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetBool testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetBool testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100', 0, async function (done) {
+ console.info('SingleKvStoreGetBoolPromiseTest001');
+ try {
+ var boolValue = false;
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, boolValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_BOOLEAN_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100 get success');
+ expect(boolValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETBOOLEAN_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTFLOAT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.Put(Float) testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Put(Float) testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTFLOAT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTFLOAT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTFLOAT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTFLOAT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTFLOAT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetFloat testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetFloat testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100');
+ try {
+ var floatValue = 123456.654321;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100 get success');
+ expect(floatValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreGetFloat testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetFloat testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200');
+ try {
+ var floatValue = 123456.0;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200 get success');
+ expect(floatValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreGetFloat testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetFloat testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300');
+ try {
+ var floatValue = 123456.00;
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, floatValue).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300 get success');
+ expect(floatValue == data).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETFLOAT_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreDeleteString testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteString testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100');
+ try {
+ var str = 'this is a test string';
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, str).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreDeleteString testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteString testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200');
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4096; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, str).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreDeleteString testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteString testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300');
+ try {
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreDeleteInt testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteInt testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_INT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEINT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreDeleteFloat testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteFloat testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEFLOAT_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreDeleteBool testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteBool testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT).then(async (data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBOOLEAN_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.Delete() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Delete() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100', 0, async function (done) {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ await kvStore.delete(predicates).then((data) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(err != undefined).assertTrue();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStore.Delete() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Delete() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200', 0, async function (done) {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ let arr = ["name"];
+ predicates.inKeys(arr);
+ await kvStore.put("name", "Bob").then(async (data) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ await kvStore.delete(predicates).then((data) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 delete success');
+ expect(data == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStore.Delete() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.Delete() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300', 0, async function (done) {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ let arr = [null];
+ predicates.inKeys(arr);
+ await kvStore.put("name", "Bob").then(async (data) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put success');
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.delete(predicates, function (err,data) {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete success');
+ expect(err != undefined).assertTrue();
+ done();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreOnChange testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOnChange testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100 ' + JSON.stringify(data));
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreOnChange testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOnChange testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 1, function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200 on ' + JSON.stringify(data));
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreOnChange testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOnChange testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 2, function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300 ' + JSON.stringify(data));
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreOnSyncComplete testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOnSyncComplete testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 0' + data)
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PULL_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode, 10);
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreOnSyncComplete testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOnSyncComplete testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 0' + data)
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_ONLY;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode, 10);
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreOnSyncComplete testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOnSyncComplete testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300', 0, async function (done) {
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 0' + data)
+ expect(data != null).assertTrue();
+ });
+ await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 put success');
+ expect(data == undefined).assertTrue();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 put fail ' + `, error code is ${error.code}, message is ${error.message}`);
+ expect(null).assertFail();
+ });
+ try {
+ var mode = factory.SyncMode.PUSH_PULL;
+ console.info('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
+ kvStore.sync(syncDeviceIds, mode, 10);
+ } catch (e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreOffChange testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffChange testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100 ' + JSON.stringify(data));
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.off('dataChange', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreOffChange testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffChange testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200');
+ let ret = false;
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 ' + JSON.stringify(data));
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 ' + JSON.stringify(data));
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.on('dataChange', 0, func1);
+ kvStore.off('dataChange', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreOffChange testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffChange testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 0' + data)
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.on('dataChange', 0, func1);
+ kvStore.off('dataChange', func);
+ kvStore.off('dataChange', func1);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreOffChange testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffChange testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400 ' + JSON.stringify(data));
+ };
+ kvStore.on('dataChange', 0, func);
+ kvStore.off('dataChange');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreOffSyncComplete testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffSyncComplete testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.off('syncComplete', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreOffSyncComplete testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffSyncComplete testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.on('syncComplete', func1);
+ kvStore.off('syncComplete', func);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreOffSyncComplete testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffSyncComplete testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 0' + data)
+ };
+ var func1 = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.on('syncComplete', func1);
+ kvStore.off('syncComplete', func);
+ kvStore.off('syncComplete', func1);
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreOffSyncComplete testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreOffSyncComplete testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400');
+ try {
+ var func = function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400 0' + data)
+ };
+ kvStore.on('syncComplete', func);
+ kvStore.off('syncComplete');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400 put e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreSetSyncRange testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreSetSyncRange testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['C', 'D'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 setSyncRange success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreSetSyncRange testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreSetSyncRange testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['B', 'C'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 setSyncRange success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreSetSyncRange testcase 003
+ * @tc.type: FUNC
+ * @tc.name issueNumber
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300');
+ try {
+ var localLabels = ['A', 'B'];
+ var remoteSupportLabels = ['A', 'B'];
+ await kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 setSyncRange success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100');
+ try {
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_string_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 getEntries success');
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 ' + JSON.stringify(entries));
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 'batch_test_string_value').assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.INTEGER,
+ value : 222
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_number_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 222).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.FLOAT,
+ value : 2.0
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_number_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.0).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_number_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.DOUBLE,
+ value : 2.00
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_number_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == 2.00).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 005
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500');
+ try {
+ var bo = false;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BOOLEAN,
+ value : bo
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_bool_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value == bo).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 006
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600');
+ try {
+ var arr = new Uint8Array([21,31]);
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_bool_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.BYTE_ARRAY,
+ value : arr
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.getEntries('batch_test_bool_key').then((entrys) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600 getEntries success');
+ expect(entrys.length == 10).assertTrue();
+ expect(entrys[0].value.value.toString() == arr.toString()).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600 getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0600 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100');
+ try {
+ let values = [];
+ let arr1 = new Uint8Array([4,5,6,7]);
+ let arr2 = new Uint8Array([4,5,6,7,8]);
+ let vb1 = {key : "name_1", value : arr1};
+ let vb2 = {key : "name_2", value : arr2};
+ values.push(vb1);
+ values.push(vb2);
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 values: ' + JSON.stringify(values));
+ await kvStore.putBatch(values).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("name_");
+ await kvStore.getEntries(query).then((entrys) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 getEntries success');
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys.length: ' + entrys.length);
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys[0]: ' + JSON.stringify(entrys[1]));
+ expect(entrys.length == 2).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200');
+ try {
+ let values = [];
+ let vb1 = {key : "name_1", value : "arr1"};
+ let vb2 = {key : "name_2", value : "arr2"};
+ values.push(vb1);
+ values.push(vb2);
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 values: ' + JSON.stringify(values));
+ await kvStore.putBatch(values).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("name_");
+ await kvStore.getEntries(query).then((entrys) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 getEntries success');
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys.length: ' + entrys.length);
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys[0]: ' + JSON.stringify(entrys[1]));
+ expect(entrys.length == 2).assertTrue();
+ done();
+ }).catch((err) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 delete fail ' + err);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 delete fail ' + err);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300');
+ try {
+ let values = [];
+ let vb1 = {key : "name_1", value : 123};
+ let vb2 = {key : "name_2", value : 321.0};
+ let vb3 = {key : "name_3", value : 321.00};
+ values.push(vb1);
+ values.push(vb2);
+ values.push(vb3);
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 values: ' + JSON.stringify(values));
+ await kvStore.putBatch(values).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("name_");
+ await kvStore.getEntries(query).then((entrys) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 getEntries success');
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys.length: ' + entrys.length);
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys[0]: ' + JSON.stringify(entrys[2]));
+ expect(entrys.length == 3).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400');
+ try {
+ let values = [];
+ let vb1 = {key : "name_1", value : true};
+ let vb2 = {key : "name_2", value : false};
+ values.push(vb1);
+ values.push(vb2);
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 values: ' + JSON.stringify(values));
+ await kvStore.putBatch(values).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("name_");
+ await kvStore.getEntries(query).then((entrys) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 getEntries success');
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys.length: ' + entrys.length);
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys[0]: ' + JSON.stringify(entrys[1]));
+ expect(entrys.length == 2).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500
+ * @tc.desc Test Js Api SingleKvStore.PutBatch() testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.PutBatch() testcase 005
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500');
+ try {
+ let values = [];
+ let vb1 = {key : "name_1", value : null};
+ let vb2 = {key : "name_2", value : null};
+ values.push(vb1);
+ values.push(vb2);
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 values: ' + JSON.stringify(values));
+ await kvStore.putBatch(values).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ var query = new factory.Query();
+ query.prefixKey("name_");
+ await kvStore.getEntries(query).then((entrys) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 getEntries success');
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys.length: ' + entrys.length);
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[1]));
+ expect(entrys.length == 2).assertTrue();
+ expect(entrys[0].value == null).assertTrue();
+ done();
+ });
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ done();
+ }
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreDeleteBatch testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteBatch testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100');
+ try {
+ let entries = [];
+ let keys = [];
+ for (var i = 0; i < 5; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ keys.push(key + i);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreDeleteBatch testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteBatch testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200');
+ try {
+ let keys = ['batch_test_string_key1', 'batch_test_string_key2'];
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 deleteBatch success');
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreDeleteBatch testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreDeleteBatch testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 putBatch success');
+ expect(err == undefined).assertTrue();
+ let keys = ['batch_test_string_key1', 'batch_test_string_keya'];
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 deleteBatch success');
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStorestartTransaction testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStorestartTransaction testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', factory.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 ' + JSON.stringify(data));
+ count++;
+ });
+ await kvStore.startTransaction().then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 startTransaction success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.commit().then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 commit success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await sleep(2000);
+ expect(count == 1).assertTrue();
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStorestartTransaction testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStorestartTransaction testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200');
+ try {
+ var count = 0;
+ kvStore.on('dataChange', 0, function (data) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 ' + JSON.stringify(data));
+ count++;
+ });
+ await kvStore.startTransaction().then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 startTransaction success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let entries = putBatchString(10, 'batch_test_string_key');
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 entries: ' + JSON.stringify(entries));
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let keys = Object.keys(entries).slice(5);
+ await kvStore.deleteBatch(keys).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 deleteBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.rollback().then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 rollback success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await sleep(2000);
+ expect(count == 0).assertTrue();
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStorestartTransaction testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStorestartTransaction testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200');
+ try {
+ await kvStore.startTransaction(1).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300 startTransaction success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStorestartTransaction testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStorestartTransaction testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0400');
+ try {
+ await kvStore.startTransaction('test_string').then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0400 startTransaction success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0400 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0500
+ * @tc.desc Test Js Api SingleKvStorestartTransaction testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStorestartTransaction testcase 005
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0500');
+ try {
+ await kvStore.startTransaction(2.000).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0500 startTransaction success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0500 startTransaction fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_COMMIT_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreCommit testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCommit testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100');
+ try {
+ await kvStore.commit(1).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 commit success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreCommit testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCommit testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200');
+ try {
+ await kvStore.commit('test_string').then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 commit success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreCommit testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCommit testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300');
+ try {
+ await kvStore.commit(2.000).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300 commit success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300 commit fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreRollback testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRollback testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0100');
+ try {
+ await kvStore.rollback(1).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0100 rollback success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0100 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreRollback testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRollback testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0200');
+ try {
+ await kvStore.rollback('test_string').then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0200 rollback success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0200 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreRollback testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRollback testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0300');
+ try {
+ await kvStore.rollback(2.000).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0300 rollback success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0300 rollback fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ROOLBACK_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreEnableSync testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreEnableSync testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0100');
+ try {
+ await kvStore.enableSync(true).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0100 enableSync success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0100 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreEnableSync testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreEnableSync testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0200');
+ try {
+ await kvStore.enableSync(false).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0200 enableSync success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0200 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreEnableSync testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreEnableSync testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0300');
+ try {
+ await kvStore.enableSync().then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0300 enableSync success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0300 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreEnableSync testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreEnableSync testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0400');
+ try {
+ await kvStore.enableSync(null).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0400 enableSync success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0400 enableSync fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_ENABLESYNC_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreRemoveDeviceData testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRemoveDeviceData testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100');
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 put success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var deviceid = 'no_exist_device_id';
+ await kvStore.removeDeviceData(deviceid).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ await kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 get success data:' + data);
+ expect(data == VALUE_TEST_STRING_ELEMENT).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 get fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreRemoveDeviceData testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRemoveDeviceData testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200');
+ try {
+ await kvStore.removeDeviceData().then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreRemoveDeviceData testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRemoveDeviceData testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300');
+ try {
+ await kvStore.removeDeviceData('').then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreRemoveDeviceData testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreRemoveDeviceData testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400');
+ try {
+ await kvStore.removeDeviceData(null).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400 removeDeviceData success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400 removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_REMOVEDEVICEDATA_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreSetSyncParam testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreSetSyncParam testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0100');
+ try {
+ var defaultAllowedDelayMs = 500;
+ await kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0100 put success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0100 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreSetSyncParam testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreSetSyncParam testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0200');
+ try {
+ await kvStore.setSyncParam().then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0200 put success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0200 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreSetSyncParam testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreSetSyncParam testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0300');
+ try {
+ await kvStore.setSyncParam('').then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0300 put success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreSetSyncParam testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreSetSyncParam testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0400');
+ try {
+ await kvStore.setSyncParam(null).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0400 put success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0400 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCPARAM_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetSecurityLevel testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetSecurityLevel testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100');
+ try {
+ await kvStore.getSecurityLevel().then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel success');
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel success: ' + data);
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel success: ' + factory.SecurityLevel.S2);
+ expect(data == factory.SecurityLevel.S2).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreGetSecurityLevel testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetSecurityLevel testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200');
+ try {
+ await kvStore.getSecurityLevel(1).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getSecurityLevel success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreGetSecurityLevel testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetSecurityLevel testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300');
+ try {
+ await kvStore.getSecurityLevel('test_string').then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300 getSecurityLevel success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreGetSecurityLevel testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetSecurityLevel testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400');
+ try {
+ await kvStore.getSecurityLevel(2.000).then((data) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400 getSecurityLevel success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400 getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSet testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.getResultSet('batch_test_string_key').then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSet testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200');
+ try {
+ let resultSet;
+ await kvStore.getResultSet('batch_test_string_key').then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 0).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSet testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300');
+ try {
+ let resultSet;
+ await kvStore.getResultSet().then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300 getResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSet testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400');
+ try {
+ await kvStore.getResultSet('test_key_string', 123).then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400 getResultSet success');
+ expect(true).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500
+ * @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 005
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSet testcase 005
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSet(query).then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0500 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600
+ * @tc.desc Test Js Api SingleKvStoreGetResultSet testcase 006
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSet testcase 006
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600');
+ try {
+ let resultSet;
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSet(query).then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETSECURITYLEVEL_PROMISE_0600 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStore.GetResultSet() testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetResultSet() testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100', 0, async function (done) {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100');
+ try {
+ let entries = [];
+ let resultSet;
+ for (let i = 0; i < 10; i++) {
+ let key = 'name_';
+ let value = 'Bob_'
+ let entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value :value + i
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ let predicates = new dataShare.DataSharePredicates();
+ predicates.prefixKey("name_");
+ await kvStore.getResultSet(predicates).then((result) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 getResultSet success');
+ resultSet = result;
+ expect(resultSet.getCount() == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStore.GetResultSet() testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStore.GetResultSet() testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0200', 0, async function (done) {
+ console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0200');
+ try {
+ let predicates = new dataShare.DataSharePredicates();
+ await kvStore.getResultSet(predicates, async function (err, result) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0200 GetResultSet success: '+`, error code is ${err.code}, message is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ done();
+ });
+ } catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0200 e' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreCloseResultSet testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100');
+ try {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100 success');
+ let resultSet = null;
+ await kvStore.closeResultSet(resultSet).then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100 closeResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreCloseResultSet testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200');
+ try {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 success');
+ let resultSet = null;
+ await kvStore.getResultSet('batch_test_string_key').then((result) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 getResultSet success');
+ resultSet = result;
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ await kvStore.closeResultSet(resultSet).then((err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 closeResultSet success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300
+ * @tc.desc Test Js Api SingleKvStoreCloseResultSet testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300');
+ try {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 success');
+ let resultSet = null;
+ await kvStore.closeResultSet().then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 closeResultSet success');
+ expect(null).assertFail();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(e.code == 401).assertTrue();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400
+ * @tc.desc Test Js Api SingleKvStoreCloseResultSet testcase 004
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 004
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400');
+ try {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 success');
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreGetResultSize testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreGetResultSize testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100', 0, async function (done) {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100');
+ try {
+ let entries = [];
+ for (var i = 0; i < 10; i++) {
+ var key = 'batch_test_string_key';
+ var entry = {
+ key : key + i,
+ value : {
+ type : factory.ValueType.STRING,
+ value : 'batch_test_string_value'
+ }
+ }
+ entries.push(entry);
+ }
+ await kvStore.putBatch(entries).then(async (err) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100 putBatch success');
+ expect(err == undefined).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ var query = new factory.Query();
+ query.prefixKey("batch_test");
+ await kvStore.getResultSize(query).then((resultSize) => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100 getResultSet success');
+ expect(resultSize == 10).assertTrue();
+ }).catch((err) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(null).assertFail();
+ });
+ }catch(e) {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSIZE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreChangeNotification testcase 001
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreChangeNotification testcase 001
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100', 0, async function (done) {
+ var getInsertEntries = new Promise((resolve, reject) => {
+ kvStore.on('dataChange', 0, function(ChangeNotification){
+ resolve(ChangeNotification.insertEntries);
+ });
+ kvStore.put("getInsertEntries", "byPut").then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 put success');
+ });
+ });
+ await getInsertEntries.then(function(insertEntries){
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 getInsertEntries' + JSON.stringify(insertEntries));
+ expect(insertEntries).assertNotNull();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 can NOT getInsertEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`);
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200
+ * @tc.desc Test Js Api SingleKvStoreChangeNotification testcase 002
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreChangeNotification testcase 002
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200', 0, async function (done) {
+ await kvStore.put('getUpdateEntries', 'byPut').then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 put success');
+ });
+ var getUpdateEntries = new Promise((resolve, reject) => {
+ kvStore.on('dataChange', 0, function(ChangeNotification){
+ resolve(ChangeNotification.updateEntries);
+ });
+ kvStore.put("getUpdateEntries", "byPut").then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 update success');
+ });
+ });
+ await getUpdateEntries.then(function(updateEntries){
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 getUpdateEntries' + JSON.stringify(updateEntries));
+ expect(updateEntries).assertNotNull();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 can NOT getUpdateEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`);
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100
+ * @tc.desc Test Js Api SingleKvStoreChangeNotification testcase 003
+ * @tc.type: FUNC
+ * @tc.name Test Js Api SingleKvStoreChangeNotification testcase 003
+ */
+ it('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100', 0, async function (done) {
+ await kvStore.put('deleteEntries', 'byPut').then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 put success');
+ });
+ var getdeleteEntries = new Promise((resolve, reject) => {
+ kvStore.on('dataChange', 0, function(ChangeNotification){
+ resolve(ChangeNotification.deleteEntries);
+ });
+ kvStore.delete("deleteEntries").then(() => {
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 delete success');
+ });
+ });
+ await getdeleteEntries.then(function(deleteEntries){
+ console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 deleteEntries' + JSON.stringify(getdeleteEntries));
+ expect(deleteEntries != null).assertNotNull();
+ }).catch((error) => {
+ console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 can NOT getdeleteEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`);
+ });
+ done();
+ })
+})
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/resources/base/element/string.json b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2b3eff51449eea76205fff9da7c44c27d1c54d15
--- /dev/null
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "DistributeddatamgrJsTest"
+ },
+ {
+ "name": "mainability_description",
+ "value": "hap sample empty page"
+ },
+ {
+ "name": "MainAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "MainAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "TestAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "TestAbility_label",
+ "value": "label"
+ }
+ ]
+}
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/resources/base/media/icon.png b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/resources/base/media/icon.png differ