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 const RdbPredicatesClass = class RdbPredicates { 19 constructor(...args) { 20 console.warn('data.rdb.RdbPredicates.constructor interface mocked in the Previewer. How this interface works on the' + 21 ' Previewer may be different from that on a real device.'); 22 this.equalTo = function (...args) { 23 console.warn("RdbPredicates.equalTo interface mocked in the Previewer. How this interface works on the" + 24 " Previewer may be different from that on a real device.") 25 return new RdbPredicatesClass(); 26 }; 27 this.notEqualTo = function (...args) { 28 console.warn("RdbPredicates.notEqualTo interface mocked in the Previewer. How this interface works on the" + 29 " Previewer may be different from that on a real device.") 30 return new RdbPredicatesClass(); 31 }; 32 this.beginWrap = function (...args) { 33 console.warn("RdbPredicates.beginWrap interface mocked in the Previewer. How this interface works on the" + 34 " Previewer may be different from that on a real device.") 35 return new RdbPredicatesClass(); 36 }; 37 this.endWrap = function (...args) { 38 console.warn("RdbPredicates.endWrap interface mocked in the Previewer. How this interface works on the" + 39 " Previewer may be different from that on a real device.") 40 return new RdbPredicatesClass(); 41 }; 42 this.or = function (...args) { 43 console.warn("RdbPredicates.or interface mocked in the Previewer. How this interface works on the" + 44 " Previewer may be different from that on a real device.") 45 return new RdbPredicatesClass(); 46 }; 47 this.and = function (...args) { 48 console.warn("RdbPredicates.and interface mocked in the Previewer. How this interface works on the" + 49 " Previewer may be different from that on a real device.") 50 return new RdbPredicatesClass(); 51 }; 52 this.contains = function (...args) { 53 console.warn("RdbPredicates.contains interface mocked in the Previewer. How this interface works on the" + 54 " Previewer may be different from that on a real device.") 55 return new RdbPredicatesClass(); 56 }; 57 this.beginsWith = function (...args) { 58 console.warn("RdbPredicates.beginsWith interface mocked in the Previewer. How this interface works on the" + 59 " Previewer may be different from that on a real device.") 60 return new RdbPredicatesClass(); 61 }; 62 this.endsWith = function (...args) { 63 console.warn("RdbPredicates.endsWith interface mocked in the Previewer. How this interface works on the" + 64 " Previewer may be different from that on a real device.") 65 return new RdbPredicatesClass(); 66 }; 67 this.isNull = function (...args) { 68 console.warn("RdbPredicates.isNull interface mocked in the Previewer. How this interface works on the" + 69 " Previewer may be different from that on a real device.") 70 return new RdbPredicatesClass(); 71 }; 72 this.isNotNull = function (...args) { 73 console.warn("RdbPredicates.isNotNull interface mocked in the Previewer. How this interface works on the" + 74 " Previewer may be different from that on a real device.") 75 return new RdbPredicatesClass(); 76 }; 77 this.like = function (...args) { 78 console.warn("RdbPredicates.like interface mocked in the Previewer. How this interface works on the" + 79 " Previewer may be different from that on a real device.") 80 return new RdbPredicatesClass(); 81 }; 82 this.glob = function (...args) { 83 console.warn("RdbPredicates.glob interface mocked in the Previewer. How this interface works on the" + 84 " Previewer may be different from that on a real device.") 85 return new RdbPredicatesClass(); 86 }; 87 this.between = function (...args) { 88 console.warn("RdbPredicates.between interface mocked in the Previewer. How this interface works on the" + 89 " Previewer may be different from that on a real device.") 90 return new RdbPredicatesClass(); 91 }; 92 this.notBetween = function (...args) { 93 console.warn("RdbPredicates.notBetween interface mocked in the Previewer. How this interface works on the" + 94 " Previewer may be different from that on a real device.") 95 return new RdbPredicatesClass(); 96 }; 97 this.greaterThan = function (...args) { 98 console.warn("RdbPredicates.greaterThan interface mocked in the Previewer. How this interface works on the" + 99 " Previewer may be different from that on a real device.") 100 return new RdbPredicatesClass(); 101 }; 102 this.lessThan = function (...args) { 103 console.warn("RdbPredicates.lessThan interface mocked in the Previewer. How this interface works on the" + 104 " Previewer may be different from that on a real device.") 105 return new RdbPredicatesClass(); 106 }; 107 this.greaterThanOrEqualTo = function (...args) { 108 console.warn("RdbPredicates.greaterThanOrEqualTo interface mocked in the Previewer. How this interface works on the" + 109 " Previewer may be different from that on a real device.") 110 return new RdbPredicatesClass(); 111 }; 112 this.lessThanOrEqualTo = function (...args) { 113 console.warn("RdbPredicates.lessThanOrEqualTo interface mocked in the Previewer. How this interface works on the" + 114 " Previewer may be different from that on a real device.") 115 return new RdbPredicatesClass(); 116 }; 117 this.orderByAsc = function (...args) { 118 console.warn("RdbPredicates.orderByAsc interface mocked in the Previewer. How this interface works on the" + 119 " Previewer may be different from that on a real device.") 120 return new RdbPredicatesClass(); 121 }; 122 this.orderByDesc = function (...args) { 123 console.warn("RdbPredicates.orderByDesc interface mocked in the Previewer. How this interface works on the" + 124 " Previewer may be different from that on a real device.") 125 return new RdbPredicatesClass(); 126 }; 127 this.distinct = function (...args) { 128 console.warn("RdbPredicates.distinct interface mocked in the Previewer. How this interface works on the" + 129 " Previewer may be different from that on a real device.") 130 return new RdbPredicatesClass(); 131 }; 132 this.limitAs = function (...args) { 133 console.warn("RdbPredicates.limitAs interface mocked in the Previewer. How this interface works on the" + 134 " Previewer may be different from that on a real device.") 135 return new RdbPredicatesClass(); 136 }; 137 this.offsetAs = function (...args) { 138 console.warn("RdbPredicates.offsetAs interface mocked in the Previewer. How this interface works on the" + 139 " Previewer may be different from that on a real device.") 140 return new RdbPredicatesClass(); 141 }; 142 this.groupBy = function (...args) { 143 console.warn("RdbPredicates.groupBy interface mocked in the Previewer. How this interface works on the" + 144 " Previewer may be different from that on a real device.") 145 return new RdbPredicatesClass(); 146 }; 147 this.indexedBy = function (...args) { 148 console.warn("RdbPredicates.indexedBy interface mocked in the Previewer. How this interface works on the" + 149 " Previewer may be different from that on a real device.") 150 return new RdbPredicatesClass(); 151 }; 152 this.in = function (...args) { 153 console.warn("RdbPredicates.in interface mocked in the Previewer. How this interface works on the" + 154 " Previewer may be different from that on a real device.") 155 return new RdbPredicatesClass(); 156 }; 157 this.notIn = function (...args) { 158 console.warn("RdbPredicates.notIn interface mocked in the Previewer. How this interface works on the" + 159 " Previewer may be different from that on a real device.") 160 return new RdbPredicatesClass(); 161 }; 162 this.inDevices = function (...args) { 163 console.warn("RdbPredicates.inDevices interface mocked in the Previewer. How this interface works on the" + 164 " Previewer may be different from that on a real device.") 165 return new RdbPredicatesClass(); 166 }; 167 this.inAllDevices = function (...args) { 168 console.warn("RdbPredicates.inAllDevices interface mocked in the Previewer. How this interface works on the" + 169 " Previewer may be different from that on a real device.") 170 return new RdbPredicatesClass(); 171 }; 172 } 173}; 174 175export function mockRdb() { 176 const rdbMock = { 177 getRdbStore: function (...args) { 178 console.warn("Rdb.getRdbStore interface mocked in the Previewer. How this interface works on the" + 179 " Previewer may be different from that on a real device.") 180 const len = args.length 181 if (len > 0 && typeof args[len - 1] === 'function') { 182 args[len - 1].call(this, paramMock.businessErrorMock, rdbStore); 183 } else { 184 return new Promise((resolve, reject) => { 185 resolve(rdbStore); 186 }) 187 } 188 }, 189 deleteRdbStore: function (...args) { 190 console.warn("Rdb.deleteRdbStore interface mocked in the Previewer. How this interface works on the" + 191 " Previewer may be different from that on a real device.") 192 const len = args.length 193 if (len > 0 && typeof args[len - 1] === 'function') { 194 args[len - 1].call(this, paramMock.businessErrorMock); 195 } else { 196 return new Promise((resolve, reject) => { 197 resolve(); 198 }) 199 } 200 }, 201 RdbPredicates: RdbPredicatesClass 202 }; 203 const resultSetMock = { 204 columnNames: "[[PC Preview] unknow columnNames]", 205 columnCount: "[PC Preview] unknow columnCount", 206 rowCount: "[PC Preview] unknow rowCount", 207 rowIndex: "[PC Preview] unknow rowIndex", 208 isAtFirstRow: "[PC Preview] unknow isAtFirstRow", 209 isAtLastRow: "[PC Preview] unknow isAtLastRow", 210 isEnded: "[PC Preview] unknow isEnded", 211 isStarted: "[PC Preview] unknow isStarted", 212 isClosed: "[PC Preview] unknow isClosed", 213 getColumnIndex: function (...args) { 214 console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the" + 215 " Previewer may be different from that on a real device.") 216 return paramMock.paramNumberMock; 217 }, 218 getColumnName: function (...args) { 219 console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the" + 220 " Previewer may be different from that on a real device.") 221 return paramMock.paramStringMock; 222 }, 223 goTo: function (...args) { 224 console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the" + 225 " Previewer may be different from that on a real device.") 226 return paramMock.paramBooleanMock; 227 }, 228 goToRow: function (...args) { 229 console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the" + 230 " Previewer may be different from that on a real device.") 231 return paramMock.paramBooleanMock; 232 }, 233 goToFirstRow: function (...args) { 234 console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the" + 235 " Previewer may be different from that on a real device.") 236 return paramMock.paramBooleanMock; 237 }, 238 goToLastRow: function (...args) { 239 console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the" + 240 " Previewer may be different from that on a real device.") 241 return paramMock.paramBooleanMock; 242 }, 243 goToNextRow: function (...args) { 244 console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the" + 245 " Previewer may be different from that on a real device.") 246 return paramMock.paramBooleanMock; 247 }, 248 goToPreviousRow: function (...args) { 249 console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the" + 250 " Previewer may be different from that on a real device.") 251 return paramMock.paramBooleanMock; 252 }, 253 getBlob: function (...args) { 254 console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the" + 255 " Previewer may be different from that on a real device.") 256 return paramMock.paramObjectMock; 257 }, 258 getString: function (...args) { 259 console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the" + 260 " Previewer may be different from that on a real device.") 261 return paramMock.paramStringMock; 262 }, 263 getLong: function (...args) { 264 console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the" + 265 " Previewer may be different from that on a real device.") 266 return paramMock.paramNumberMock; 267 }, 268 getDouble: function (...args) { 269 console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the" + 270 " Previewer may be different from that on a real device.") 271 return paramMock.paramNumberMock; 272 }, 273 isColumnNull: function (...args) { 274 console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the" + 275 " Previewer may be different from that on a real device.") 276 return paramMock.paramBooleanMock; 277 }, 278 close: function (...args) { 279 console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the" + 280 " Previewer may be different from that on a real device.") 281 } 282 } 283 const storeConfig = { 284 name: "[PC Preview] unknown name" 285 } 286 const rdbStore = { 287 insert: function (...args) { 288 console.warn("RdbStore.insert interface mocked in the Previewer. How this interface works on the" + 289 " Previewer may be different from that on a real device.") 290 const len = args.length 291 if (len > 0 && typeof args[len - 1] === 'function') { 292 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 293 } else { 294 return new Promise((resolve, reject) => { 295 resolve(paramMock.paramNumberMock); 296 }) 297 } 298 }, 299 update: function (...args) { 300 console.warn("RdbStore.update interface mocked in the Previewer. How this interface works on the" + 301 " Previewer may be different from that on a real device.") 302 const len = args.length 303 if (len > 0 && typeof args[len - 1] === 'function') { 304 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 305 } else { 306 return new Promise((resolve, reject) => { 307 resolve(paramMock.paramNumberMock); 308 }) 309 } 310 }, 311 delete: function (...args) { 312 console.warn("RdbStore.delete interface mocked in the Previewer. How this interface works on the" + 313 " Previewer may be different from that on a real device.") 314 const len = args.length 315 if (len > 0 && typeof args[len - 1] === 'function') { 316 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 317 } else { 318 return new Promise((resolve, reject) => { 319 resolve(paramMock.paramNumberMock); 320 }) 321 } 322 }, 323 query: function (...args) { 324 console.warn("RdbStore.query interface mocked in the Previewer. How this interface works on the" + 325 " Previewer may be different from that on a real device.") 326 const len = args.length 327 if (len > 0 && typeof args[len - 1] === 'function') { 328 args[len - 1].call(this, paramMock.businessErrorMock, resultSetMock); 329 } else { 330 return new Promise((resolve, reject) => { 331 resolve(resultSetMock); 332 }) 333 } 334 }, 335 querySql: function (...args) { 336 console.warn("RdbStore.querySql interface mocked in the Previewer. How this interface works on the" + 337 " Previewer may be different from that on a real device.") 338 const len = args.length 339 if (len > 0 && typeof args[len - 1] === 'function') { 340 args[len - 1].call(this, paramMock.businessErrorMock, resultSetMock); 341 } else { 342 return new Promise((resolve, reject) => { 343 resolve(resultSetMock); 344 }) 345 } 346 }, 347 executeSql: function (...args) { 348 console.warn("RdbStore.executeSql interface mocked in the Previewer. How this interface works on the" + 349 " Previewer may be different from that on a real device.") 350 const len = args.length 351 if (len > 0 && typeof args[len - 1] === 'function') { 352 args[len - 1].call(this, paramMock.businessErrorMock); 353 } else { 354 return new Promise((resolve, reject) => { 355 resolve(); 356 }) 357 } 358 }, 359 setDistributedTables: function (...args) { 360 console.warn("RdbStore.setDistributedTables interface mocked in the Previewer. How this interface works on the" + 361 " Previewer may be different from that on a real device.") 362 const len = args.length 363 if (len > 0 && typeof args[len - 1] === 'function') { 364 args[len - 1].call(this, paramMock.businessErrorMock); 365 } else { 366 return new Promise((resolve, reject) => { 367 resolve(); 368 }) 369 } 370 }, 371 obtainDistributedTableName: function (...args) { 372 console.warn("RdbStore.obtainDistributedTableName interface mocked in the Previewer. How this interface works on the" + 373 " Previewer may be different from that on a real device.") 374 const len = args.length 375 if (len > 0 && typeof args[len - 1] === 'function') { 376 args[len - 1].call(this, paramMock.businessErrorMock); 377 } else { 378 return new Promise((resolve, reject) => { 379 resolve(); 380 }) 381 } 382 }, 383 sync: function (...args) { 384 console.warn("RdbStore.sync interface mocked in the Previewer. How this interface works on the" + 385 " Previewer may be different from that on a real device.") 386 const len = args.length 387 if (len > 0 && typeof args[len - 1] === 'function') { 388 args[len - 1].call(this, paramMock.businessErrorMock); 389 } else { 390 return new Promise((resolve, reject) => { 391 resolve(); 392 }) 393 } 394 }, 395 on: function (...args) { 396 console.warn("RdbStore.on interface mocked in the Previewer. How this interface works on the" + 397 " Previewer may be different from that on a real device.") 398 }, 399 off: function (...args) { 400 console.warn("RdbStore.off interface mocked in the Previewer. How this interface works on the" + 401 " Previewer may be different from that on a real device.") 402 }, 403 }; 404 405 return rdbMock; 406} 407