未验证 提交 f24488d1 编写于 作者: O openharmony_ci 提交者: Gitee

!1515 js api8 testcase update.

Merge pull request !1515 from xsterling/master
......@@ -32,6 +32,9 @@ const TEST_STORE_ID = 'storeId';
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));
......@@ -137,6 +140,7 @@ describe('DeviceKvStoreCallbackTest', function () {
done();
});
});
kvStore = null;
})
/**
......@@ -851,22 +855,25 @@ describe('DeviceKvStoreCallbackTest', function () {
console.log('testDeviceKvStoreOnSyncComplete101 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete101 put success');
expect(err == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
try {
kvStore.sync(devices, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
done();
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete101 put failed:' + e);
expect(null).assertFail();
});
try {
var mode = factory.SyncMode.PULL_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 no peer device :e:' + e);
done();
expect(null).assertFail();
}
done();
})
/**
......@@ -880,22 +887,25 @@ describe('DeviceKvStoreCallbackTest', function () {
console.log('testDeviceKvStoreOnSyncComplete102 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete102 put success');
expect(err == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
try {
kvStore.sync(devices, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
done();
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete102 put failed:' + e);
expect(null).assertFail();
});
try {
var mode = factory.SyncMode.PUSH_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete102 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete102 no peer device :e:' + e);
done();
expect(null).assertFail();
}
done();
})
/**
......@@ -909,22 +919,25 @@ describe('DeviceKvStoreCallbackTest', function () {
console.log('testDeviceKvStoreOnSyncComplete103 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete103 put success');
expect(err == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
try {
kvStore.sync(devices, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
done();
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete103 put failed:' + e);
expect(null).assertFail();
});
try {
var mode = factory.SyncMode.PUSH_PULL;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete103 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete103 no peer device :e:' + e);
done();
expect(null).assertFail();
}
done();
})
/**
......
......@@ -32,6 +32,9 @@ const TEST_STORE_ID = 'storeId';
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));
......@@ -137,13 +140,13 @@ describe('DeviceKvStorePromiseTest', function () {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -860,14 +863,19 @@ describe('DeviceKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete001 put success');
expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode);
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete001 no peer device :e:' + error);
console.log('testDeviceKvStoreOnSyncComplete001 put failed:' + e);
expect(null).assertFail();
});
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete001 put e ' + e);
try {
var mode = factory.SyncMode.PULL_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch (e) {
console.log('testDeviceKvStoreOnSyncComplete001 sync no peer device :e:' + e);
}
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete001 e ' + e);
expect(null).assertFail();
}
done();
......@@ -887,13 +895,18 @@ describe('DeviceKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete002 put success');
expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode);
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete002 no peer device :e:' + error);
console.log('testDeviceKvStoreOnSyncComplete002 put failed:' + e);
expect(null).assertFail();
});
}catch(e) {
try {
var mode = factory.SyncMode.PUSH_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(error) {
console.log('testDeviceKvStoreOnSyncComplete002 no peer device :e:' + error);
}
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete002 put e ' + e);
expect(null).assertFail();
}
......@@ -914,13 +927,18 @@ describe('DeviceKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete003 put success');
expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode);
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete003 no peer device :e:' + error);
console.log('testDeviceKvStoreOnSyncComplete003 put failed:' + e);
expect(null).assertFail();
});
}catch(e) {
try {
var mode = factory.SyncMode.PUSH_PULL;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(error) {
console.log('testDeviceKvStoreOnSyncComplete003 no peer device :e:' + error);
}
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete003 put e ' + e);
expect(null).assertFail();
}
......
......@@ -15,9 +15,6 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import ddm from '@ohos.data.distributedData';
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
describe('FieldNodeTest', function() {
/**
......
......@@ -67,6 +67,7 @@ describe('KVManagerCallbackTest', function () {
done();
});
});
kvStore = null;
})
/**
......@@ -725,16 +726,23 @@ describe('KVManagerCallbackTest', function () {
it('testKVManagerCloseKVStore104', 0, async function (done) {
console.log('testKVManagerCloseKVStore104');
try {
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVManagerCloseKVStore104 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
});
console.log('testKVManagerCloseKVStore104 closeKVStore redo.');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, function (err, data) {
console.log('testKVManagerCloseKVStore104 closeKVStore success');
expect((err == undefined) && (data == undefined)).assertTrue();
done();
console.log('testKVManagerCloseKVStore104 closeKVStore twice ' + err);
if (err == undefined) {
expect(null).assertFail();
}
});
} catch (e) {
console.log('testKVManagerCloseKVStore104 e ' + e);
console.log('testKVManagerCloseKVStore104 closeKVStore twice e ' + e);
expect(null).assertFail();
done();
}
done();
})
/**
......
......@@ -73,6 +73,7 @@ describe('KVManagerPromiseTest', function () {
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -659,11 +660,17 @@ describe('KVManagerPromiseTest', function () {
*/
it('testKVManagerCloseKVStore004', 0, async function (done) {
console.log('testKVManagerCloseKVStore004');
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVManagerCloseKVStore004 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
});
console.log('testKVManagerCloseKVStore104 closeKVStore redo.');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => {
console.log('testKVManagerCloseKVStore004 closeKVStore success');
}).catch((err) => {
console.log('testKVManagerCloseKVStore004 closeKVStore err ' + err);
console.log('testKVManagerCloseKVStore004 closeKVStore twice');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore004 closeKVStore twice err ' + err);
});
done();
})
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import factory from '@ohos.data.distributedData'
import factory from '@ohos.data.distributedData';
const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const TEST_STORE_ID = 'storeId';
......@@ -120,13 +120,14 @@ describe('KvStoreResultSetTest', function() {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
resultSet = null;
done();
})
......@@ -581,12 +582,12 @@ describe('KvStoreResultSetTest', function() {
expect(moved && (resultSet.getPosition() == 0)).assertTrue();
moved = resultSet.moveToPrevious();
console.log("testKvStoreResultSetMoveToPrevious005 from 0 to -1 return" + moved);
expect(moved).assertFalse();
expect(moved == false).assertTrue();
console.log("testKvStoreResultSetMoveToPrevious005 from 0 to " + resultSet.getPosition());
expect(-1).assertEqual(resultSet.getPosition());
} catch (e) {
console.log("testKvStoreResultSetMoveToPrevious005 fail " + e);
expect(null).assertTrue();
expect(null).assertFail();
}
done();
})
......@@ -965,7 +966,7 @@ describe('KvStoreResultSetTest', function() {
expect(moved).assertTrue();
moved = resultSet.moveToNext();
console.log("testKvStoreResultSetIsAfterLast002 moveToNext moved=" + moved);
expect(moved).assertFalse();
expect(moved == false).assertTrue();
var flag = resultSet.isAfterLast();
console.log("testKvStoreResultSetIsAfterLast002 isAfterLast true=" + flag);
expect(flag).assertTrue();
......
......@@ -14,6 +14,7 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import ddm from '@ohos.data.distributedData';
describe('QueryTest', function() {
/**
......@@ -22,8 +23,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Reset() testcase 001
*/
it('testReset001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("test", 3);
console.log("query is " + query.getSqlLike());
......@@ -31,11 +33,11 @@ describe('QueryTest', function() {
query.reset();
expect("").assertEqual(query.getSqlLike());
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("simply calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -45,8 +47,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Reset() testcase 002
*/
it('testReset002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("number", 5);
query.equalTo("string", 'v');
......@@ -59,11 +62,11 @@ describe('QueryTest', function() {
expect("").assertEqual(query.getSqlLike());
console.log("sql after reset: " + query.getSqlLike());
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -73,8 +76,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Reset() testcase 003
*/
it('testReset003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key", "value");
expect(query.getSqlLike() !== "").assertTrue();
......@@ -82,11 +86,11 @@ describe('QueryTest', function() {
query.reset().equalTo("key", "value");
console.log("query is " + query.getSqlLike());
expect(sql === query.getSqlLike()).assertTrue();
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -96,8 +100,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Reset() testcase 004
*/
it('testReset004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key", "value");
expect(query.getSqlLike() !== "").assertTrue();
......@@ -107,6 +112,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -116,8 +122,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EqaulTo() testcase 001
*/
it('testEqaulTo001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key1", 5);
query.equalTo("key2", 5.0);
......@@ -125,11 +132,11 @@ describe('QueryTest', function() {
query.equalTo("key3", "string");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -139,17 +146,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EqualTo() testcase 002
*/
it('testEqualTo002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key1", 1).equalTo("key2", 2).equalTo("key3", 3);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -159,8 +167,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EqualTo() testcase 003
*/
it('testEqualTo003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key2", NaN);
expect(query.getSqlLike() !== "").assertTrue();
......@@ -168,6 +177,7 @@ describe('QueryTest', function() {
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -177,17 +187,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EqualTo() testcase 004
*/
it('testEqualTo004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key1", "value", "too more");
console.log("should throw exception on invalid arguments");
console.log("query is " + query.getSqlLike());
query = null;
expect(null).assertFail();
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -197,8 +208,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotEqualTo() testcase 001
*/
it('testNotEqualTo001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key1", 5);
query.notEqualTo("key2", 5.0);
......@@ -206,11 +218,11 @@ describe('QueryTest', function() {
query.notEqualTo("key4", "string");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -220,19 +232,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotEqualTo() testcase 002
*/
it('testNotEqualTo002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -242,16 +255,17 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotEqualTo() testcase 003
*/
it('testNotEqualTo003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key2", NaN);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -261,14 +275,16 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotEqualTo() testcase 004
*/
it('testNotEqualTo004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key1", "value", "too more", 4);
console.log("should throw exception on invalid arguments");
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -278,8 +294,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreaterThan() testcase 001
*/
it('testGreaterThan001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThan("key1", 5);
query.greaterThan("key2", 5.0);
......@@ -287,11 +304,11 @@ describe('QueryTest', function() {
query.greaterThan("key4", "string");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -301,19 +318,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreatThan() testcase 002
*/
it('testGreatThan002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -323,8 +341,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreatThan() testcase 003
*/
it('testGreatThan003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThan("key2", NaN);
console.log("should throw exception on invalid arguments");
......@@ -332,6 +351,7 @@ describe('QueryTest', function() {
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -341,8 +361,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreatThan() testcase 004
*/
it('testGreatThan004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThan("key1", "value", "too more", 4);
console.log("should throw exception on invalid arguments");
......@@ -350,6 +371,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -359,8 +381,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThan() testcase 001
*/
it('testLessThan001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.lessThan("key1", 5);
query.lessThan("key2", 5.0);
......@@ -368,10 +391,10 @@ describe('QueryTest', function() {
query.lessThan("key4", "string");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
}
query = null;
done();
})
......@@ -381,19 +404,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThan() testcase 002
*/
it('testLessThan002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertTrue();
}
query = null;
done();
})
......@@ -403,14 +427,16 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThan() testcase 003
*/
it('testLessThan003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.lessThan("key2", NaN);
console.log("query is " + query.getSqlLike());
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -420,8 +446,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThan() testcase 004
*/
it('testLessThan004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.lessThan("key1", "value", "too more", 4);
console.log("query is " + query.getSqlLike());
......@@ -429,6 +456,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -438,8 +466,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreaterThanOrEqualTo() testcase 001
*/
it('testGreaterThanOrEqualTo001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThanOrEqualTo("key1", 5);
query.greaterThanOrEqualTo("key2", 5.0);
......@@ -447,11 +476,11 @@ describe('QueryTest', function() {
query.greaterThanOrEqualTo("key4", "string");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -461,8 +490,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreaterThanOrEqualTo() testcase 002
*/
it('testGreaterThanOrEqualTo002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThanOrEqualTo("key", 5);
query.reset();
......@@ -471,11 +501,11 @@ describe('QueryTest', function() {
.greaterThanOrEqualTo("key3", false);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -485,8 +515,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreaterThanOrEqualTo() testcase 003
*/
it('testGreaterThanOrEqualTo003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThanOrEqualTo("key2", NaN);
expect(query.getSqlLike() !== "").assertTrue();
......@@ -494,6 +525,7 @@ describe('QueryTest', function() {
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -503,8 +535,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GreaterThanOrEqualTo() testcase 004
*/
it('testGreaterThanOrEqualTo004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.greaterThanOrEqualTo("key1", "value", "too more", 4);
console.log("should throw exception on invalid arguments");
......@@ -512,6 +545,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -521,8 +555,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThanOrEqualTo() testcase 001
*/
it('testLessThanOrEqualTo001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.lessThanOrEqualTo("key1", 5);
query.lessThanOrEqualTo("key2", 5.0);
......@@ -530,11 +565,11 @@ describe('QueryTest', function() {
query.lessThanOrEqualTo("key4", "string");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -544,19 +579,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThanOrEqualTo() testcase 002
*/
it('testLessThanOrEqualTo002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -566,14 +602,16 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThanOrEqualTo() testcase 003
*/
it('testLessThanOrEqualTo003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.lessThanOrEqualTo("key2", NaN);
console.log("query is " + query.getSqlLike());
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -583,8 +621,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.LessThanOrEqualTo() testcase 004
*/
it('testLessThanOrEqualTo004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.lessThanOrEqualTo("key1", "value", "too more", 4);
console.log("should throw exception on invalid arguments");
......@@ -592,6 +631,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -601,18 +641,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNull() testcase 001
*/
it('testIsNull001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNull("key");
query.isNull("key2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -622,17 +663,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNull() testcase 002
*/
it('testIsNull002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNull("key").notEqualTo("key1", 4).isNull("key2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -642,15 +684,17 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNull() testcase 003
*/
it('testIsNull003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNUll("key", 0);
query.isNull("key", 0);
console.log("should throw exception on invalid arguments");
expect(null).assertFail();
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -660,15 +704,17 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNull() testcase 004
*/
it('testIsNull004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNUll(0);
query.isNull(0);
console.log("should throw exception on invalid arguments");
expect(null).assertFail();
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -695,8 +741,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InNumber() testcase 001
*/
it('testInNumber001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
console.log("testInNumber001 start ");
var i8 = new Int8Array([-21,31]);
......@@ -730,11 +777,11 @@ describe('QueryTest', function() {
query.reset().inNumber("key", f64);
console.log("inNumber(Float64Array([-21,31]) => " + query.getSqlLike());
query.reset();
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -744,8 +791,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InNumber() testcase 002
*/
it('testInNumber002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inNumber("key", [1, 2.3, 987654]).
inNumber("key2", [0x10abcdef]).
......@@ -753,11 +801,11 @@ describe('QueryTest', function() {
inNumber("key2", [0b10101]);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -767,8 +815,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InNumber() testcase 003
*/
it('testInNumber003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inNumber("key", 0);
console.log("should throw exception on invalid arguments");
......@@ -776,6 +825,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -785,8 +835,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InNumber() testcase 004
*/
it('testInNumber004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inNumber([0, 1]);
console.log("should throw exception on invalid arguments");
......@@ -794,6 +845,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -803,8 +855,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InNumber() testcase 005
*/
it('testInNumber005', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
var u64 = new BigUint64Array([21, 31]);
query.inNumber("key", u64);
......@@ -815,6 +868,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -824,8 +878,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InNumber() testcase 006
*/
it('testInNumber006', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
console.log("typeof([1, 2, 97])" + typeof([1, 2, 97]))
console.log("typeof([1, 2, 97][0])" + typeof([1, 2, 97][0]))
query.inNumber("key", [1, 2, 97]);
......@@ -845,11 +900,11 @@ describe('QueryTest', function() {
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query.reset();
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -859,18 +914,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InString() testcase 001
*/
it('testInString001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inString("key", ["a2z" , 'z2a']);
query.inString("key2", ["AAA" ]);
console.log("query is " + query.getSqlLike());
expect(query.getSqlLike() !== "").assertTrue();
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -880,19 +936,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InString() testcase 002
*/
it('testInString002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -902,8 +959,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InString() testcase 003
*/
it('testInString003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inString("key", 0);
console.log("should throw exception on invalid arguments");
......@@ -911,6 +969,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -920,8 +979,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.InString() testcase 004
*/
it('testInString004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inString("key", [0, 1]);
console.log("should throw exception on invalid arguments");
......@@ -929,6 +989,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -938,18 +999,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInNumber() testcase 001
*/
it('testNotInNumber001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInNumber("key", [1, 2]);
query.notInNumber("key", [1000]);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -959,17 +1021,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInNumber() testcase 002
*/
it('testNotInNumber002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -979,8 +1042,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInNumber() testcase 003
*/
it('testNotInNumber003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInNumber("key", [1], 2);
console.log("should throw exception on invalid arguments");
......@@ -988,6 +1052,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -997,8 +1062,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInNumber() testcase 004
*/
it('testNotInNumber004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInNumber("key", ["string"]);
expect(query.getSqlLike() !== "").assertTrue();
......@@ -1007,6 +1073,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1016,18 +1083,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInString() testcase 001
*/
it('testNotInString001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInString("key", ["v1", "v2"]);
query.notInString("key", ["v1", "NaN"]);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1037,17 +1105,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInString() testcase 002
*/
it('testNotInString002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInString("key", ["v1", "v2", "v3"]).notEqualTo("kkk", "v3");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1057,8 +1126,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInString() testcase 003
*/
it('testNotInString003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInString("key", ["", "abccd"], 2);
console.log("should throw exception on invalid arguments");
......@@ -1066,6 +1136,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1075,8 +1146,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.NotInString() testcase 004
*/
it('testNotInString004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notInString("key", [1, 2]);
console.log("should throw exception on invalid arguments");
......@@ -1084,6 +1156,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1093,18 +1166,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Like() testcase 001
*/
it('testLike001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.like("key", "v1");
query.like("key2", "v2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1114,17 +1188,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Like() testcase 002
*/
it('testLike002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.like("key", "v1").like("key", "v3").like("key", "v2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1134,8 +1209,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Like() testcase 003
*/
it('testLike003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.like("key", 0);
console.log("should throw exception on invalid arguments");
......@@ -1143,6 +1219,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1152,8 +1229,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Like() testcase 004
*/
it('testLike004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.like("key", "str1", "str2");
console.log("should throw exception on invalid arguments");
......@@ -1161,6 +1239,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1170,17 +1249,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Unlike() testcase 001
*/
it('testUnlike001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.unlike("key", "v1");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1190,17 +1270,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Unlike() testcase 002
*/
it('testUnlike002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.unlike("key", "v1").unlike("key", "v3").unlike("key", "v2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1210,8 +1291,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Unlike() testcase 003
*/
it('testUnlike003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.unlike("key", 0);
console.log("should throw exception on invalid arguments");
......@@ -1219,6 +1301,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1228,8 +1311,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Unlike() testcase 004
*/
it('testUnlike004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.unlike("key", "str1", "str2");
console.log("should throw exception on invalid arguments");
......@@ -1237,6 +1321,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1246,19 +1331,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.And() testcase 001
*/
it('testAnd001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0);
query.and();
query.notEqualTo("key", "v1");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1268,17 +1354,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.And() testcase 002
*/
it('testAnd002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key1", 0).and().equalTo("key2", "v1");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1288,17 +1375,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.And() testcase 003
*/
it('testAnd003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0).and().notEqualTo("key", 1).and();
expect(query.getSqlLike() !== "").assertTrue();
query.reset();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1308,8 +1396,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.And() testcase 004
*/
it('testAnd004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0).and(1).notInNumber("key", [1, 3]);
console.log("should throw exception on invalid arguments");
......@@ -1317,6 +1406,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1326,19 +1416,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Or() testcase 001
*/
it('testOr001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0);
query.or();
query.notEqualTo("key", "v1");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1348,18 +1439,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Or() testcase 002
*/
it('testOr002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.equalTo("key1", 0).or().equalTo("key2", "v1");
expect(query.getSqlLike() !== "").assertTrue();
query.reset();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1369,19 +1461,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Or() testcase 003
*/
it('testOr003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0).or();
console.log("or ... sql:" + query.getSqlLike());
expect(query.getSqlLike() !== "").assertTrue();
query.reset();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("throw exception is ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1391,8 +1484,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Or() testcase 004
*/
it('testOr004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0).or(1).notInNumber("key", [1, 3]);
console.log("should throw exception on invalid arguments");
......@@ -1400,6 +1494,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1409,18 +1504,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByAsc() testcase 001
*/
it('testOrderByAsc001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0);
query.orderByAsc("sortbykey");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1430,17 +1526,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByAsc() testcase 002
*/
it('testOrderByAsc002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", "V0").orderByAsc("sortbykey1").orderByAsc("sortbykey2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1450,8 +1547,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByAsc() testcase 003
*/
it('testOrderByAsc003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", false).orderByAsc(1);
console.log("should throw exception on invalid arguments");
......@@ -1459,6 +1557,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1468,8 +1567,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByAsc() testcase 004
*/
it('testOrderByAsc004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.orderByAsc();
console.log("should throw exception on invalid arguments");
......@@ -1477,6 +1577,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1486,18 +1587,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByDesc() testcase 001
*/
it('testOrderByDesc001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", 0);
query.orderByDesc("sortbykey");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1507,17 +1609,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByDesc() testcase 002
*/
it('testOrderByDesc002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", "V0").orderByDesc("sortbykey1").orderByDesc("sortbykey2");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1527,8 +1630,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByDesc() testcase 003
*/
it('testOrderByDesc003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", false).orderByDesc(1);
console.log("should throw exception on invalid arguments");
......@@ -1536,6 +1640,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1545,8 +1650,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.OrderByDesc() testcase 004
*/
it('testOrderByDesc004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.orderByDesc();
console.log("should throw exception on invalid arguments");
......@@ -1554,6 +1660,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1563,18 +1670,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Limit() testcase 001
*/
it('testLimit001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", "vx");
query.limit(10, 2);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1584,18 +1692,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Limit() testcase 002
*/
it('testLimit002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
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.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1605,17 +1714,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Limit() testcase 003
*/
it('testLimit003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", false).limit(10, 2, "any");
console.log("should throw exception on invalid arguments");
expect(null).assertFail();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1625,8 +1735,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Limit() testcase 004
*/
it('testLimit004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", false).limit(10);
console.log("should throw exception on invalid arguments");
......@@ -1634,6 +1745,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1643,17 +1755,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.Limit() testcase 005
*/
it('testLimit005', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.notEqualTo("key", false).limit("any", 10);
console.log("should throw exception on invalid arguments");
console.log("query is " + query.getSqlLike());
query = null;
expect(null).assertFail();
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1663,17 +1776,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNotNull() testcase 001
*/
it('testIsNotNull001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNotNull("key");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1683,17 +1797,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNotNull() testcase 002
*/
it('testIsNotNull002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNotNull("key1").and().notEqualTo("key1", 123);
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1703,8 +1818,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNotNull() testcase 003
*/
it('testIsNotNull003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNotNull("key2", "any");
console.log("should throw exception on invalid arguments");
......@@ -1712,6 +1828,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1721,8 +1838,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.IsNotNull() testcase 004
*/
it('testIsNotNull004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.isNotNull(1);
console.log("should throw exception on invalid arguments");
......@@ -1730,6 +1848,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1739,19 +1858,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.BeginGroup() testcase 001
*/
it('testBeginGroup001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.beginGroup();
query.isNotNull("$.name");
query.endGroup();
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1761,8 +1881,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.BeginGroup() testcase 002
*/
it('testBeginGroup002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.beginGroup();
query.beginGroup();
......@@ -1771,11 +1892,11 @@ describe('QueryTest', function() {
query.beginGroup();
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1785,8 +1906,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.BeginGroup() testcase 003
*/
it('testBeginGroup003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.beginGroup(1);
console.log("should throw exception on invalid arguments");
......@@ -1794,6 +1916,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1803,8 +1926,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.BeginGroup() testcase 004
*/
it('testBeginGroup004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.beginGroup("any", 1);
console.log("should throw exception on invalid arguments");
......@@ -1812,6 +1936,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1821,18 +1946,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EndGroup() testcase 001
*/
it('testEndGroup001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.beginGroup();
query.isNotNull("$.name");
query.endGroup();
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1842,8 +1968,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EndGroup() testcase 002
*/
it('testEndGroup002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.endGroup();
query.beginGroup();
......@@ -1851,10 +1978,10 @@ describe('QueryTest', function() {
query.endGroup();
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1864,8 +1991,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EndGroup() testcase 003
*/
it('testEndGroup003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.endGroup(0);
console.log("should throw exception on invalid arguments");
......@@ -1873,6 +2001,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1882,8 +2011,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.EndGroup() testcase 004
*/
it('testEndGroup004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.endGroup("any");
console.log("should throw exception on invalid arguments");
......@@ -1891,6 +2021,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1900,17 +2031,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.PrefixKey() testcase 001
*/
it('testPrefixKey001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.prefixKey("$.name");
query.prefixKey("0");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1920,16 +2052,17 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.PrefixKey() testcase 002
*/
it('testPrefixKey002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.prefixKey("kx1").or().prefixKey("kx2").or().prefixKey("kx3");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1939,8 +2072,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.PrefixKey() testcase 003
*/
it('testPrefixKey003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.prefixKey("k", "any");
console.log("should throw exception on invalid arguments");
......@@ -1948,6 +2082,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1957,8 +2092,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.PrefixKey() testcase 004
*/
it('testPrefixKey004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.prefixKey(123);
console.log("should throw exception on invalid arguments");
......@@ -1966,6 +2102,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -1975,17 +2112,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.SetSuggestIndex() testcase 001
*/
it('testSetSuggestIndex001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.setSuggestIndex("$.name");
query.setSuggestIndex("0");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -1995,16 +2133,17 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.SetSuggestIndex() testcase 002
*/
it('testSetSuggestIndex002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.setSuggestIndex("kxx").or().equalTo("key2", "v1");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
expect(null).assertFail();
}
query = null;
done();
})
......@@ -2014,8 +2153,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.SetSuggestIndex() testcase 003
*/
it('testSetSuggestIndex003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.setSuggestIndex("k", "any");
console.log("should throw exception on invalid arguments");
......@@ -2023,6 +2163,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -2032,8 +2173,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.SetSuggestIndex() testcase 004
*/
it('testSetSuggestIndex004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.setSuggestIndex(123);
console.log("should throw exception on invalid arguments");
......@@ -2041,6 +2183,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -2050,18 +2193,19 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.DeviceId() testcase 001
*/
it('testDeviceId001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.deviceId("$.name");
query.deviceId("0");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -2071,17 +2215,18 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.DeviceId() testcase 002
*/
it('testDeviceId002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.deviceId("kxx").equalTo("key2", "v1");
expect(query.getSqlLike() !== "").assertTrue();
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -2091,8 +2236,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.DeviceId() testcase 003
*/
it('testDeviceId003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.deviceId("k", "any");
console.log("should throw exception on invalid arguments");
......@@ -2100,6 +2246,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -2109,8 +2256,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.DeviceId() testcase 004
*/
it('testDeviceId004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.deviceId(123);
console.log("should throw exception on invalid arguments");
......@@ -2118,6 +2266,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -2127,19 +2276,20 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GetSqlLike() testcase 001
*/
it('testGetSqlLike001', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
let sql1 = query.getSqlLike();
console.log("testGetSqlLike001 sql=" + sql1);
let sql2 = query.getSqlLike();
expect(sql1).assertEqual(sql2);
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
console.log("dumplicated calls should be ok : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -2149,8 +2299,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GetSqlLike() testcase 002
*/
it('testGetSqlLike002', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
let sql1 = query.getSqlLike();
console.log("testGetSqlLike002 sql=" + sql1);
......@@ -2161,11 +2312,11 @@ describe('QueryTest', function() {
console.log("testGetSqlLike002 sql=" + sql2);
console.log("query is " + query.getSqlLike());
expect(sql1 !== sql2).assertTrue();
query = null;
} catch (e) {
console.log("should be ok on Method Chaining : " + e);
expect(null).assertFail();
}
query = null;
done();
})
......@@ -2175,8 +2326,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GetSqlLike() testcase 003
*/
it('testGetSqlLike003', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inNumber("key");
query.getSqlLike(0);
......@@ -2185,6 +2337,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
......@@ -2194,8 +2347,9 @@ describe('QueryTest', function() {
* @tc.desc Test Js Api Query.GetSqlLike() testcase 004
*/
it('testGetSqlLike004', 0, async function(done) {
var query = null;
try {
let query = new ddm.Query();
query = new ddm.Query();
expect("").assertEqual(query.getSqlLike());
query.inNumber("key");
query.getSqlLike("any");
......@@ -2204,6 +2358,7 @@ describe('QueryTest', function() {
} catch (e) {
console.log("throw exception is ok : " + e);
}
query = null;
done();
})
})
\ No newline at end of file
......@@ -136,13 +136,13 @@ describe('SchemaTest', function() {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -262,4 +262,25 @@ describe('SchemaTest', function() {
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_TOJSONSTRING_0400
* @tc.name [JS-API8]Schema.ToJsonString()
* @tc.desc Test Js Api Schema.ToJsonString() testcase 004
*/
it('testToJsonString004', 0, async function(done) {
try {
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
let schema = new ddm.Schema();
schema.root.appendChild(english);
console.log("schema without indexes: " + schema.toJsonString());
schema.indexes = []; // indexex set to empty array -> invalid indexes.
expect(null).assertFail();
} catch (e) {
console.log("schema exception is ok: " + e);
}
done();
})
})
\ No newline at end of file
......@@ -31,6 +31,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
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));
......@@ -104,6 +107,7 @@ describe('SingleKvStoreCallbackTest', function () {
done();
});
});
kvStore = null;
})
/**
......@@ -821,16 +825,19 @@ describe('SingleKvStoreCallbackTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
console.log('testSingleKvStoreOnSyncComplete101 put success');
expect(err == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10);
done();
});
try {
var mode = factory.SyncMode.PULL_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testSingleKvStoreOnSyncComplete101 e' + e);
expect(null).assertFail();
done();
}
done();
})
/**
......@@ -844,19 +851,22 @@ describe('SingleKvStoreCallbackTest', function () {
console.log('testSingleKvStoreOnSyncComplete102 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync102', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
console.log('testSingleKvStoreOnSyncComplete102 put success');
expect(err == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10);
done();
});
try {
var mode = factory.SyncMode.PUSH_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete102 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testSingleKvStoreOnSyncComplete102 e' + e);
expect(null).assertFail();
done();
}
done();
})
/**
......@@ -870,19 +880,22 @@ describe('SingleKvStoreCallbackTest', function () {
console.log('testSingleKvStoreOnSyncComplete103 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync103', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
console.log('testSingleKvStoreOnSyncComplete103 put success');
expect(err == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10);
done();
});
try {
var mode = factory.SyncMode.PUSH_PULL;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete103 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testSingleKvStoreOnSyncComplete103 e' + e);
expect(null).assertFail();
done();
}
done();
})
/**
......
......@@ -48,7 +48,7 @@ describe('KvStoreEnumTest', function () {
var maxValueLength = factory.Constants.MAX_VALUE_LENGTH;
console.info('maxValueLength = ' + maxValueLength);
expect(maxValueLength == 4194303).assertTrue();
expect( factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
})
/**
......@@ -63,7 +63,6 @@ describe('KvStoreEnumTest', function () {
console.info('can NOT set value to MAX_VALUE_LENGTH : ' + e);
expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
}
})
/**
......@@ -72,9 +71,6 @@ describe('KvStoreEnumTest', function () {
* @tc.desc Test Js Enum Value Constants.MAX_KEY_LENGTH_DEVICE
*/
it('testConstantsMaxKeyLengthDevice_001', 0, function () {
expect( factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
var maxKeyLengthDevice = factory.Constants.MAX_KEY_LENGTH_DEVICE;
console.info('maxKeyLengthDevice = ' + maxKeyLengthDevice);
expect(maxKeyLengthDevice == 896).assertTrue()
......
......@@ -31,6 +31,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
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));
......@@ -107,13 +110,13 @@ describe('SingleKvStorePromiseTest', function () {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -830,15 +833,19 @@ describe('SingleKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testSingleKvStoreOnSyncComplete001 put success');
expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10);
}).catch((error) => {
console.log('testSingleKvStoreOnSyncComplete001 put fail ' + error);
expect(null).assertFail();
});
try {
var mode = factory.SyncMode.PULL_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete001 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testSingleKvStoreOnSyncComplete001 put e ' + e);
console.log('testSingleKvStoreOnSyncComplete001 e ' + e);
expect(null).assertFail();
}
done();
......@@ -858,15 +865,19 @@ describe('SingleKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testSingleKvStoreOnSyncComplete002 put success');
expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10);
}).catch((error) => {
console.log('testSingleKvStoreOnSyncComplete002 put fail ' + error);
expect(null).assertFail();
});
try {
var mode = factory.SyncMode.PUSH_ONLY;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete002 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testSingleKvStoreOnSyncComplete002 put e ' + e);
console.log('testSingleKvStoreOnSyncComplete002 e ' + e);
expect(null).assertFail();
}
done();
......@@ -886,15 +897,19 @@ describe('SingleKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testSingleKvStoreOnSyncComplete003 put success');
expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10);
}).catch((error) => {
console.log('testSingleKvStoreOnSyncComplete003 put fail ' + error);
expect(null).assertFail();
});
try {
var mode = factory.SyncMode.PUSH_PULL;
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete003 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testSingleKvStoreOnSyncComplete003 put e ' + e);
console.log('testSingleKvStoreOnSyncComplete003 e ' + e);
expect(null).assertFail();
}
done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册