• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { paramMock } from "../utils"
17
18export function mockDistributedData() {
19  const SchemaClass = class Schema {
20    constructor() {
21      console.warn('Schema.constructor interface mocked in the Previewer. How this interface works on the' +
22        ' Previewer may be different from that on a real device.');
23      this.toJsonString = function (...args) {
24        console.warn("Schema.toJsonString interface mocked in the Previewer. How this interface works" +
25          " on the Previewer may be different from that on a real device.")
26        return paramMock.paramStringMock;
27      }
28    }
29  };
30
31  const FieldNodeClass = class FieldNode {
32    constructor(...args) {
33      console.warn('FieldNode.constructor interface mocked in the Previewer. How this interface works on the' +
34        ' Previewer may be different from that on a real device.');
35
36      this.appendChild = function (...args) {
37        console.warn("FieldNode.appendChild interface mocked in the Previewer. How this interface works" +
38          " on the Previewer may be different from that on a real device.")
39        return paramMock.paramBooleanMock;
40      };
41
42      this.toJson = function (...args) {
43        console.warn("FieldNode.toJson interface mocked in the Previewer. How this interface works" +
44          " on the Previewer may be different from that on a real device.")
45        return paramMock.paramStringMock;
46      };
47    }
48  };
49
50  const QueryClass = class Query {
51    constructor() {
52      console.warn('Query.constructor interface mocked in the Previewer. How this interface works on the' +
53        ' Previewer may be different from that on a real device.');
54      this.reset = function (...args) {
55        console.warn("Query.reset interface mocked in the Previewer. How this interface works" +
56          " on the Previewer may be different from that on a real device.")
57        return QueryClass;
58      };
59
60      this.equalTo = function (...args) {
61        console.warn("Query.equalTo interface mocked in the Previewer. How this interface works" +
62          " on the Previewer may be different from that on a real device.")
63        return QueryClass;
64      };
65
66      this.notEqualTo = function (...args) {
67        console.warn("Query.notEqualTo interface mocked in the Previewer. How this interface works" +
68          " on the Previewer may be different from that on a real device.")
69        return QueryClass;
70      };
71
72      this.greaterThan = function (...args) {
73        console.warn("Query.greaterThan interface mocked in the Previewer. How this interface works" +
74          " on the Previewer may be different from that on a real device.")
75        return QueryClass;
76      };
77
78      this.lessThan = function (...args) {
79        console.warn("Query.lessThan interface mocked in the Previewer. How this interface works" +
80          " on the Previewer may be different from that on a real device.")
81        return QueryClass;
82      };
83
84      this.greaterThanOrEqualTo = function (...args) {
85        console.warn("Query.greaterThanOrEqualTo interface mocked in the Previewer. How this interface works" +
86          " on the Previewer may be different from that on a real device.")
87        return QueryClass;
88      };
89
90      this.lessThanOrEqualTo = function (...args) {
91        console.warn("Query.lessThanOrEqualTo interface mocked in the Previewer. How this interface works" +
92          " on the Previewer may be different from that on a real device.")
93        return QueryClass;
94      };
95
96      this.isNull = function (...args) {
97        console.warn("Query.isNull interface mocked in the Previewer. How this interface works" +
98          " on the Previewer may be different from that on a real device.")
99        return QueryClass;
100      };
101
102      this.inNumber = function (...args) {
103        console.warn("Query.inNumber interface mocked in the Previewer. How this interface works" +
104          " on the Previewer may be different from that on a real device.")
105        return QueryClass;
106      };
107
108      this.inString = function (...args) {
109        console.warn("Query.inString interface mocked in the Previewer. How this interface works" +
110          " on the Previewer may be different from that on a real device.")
111        return QueryClass;
112      };
113
114      this.notInNumber = function (...args) {
115        console.warn("Query.notInNumber interface mocked in the Previewer. How this interface works" +
116          " on the Previewer may be different from that on a real device.")
117        return QueryClass;
118      };
119
120      this.notInString = function (...args) {
121        console.warn("Query.notInString interface mocked in the Previewer. How this interface works" +
122          " on the Previewer may be different from that on a real device.")
123        return QueryClass;
124      };
125
126      this.like = function (...args) {
127        console.warn("Query.like interface mocked in the Previewer. How this interface works" +
128          " on the Previewer may be different from that on a real device.")
129        return QueryClass;
130      };
131
132      this.unlike = function (...args) {
133        console.warn("Query.unlike interface mocked in the Previewer. How this interface works" +
134          " on the Previewer may be different from that on a real device.")
135        return QueryClass;
136      };
137
138      this.and = function (...args) {
139        console.warn("Query.and interface mocked in the Previewer. How this interface works" +
140          " on the Previewer may be different from that on a real device.")
141        return QueryClass;
142      };
143
144      this.or = function (...args) {
145        console.warn("Query.or interface mocked in the Previewer. How this interface works" +
146          " on the Previewer may be different from that on a real device.")
147        return QueryClass;
148      };
149
150      this.orderByAsc = function (...args) {
151        console.warn("Query.orderByAsc interface mocked in the Previewer. How this interface works" +
152          " on the Previewer may be different from that on a real device.")
153        return QueryClass;
154      };
155
156      this.orderByDesc = function (...args) {
157        console.warn("Query.orderByDesc interface mocked in the Previewer. How this interface works" +
158          " on the Previewer may be different from that on a real device.")
159        return QueryClass;
160      };
161
162      this.limit = function (...args) {
163        console.warn("Query.limit interface mocked in the Previewer. How this interface works" +
164          " on the Previewer may be different from that on a real device.")
165        return QueryClass;
166      };
167
168      this.isNotNull = function (...args) {
169        console.warn("Query.isNotNull interface mocked in the Previewer. How this interface works" +
170          " on the Previewer may be different from that on a real device.")
171        return QueryClass;
172      };
173
174      this.beginGroup = function (...args) {
175        console.warn("Query.beginGroup interface mocked in the Previewer. How this interface works" +
176          " on the Previewer may be different from that on a real device.")
177        return QueryClass;
178      };
179
180      this.endGroup = function (...args) {
181        console.warn("Query.endGroup interface mocked in the Previewer. How this interface works" +
182          " on the Previewer may be different from that on a real device.")
183        return QueryClass;
184      };
185
186      this.prefixKey = function (...args) {
187        console.warn("Query.prefixKey interface mocked in the Previewer. How this interface works" +
188          " on the Previewer may be different from that on a real device.")
189        return QueryClass;
190      };
191
192      this.setSuggestIndex = function (...args) {
193        console.warn("Query.setSuggestIndex interface mocked in the Previewer. How this interface works" +
194          " on the Previewer may be different from that on a real device.")
195        return QueryClass;
196      };
197
198      this.deviceId = function (...args) {
199        console.warn("Query.deviceId interface mocked in the Previewer. How this interface works" +
200          " on the Previewer may be different from that on a real device.")
201        return QueryClass;
202      };
203
204      this.getSqlLike = function (...args) {
205        console.warn("Query.getSqlLike interface mocked in the Previewer. How this interface works" +
206          " on the Previewer may be different from that on a real device.")
207        return QueryClass;
208      };
209    }
210  };
211
212  const distributedDataMock = {
213    Schema: SchemaClass,
214    Query: QueryClass,
215    FieldNode: FieldNodeClass,
216
217    KVStoreType: {
218      DEVICE_COLLABORATION: 0,
219      SINGLE_VERSION: 1,
220      MULTI_VERSION: 2,
221    },
222
223    SecurityLevel: {
224      NO_LEVEL: 0,
225      S0: 1,
226      S1: 2,
227      S2: 3,
228      S3: 5,
229      S4: 6,
230    },
231
232    SyncMode: {
233      PULL_ONLY: 0,
234      PUSH_ONLY: 1,
235      PUSH_PULL: 2,
236    },
237
238    SubscribeType: {
239      SUBSCRIBE_TYPE_LOCAL: 0,
240      SUBSCRIBE_TYPE_REMOTE: 1,
241      SUBSCRIBE_TYPE_ALL: 2,
242    },
243
244    createKVManager: function (...args) {
245      console.warn("distributedData.createKVManager interface mocked in the Previewer." +
246        " How this interface works on the Previewer may be different from that on a real device.")
247      const len = args.length
248      if (len > 0 && typeof args[len - 1] === 'function') {
249        args[len - 1].call(this, paramMock.businessErrorMock, KVManager);
250      } else {
251        return new Promise((resolve, reject) => {
252          resolve(KVManager);
253        })
254      }
255    }
256  };
257
258  const userTypeMock = {
259    SAME_USER_ID: "[PC Preview] unknown SAME_USER_ID"
260  };
261  const userInfoMock = {
262    userId: "[PC Preview] unknown userId",
263    userType: "[PC Preview] unknown userType"
264  };
265  const kvManagerConfigMock = {
266    userInfo: "[PC Preview] unknown userInfo",
267    bundleName: "[PC Preview] unknown bundleName",
268    context : "[PC Preview] unknown context"
269  };
270  const constantsMock = {
271    MAX_KEY_LENGTH: "[PC Preview] unknown MAX_KEY_LENGTH",
272    MAX_VALUE_LENGTH: "[PC Preview] unknown MAX_VALUE_LENGTH",
273    MAX_KEY_LENGTH_DEVICE: "[PC Preview] unknown MAX_KEY_LENGTH_DEVICE",
274    MAX_STORE_ID_LENGTH: "[PC Preview] unknown MAX_STORE_ID_LENGTH",
275    MAX_QUERY_LENGTH: "[PC Preview] unknown MAX_QUERY_LENGTH",
276    MAX_BATCH_SIZE: "[PC Preview] unknown MAX_BATCH_SIZE"
277  };
278  const schemaMock = {
279    root: "[PC Preview] unknown root",
280    indexes: "[PC Preview] unknown indexes",
281    mode: "[PC Preview] unknown mode",
282    skip: "[PC Preview] unknown skip"
283  };
284  const fieldnodeMock = {
285    default: "[PC Preview] unknown default",
286    nullable: "[PC Preview] unknown nullable",
287    type: "[PC Preview] unknown type"
288  };
289  const valueTypeMock = {
290    STRING: "[PC Preview] unknown STRING",
291    INTEGER: "[PC Preview] unknown INTEGER",
292    FLOAT: "[PC Preview] unknown FLOAT",
293    BYTE_ARRAY: "[PC Preview] unknown BYTE_ARRAY",
294    BOOLEAN: "[PC Preview] unknown BOOLEAN",
295    DOUBLE: "[PC Preview] unknown DOUBLE"
296  };
297  const valueMock = {
298    type: valueTypeMock.STRING,
299    value: "[PC Preview] unknown value"
300  };
301  const entryMock = {
302    key: "[PC Preview] unknown key",
303    value: valueMock
304  };
305  const changeNotificationMock = {
306    insertEntries: new Array(entryMock),
307    updateEntries: new Array(entryMock),
308    deleteEntries: new Array(entryMock),
309    deviceId: "[PC Preview] unknown deviceId"
310  };
311  const optionsMock = {
312    createIfMissing: "[PC Preview] unknown createIfMissing",
313    encrypt: "[PC Preview] unknown encrypt",
314    backup: "[PC Preview] unknown backup",
315    autoSync: "[PC Preview] unknown autoSync",
316    kvStoreType: "[PC Preview] unknown kvStoreType",
317    securityLevel: "[PC Preview] unknown securityLevel",
318    schema: "[PC Preview] unknown schema"
319  };
320
321  const KVStoreClass = class KVStore {
322    constructor() {
323      console.warn("KVStore.constructor interface mocked in the Previewer." +
324        " How this interface works on the Previewer may be different from that on a real device.")
325      this.put = function (...args) {
326        console.warn("KVStore.put interface mocked in the Previewer. How this interface works" +
327          " on the Previewer may be different from that on a real device.")
328        const len = args.length
329        if (typeof args[len - 1] === 'function') {
330          args[len - 1].call(this, paramMock.businessErrorMock);
331        } else {
332          return new Promise((resolve) => {
333            resolve()
334          })
335        }
336      };
337
338      this.delete = function (...args) {
339        console.warn("KVStore.delete interface mocked in the Previewer. How this interface works" +
340          " on the Previewer may be different from that on a real device.")
341        const len = args.length
342        if (typeof args[len - 1] === 'function') {
343          args[len - 1].call(this, paramMock.businessErrorMock)
344        } else {
345          return new Promise((resolve) => {
346            resolve()
347          })
348        }
349      };
350
351      this.setSyncRange = function (...args) {
352        console.warn("KVStore.setSyncRange interface mocked in the Previewer. How this interface works" +
353          " on the Previewer may be different from that on a real device.")
354        const len = args.length
355        if (typeof args[len - 1] === 'function') {
356          args[len - 1].call(this, paramMock.businessErrorMock)
357        } else {
358          return new Promise((resolve) => {
359            resolve()
360          })
361        }
362      };
363
364      this.on = function (...args) {
365        console.warn("KVStore.on interface mocked in the Previewer. How this interface works" +
366          " on the Previewer may be different from that on a real device.")
367        const len = args.length
368        if (typeof args[len - 1] === 'function') {
369          if (args[0] == 'dataChange') {
370            args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock)
371          } else if (args[0] === 'syncComplete') {
372            var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]);
373            args[len - 1].call(this, array);
374          }
375        }
376      };
377
378      this.off = function (...args) {
379        console.warn("KVStore.off interface mocked in the Previewer. How this interface works" +
380          " on the Previewer may be different from that on a real device.")
381        const len = args.length
382        if (typeof args[len - 1] === 'function') {
383          if (args[0] == 'dataChange') {
384            args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock)
385          } else if (args[0] === 'syncComplete') {
386            var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]);
387            args[len - 1].call(this, array);
388          }
389        }
390      };
391
392      this.putBatch = function (...args) {
393        console.warn("KVStore.putBatch interface mocked in the Previewer. How this interface works" +
394          " on the Previewer may be different from that on a real device.")
395        const len = args.length
396        if (typeof args[len - 1] === 'function') {
397          args[len - 1].call(this, paramMock.businessErrorMock)
398        } else {
399          return new Promise((resolve) => {
400            resolve()
401          })
402        }
403      };
404
405      this.deleteBatch = function (...args) {
406        console.warn("KVStore.deleteBatch interface mocked in the Previewer. How this interface works" +
407          " on the Previewer may be different from that on a real device.")
408        const len = args.length
409        if (typeof args[len - 1] === 'function') {
410          args[len - 1].call(this, paramMock.businessErrorMock)
411        } else {
412          return new Promise((resolve) => {
413            resolve()
414          })
415        }
416      };
417
418      this.startTransaction = function (...args) {
419        console.warn("KVStore.startTransaction interface mocked in the Previewer. How this interface works" +
420          " on the Previewer may be different from that on a real device.")
421        const len = args.length
422        if (typeof args[len - 1] === 'function') {
423          args[len - 1].call(this, paramMock.businessErrorMock)
424        } else {
425          return new Promise((resolve) => {
426            resolve()
427          })
428        }
429      };
430
431      this.commit = function (...args) {
432        console.warn("KVStore.commit interface mocked in the Previewer. How this interface works" +
433          " on the Previewer may be different from that on a real device.")
434        const len = args.length
435        if (typeof args[len - 1] === 'function') {
436          args[len - 1].call(this, paramMock.businessErrorMock)
437        } else {
438          return new Promise((resolve) => {
439            resolve()
440          })
441        }
442      };
443
444      this.rollback = function (...args) {
445        console.warn("KVStore.rollback interface mocked in the Previewer. How this interface works" +
446          " on the Previewer may be different from that on a real device.")
447        const len = args.length
448        if (typeof args[len - 1] === 'function') {
449          args[len - 1].call(this, paramMock.businessErrorMock)
450        } else {
451          return new Promise((resolve) => {
452            resolve()
453          })
454        }
455      };
456
457      this.enableSync = function (...args) {
458        console.warn("KVStore.enableSync interface mocked in the Previewer. How this interface works" +
459          " on the Previewer may be different from that on a real device.")
460        const len = args.length
461        if (typeof args[len - 1] === 'function') {
462          args[len - 1].call(this, paramMock.businessErrorMock)
463        } else {
464          return new Promise((resolve) => {
465            resolve()
466          })
467        }
468      };
469
470      this.backup = function (...args) {
471        console.warn("KVStore.backup interface mocked in the Previewer. How this interface works" +
472          " on the Previewer may be different from that on a real device.")
473        const len = args.length
474        if (typeof args[len - 1] === 'function') {
475          args[len - 1].call(this, paramMock.businessErrorMock)
476        } else {
477          return new Promise((resolve) => {
478            resolve()
479          })
480        }
481      };
482
483	    this.restore = function (...args) {
484        console.warn("KVStore.restore interface mocked in the Previewer. How this interface works" +
485          " on the Previewer may be different from that on a real device.")
486        const len = args.length
487        if (typeof args[len - 1] === 'function') {
488          args[len - 1].call(this, paramMock.businessErrorMock)
489        } else {
490          return new Promise((resolve) => {
491            resolve()
492          })
493        }
494      };
495
496      this.deleteBackup = function (...args) {
497        console.warn("KVStore.deleteBackup interface mocked in the Previewer. How this interface works" +
498          " on the Previewer may be different from that on a real device.")
499        const len = args.length
500        if (typeof args[len - 1] === 'function') {
501          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock)
502        } else {
503          return new Promise((resolve) => {
504            resolve(paramMock.paramArrayMock)
505          })
506        }
507      };
508    }
509  };
510
511  const SingleKVStoreClass = class SingleKVStore extends KVStoreClass {
512    constructor() {
513      super();
514      console.warn("SingleKVStore.constructor interface mocked in the Previewer." +
515        " How this interface works on the Previewer may be different from that on a real device.")
516
517      this.put = function (...args) {
518        console.warn("SingleKVStore.put interface mocked in the Previewer." +
519          " How this interface works on the Previewer may be different from that on a real device.")
520        const len = args.length
521        if (len > 0 && typeof args[len - 1] === 'function') {
522          args[len - 1].call(this, paramMock.businessErrorMock);
523        } else {
524          return new Promise((resolve, reject) => {
525            resolve();
526          })
527        }
528      };
529
530      this.delete = function (...args) {
531        console.warn("SingleKVStore.delete interface mocked in the Previewer." +
532          " How this interface works on the Previewer may be different from that on a real device.")
533        const len = args.length
534        if (len > 0 && typeof args[len - 1] === 'function') {
535          args[len - 1].call(this, paramMock.businessErrorMock);
536        } else {
537          return new Promise((resolve, reject) => {
538            resolve();
539          })
540        }
541      };
542
543      this.on = function (...args) {
544        console.warn("SingleKVStore.on interface mocked in the Previewer." +
545          " How this interface works on the Previewer may be different from that on a real device.")
546        const len = args.length
547        if (typeof args[len - 1] === 'function') {
548          if (args[0] === 'dataChange') {
549            args[len - 1].call(this, changeNotificationMock);
550          } else if (args[0] === 'syncComplete') {
551            var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]);
552            args[len - 1].call(this, array);
553          }
554        }
555      };
556
557      this.off = function (...args) {
558        console.warn("SingleKVStore.off interface mocked in the Previewer. How this interface works" +
559          " on the Previewer may be different from that on a real device.")
560        const len = args.length
561        var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]);
562        if (typeof args[len - 1] === 'function') {
563          if (args[0] == 'syncComplete') {
564            args[len - 1].call(this, paramMock.businessErrorMock, array)
565          } else if (args[0] == 'dataChange') {
566            args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock)
567          }
568        }
569      };
570
571      this.sync = function (...args) {
572        console.warn("SingleKVStore.sync interface mocked in the Previewer." +
573          " How this interface works on the Previewer may be different from that on a real device.")
574      };
575
576      this.get = function (...args) {
577        console.warn("SingleKVStore.get interface mocked in the Previewer. How this interface works" +
578          " on the Previewer may be different from that on a real device.")
579        const len = args.length
580        if (typeof args[len - 1] === 'function') {
581          args[len - 1].call(this, paramMock.businessErrorMock,
582            paramMock.paramBooleanMock | paramMock.paramStringMock | paramMock.paramNumberMock | paramMock.paramArrayMock)
583        } else {
584          return new Promise((resolve) => {
585            resolve(paramMock.paramBooleanMock | paramMock.paramStringMock | paramMock.paramNumberMock | paramMock.paramArrayMock)
586          })
587        }
588      };
589
590      this.getResultSet = function (...args) {
591        console.warn("SingleKVStore.getResultSet interface mocked in the Previewer. How this interface works" +
592          " on the Previewer may be different from that on a real device.")
593        const len = args.length
594        if (typeof args[len - 1] === 'function') {
595          args[len - 1].call(this, paramMock.businessErrorMock, KVStoreResultSet)
596        } else {
597          return new Promise((resolve) => {
598            resolve(KVStoreResultSet)
599          })
600        }
601      };
602
603      this.closeResultSet = function (...args) {
604        console.warn("SingleKVStore.closeResultSet interface mocked in the Previewer. How this interface works" +
605          " on the Previewer may be different from that on a real device.")
606        const len = args.length
607        if (typeof args[len - 1] === 'function') {
608          args[len - 1].call(this, paramMock.businessErrorMock)
609        } else {
610          return new Promise((resolve) => {
611            resolve()
612          })
613        }
614      };
615
616      this.getResultSize = function (...args) {
617        console.warn("SingleKVStore.getResultSize interface mocked in the Previewer. How this interface works" +
618          " on the Previewer may be different from that on a real device.")
619        const len = args.length
620        if (typeof args[len - 1] === 'function') {
621          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
622        } else {
623          return new Promise((resolve) => {
624            resolve(paramMock.paramNumberMock)
625          })
626        }
627      };
628
629      this.getEntries = function (...args) {
630        console.warn("SingleKVStore.getEntries interface mocked in the Previewer. How this interface works" +
631          " on the Previewer may be different from that on a real device.")
632        const len = args.length
633        var array = new Array(entryMock)
634        if (typeof args[len - 1] === 'function') {
635          args[len - 1].call(this, paramMock.businessErrorMock, array)
636        } else {
637          return new Promise((resolve) => {
638            resolve(array)
639          })
640        }
641      };
642
643      this.removeDeviceData = function (...args) {
644        console.warn("SingleKVStore.removeDeviceData interface mocked in the Previewer. How this interface works" +
645          " on the Previewer may be different from that on a real device.")
646        const len = args.length
647        if (typeof args[len - 1] === 'function') {
648          args[len - 1].call(this, paramMock.businessErrorMock)
649        } else {
650          return new Promise((resolve) => {
651            resolve()
652          })
653        }
654      };
655
656      this.setSyncParam = function (...args) {
657        console.warn("SingleKVStore.setSyncParam interface mocked in the Previewer. How this interface works" +
658          " on the Previewer may be different from that on a real device.")
659        const len = args.length
660        if (typeof args[len - 1] === 'function') {
661          args[len - 1].call(this, paramMock.businessErrorMock)
662        } else {
663          return new Promise((resolve) => {
664            resolve()
665          })
666        }
667      };
668
669      this.getSecurityLevel = function (...args) {
670        console.warn("SingleKVStore.getSecurityLevel interface mocked in the Previewer. How this interface works" +
671          " on the Previewer may be different from that on a real device.")
672        const len = args.length
673        if (typeof args[len - 1] === 'function') {
674          args[len - 1].call(this, paramMock.businessErrorMock)
675        } else {
676          return new Promise((resolve) => {
677            resolve()
678          })
679        }
680      };
681    }
682  };
683
684  const DeviceKVStoreClass = class DeviceKVStore extends KVStoreClass {
685    constructor() {
686      super();
687      console.warn('DeviceKVStore.constructor interface mocked in the Previewer. How this interface works on the' +
688        ' Previewer may be different from that on a real device.');
689
690      this.get = function (...args) {
691        console.warn("DeviceKVStore.get interface mocked in the Previewer. How this interface works" +
692          " on the Previewer may be different from that on a real device.")
693        const len = args.length
694        if (typeof args[len - 1] === 'function') {
695          args[len - 1].call(this, paramMock.businessErrorMock,
696            paramMock.paramBooleanMock | paramMock.paramStringMock | paramMock.paramNumberMock | paramMock.paramArrayMock)
697        } else {
698          return new Promise((resolve) => {
699            resolve(paramMock.paramBooleanMock | paramMock.paramStringMock | paramMock.paramNumberMock | paramMock.paramArrayMock)
700          })
701        }
702      };
703
704      this.getEntries = function (...args) {
705        console.warn("DeviceKVStore.getEntries interface mocked in the Previewer. How this interface works" +
706          " on the Previewer may be different from that on a real device.")
707        const len = args.length
708        var array = new Array(entryMock)
709        if (typeof args[len - 1] === 'function') {
710          args[len - 1].call(this, paramMock.businessErrorMock, array)
711        } else {
712          return new Promise((resolve) => {
713            resolve(array)
714          })
715        }
716      };
717
718      this.getResultSet = function (...args) {
719        console.warn("DeviceKVStore.getResultSet interface mocked in the Previewer. How this interface works" +
720          " on the Previewer may be different from that on a real device.")
721        const len = args.length
722        if (typeof args[len - 1] === 'function') {
723          args[len - 1].call(this, paramMock.businessErrorMock, KVStoreResultSet)
724        } else {
725          return new Promise((resolve) => {
726            resolve(KVStoreResultSet)
727          })
728        }
729      };
730
731      this.closeResultSet = function (...args) {
732        console.warn("DeviceKVStore.closeResultSet interface mocked in the Previewer. How this interface works" +
733          " on the Previewer may be different from that on a real device.")
734        const len = args.length
735        if (typeof args[len - 1] === 'function') {
736          args[len - 1].call(this, paramMock.businessErrorMock)
737        } else {
738          return new Promise((resolve) => {
739            resolve()
740          })
741        }
742      };
743
744      this.getResultSize = function (...args) {
745        console.warn("DeviceKVStore.getResultSize interface mocked in the Previewer. How this interface works" +
746          " on the Previewer may be different from that on a real device.")
747        const len = args.length
748        if (typeof args[len - 1] === 'function') {
749          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
750        } else {
751          return new Promise((resolve) => {
752            resolve(paramMock.paramNumberMock)
753          })
754        }
755      };
756
757      this.removeDeviceData = function (...args) {
758        console.warn("DeviceKVStore.removeDeviceData interface mocked in the Previewer. How this interface works" +
759          " on the Previewer may be different from that on a real device.")
760        const len = args.length
761        if (typeof args[len - 1] === 'function') {
762          args[len - 1].call(this, paramMock.businessErrorMock)
763        } else {
764          return new Promise((resolve) => {
765            resolve()
766          })
767        }
768      };
769
770      this.sync = function (...args) {
771        console.warn("DeviceKVStore.sync interface mocked in the Previewer. How this interface works" +
772          " on the Previewer may be different from that on a real device.")
773      };
774
775      this.on = function (...args) {
776        console.warn("DeviceKVStore.on interface mocked in the Previewer. How this interface works" +
777          " on the Previewer may be different from that on a real device.")
778        const len = args.length
779        var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]);
780        if (typeof args[len - 1] === 'function') {
781          if (args[0] == 'syncComplete') {
782            args[len - 1].call(this, paramMock.businessErrorMock, array)
783          } else if (args[0] == 'dataChange') {
784            args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock)
785          }
786        }
787      };
788
789      this.off = function (...args) {
790        console.warn("DeviceKVStore.off interface mocked in the Previewer. How this interface works" +
791          " on the Previewer may be different from that on a real device.")
792        const len = args.length
793        var array = new Array([paramMock.paramStringMock, paramMock.paramNumberMock]);
794        if (typeof args[len - 1] === 'function') {
795          if (args[0] == 'syncComplete') {
796            args[len - 1].call(this, paramMock.businessErrorMock, array)
797          } else if (args[0] == 'dataChange') {
798            args[len - 1].call(this, paramMock.businessErrorMock, changeNotificationMock)
799          }
800        }
801      };
802    }
803  };
804
805  const KVManager = {
806    getKVStore: function (...args) {
807      console.warn("KVManager.getKVStore interface mocked in the Previewer." +
808        " How this interface works on the Previewer may be different from that on a real device.")
809      const len = args.length
810      var singleKVStoreClass = new SingleKVStoreClass
811      var deviceKVStoreClass = new DeviceKVStoreClass
812      if (len > 0 && typeof args[len - 1] === 'function') {
813        console.warn("getKVStore kvStoreType = " + args[1].kvStoreType);
814        if (args[1].kvStoreType == distributedDataMock.KVStoreType.DEVICE_COLLABORATION) {
815          args[len - 1].call(this, paramMock.businessErrorMock, deviceKVStoreClass);
816        } else if (args[1].kvStoreType == distributedDataMock.KVStoreType.SINGLE_VERSION) {
817          args[len - 1].call(this, paramMock.businessErrorMock, singleKVStoreClass);
818        }
819      } else {
820        return new Promise((resolve) => {
821          if (args[1].kvStoreType == distributedDataMock.KVStoreType.DEVICE_COLLABORATION) {
822            resolve(deviceKVStoreClass);
823          } else if (args[1].kvStoreType == distributedDataMock.KVStoreType.SINGLE_VERSION) {
824            resolve(singleKVStoreClass);
825          }
826        })
827      }
828    },
829
830    closeKVStore: function (...args) {
831      console.warn("KVManager.closeKVStore interface mocked in the Previewer. How this interface works" +
832        " on the Previewer may be different from that on a real device.")
833      const len = args.length
834      if (typeof args[len - 1] === 'function') {
835        args[len - 1].call(this, paramMock.businessErrorMock)
836      } else {
837        return new Promise((resolve) => {
838          resolve()
839        })
840      }
841    },
842
843    deleteKVStore: function (...args) {
844      console.warn("KVManager.deleteKVStore interface mocked in the Previewer. How this interface works" +
845        " on the Previewer may be different from that on a real device.")
846      const len = args.length
847      if (typeof args[len - 1] === 'function') {
848        args[len - 1].call(this, paramMock.businessErrorMock)
849      } else {
850        return new Promise((resolve) => {
851          resolve()
852        })
853      }
854    },
855
856    getAllKVStoreId: function (...args) {
857      console.warn("KVManager.getAllKVStoreId interface mocked in the Previewer. How this interface works" +
858        " on the Previewer may be different from that on a real device.")
859      const len = args.length
860      var array = new Array(paramMock.paramStringMock)
861      if (typeof args[len - 1] === 'function') {
862        args[len - 1].call(this, paramMock.businessErrorMock, array)
863      } else {
864        return new Promise((resolve) => {
865          resolve(array)
866        })
867      }
868    },
869
870    on: function (...args) {
871      console.warn("KVManager.on interface mocked in the Previewer. How this interface works" +
872        " on the Previewer may be different from that on a real device.")
873      const len = args.length
874      if (typeof args[len - 1] === 'function') {
875        if (args[0] == 'distributedDataServiceDie') {
876          args[len - 1].call(this, paramMock.businessErrorMock)
877        }
878      }
879    },
880
881    off: function (...args) {
882      console.warn("KVManager.off interface mocked in the Previewer. How this interface works" +
883        " on the Previewer may be different from that on a real device.")
884      const len = args.length
885      if (typeof args[len - 1] === 'function') {
886        if (args[0] == 'distributedDataServiceDie') {
887          args[len - 1].call(this, paramMock.businessErrorMock)
888        }
889      }
890    }
891  };
892
893  const KVStoreResultSet = {
894    getCount: function (...args) {
895      console.warn("KVStoreResultSet.getCount interface mocked in the Previewer. How this interface works" +
896        " on the Previewer may be different from that on a real device.")
897      return paramMock.paramNumberMock;
898    },
899
900    getPosition: function (...args) {
901      console.warn("KVStoreResultSet.getPosition interface mocked in the Previewer. How this interface works" +
902        " on the Previewer may be different from that on a real device.")
903      return paramMock.paramNumberMock;
904    },
905
906    moveToFirst: function (...args) {
907      console.warn("KVStoreResultSet.moveToFirst interface mocked in the Previewer. How this interface works" +
908        " on the Previewer may be different from that on a real device.")
909      return paramMock.paramBooleanMock;
910    },
911
912    moveToLast: function (...args) {
913      console.warn("KVStoreResultSet.moveToLast interface mocked in the Previewer. How this interface works" +
914        " on the Previewer may be different from that on a real device.")
915      return paramMock.paramBooleanMock;
916    },
917
918    moveToNext: function (...args) {
919      console.warn("KVStoreResultSet.moveToNext interface mocked in the Previewer. How this interface works" +
920        " on the Previewer may be different from that on a real device.")
921      return paramMock.paramBooleanMock;
922    },
923
924    moveToPrevious: function (...args) {
925      console.warn("KVStoreResultSet.moveToPrevious interface mocked in the Previewer. How this interface works" +
926        " on the Previewer may be different from that on a real device.")
927      return paramMock.paramBooleanMock;
928    },
929    move: function (...args) {
930      console.warn("KVStoreResultSet.move interface mocked in the Previewer. How this interface works" +
931        " on the Previewer may be different from that on a real device.")
932      return paramMock.paramBooleanMock;
933    },
934
935    moveToPosition: function (...args) {
936      console.warn("KVStoreResultSet.moveToPosition interface mocked in the Previewer. How this interface works" +
937        " on the Previewer may be different from that on a real device.")
938      return paramMock.paramBooleanMock;
939    },
940
941    isFirst: function (...args) {
942      console.warn("KVStoreResultSet.isFirst interface mocked in the Previewer. How this interface works" +
943        " on the Previewer may be different from that on a real device.")
944      return paramMock.paramBooleanMock;
945    },
946
947    isLast: function (...args) {
948      console.warn("KVStoreResultSet.isLast interface mocked in the Previewer. How this interface works" +
949        " on the Previewer may be different from that on a real device.")
950      return paramMock.paramBooleanMock;
951    },
952    isBeforeFirst: function (...args) {
953      console.warn("KVStoreResultSet.isBeforeFirst interface mocked in the Previewer. How this interface works" +
954        " on the Previewer may be different from that on a real device.")
955      return paramMock.paramBooleanMock;
956    },
957
958    isAfterLast: function (...args) {
959      console.warn("KVStoreResultSet.isAfterLast interface mocked in the Previewer. How this interface works" +
960        " on the Previewer may be different from that on a real device.")
961      return paramMock.paramBooleanMock;
962    },
963
964    getEntry: function (...args) {
965      console.warn("KVStoreResultSet.getEntry interface mocked in the Previewer. How this interface works" +
966        " on the Previewer may be different from that on a real device.")
967      return entryMock;
968    }
969  };
970
971  return distributedDataMock;
972}