@adobe/acc-js-sdk 1.1.3 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -1
- package/CHANGELOG.md +23 -0
- package/README.md +104 -27
- package/compile.js +2 -1
- package/package-lock.json +19 -12
- package/package.json +1 -1
- package/samples/011 - basics - packages.js +60 -0
- package/src/application.js +46 -6
- package/src/cache.js +11 -1
- package/src/cacheRefresher.js +227 -0
- package/src/client.js +96 -23
- package/src/index.js +3 -1
- package/src/soap.js +18 -12
- package/src/testUtil.js +2 -2
- package/src/transport.js +17 -2
- package/test/application.test.js +13 -2
- package/test/cacheRefresher.test.js +338 -0
- package/test/caches.test.js +16 -1
- package/test/client.test.js +314 -6
- package/test/mock.js +66 -1
- package/test/soap.test.js +45 -31
- package/.vscode/launch.json +0 -22
package/test/client.test.js
CHANGED
|
@@ -25,7 +25,6 @@ const { HttpError } = require('../src/transport.js');
|
|
|
25
25
|
const { Cipher } = require('../src/crypto.js');
|
|
26
26
|
const { EntityAccessor } = require('../src/entityAccessor.js');
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
describe('ACC Client', function () {
|
|
30
29
|
|
|
31
30
|
describe('Init', function () {
|
|
@@ -65,10 +64,10 @@ describe('ACC Client', function () {
|
|
|
65
64
|
|
|
66
65
|
it('Should logon and logoff with traces', async () => {
|
|
67
66
|
const client = await Mock.makeClient();
|
|
67
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
68
|
+
client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
68
69
|
const logs = await Mock.withMockConsole(async () => {
|
|
69
70
|
client.traceAPICalls(true);
|
|
70
|
-
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
71
|
-
client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
72
71
|
await client.NLWS.xtkSession.logon();
|
|
73
72
|
expect(client.isLogged()).toBe(true);
|
|
74
73
|
var sessionInfoXml = client.getSessionInfo("xml");
|
|
@@ -2243,6 +2242,8 @@ describe('ACC Client', function () {
|
|
|
2243
2242
|
}
|
|
2244
2243
|
const client = await Mock.makeClient({ storage: storage });
|
|
2245
2244
|
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2245
|
+
client._transport.mockReturnValueOnce(Mock.GETMODIFIEDENTITIES_RESPONSE);
|
|
2246
|
+
client._transport.mockReturnValueOnce(Mock.GETMODIFIEDENTITIES_RESPONSE);
|
|
2246
2247
|
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
2247
2248
|
await client.NLWS.xtkSession.logon();
|
|
2248
2249
|
storage.getItem.mockReturnValueOnce(JSON.stringify({value: { value: "Hello", type: 6 }, cachedAt: 1633715996021 }));
|
|
@@ -2281,17 +2282,19 @@ describe('ACC Client', function () {
|
|
|
2281
2282
|
});
|
|
2282
2283
|
|
|
2283
2284
|
it("Should ignore protocol for local storage root key", async () => {
|
|
2285
|
+
const version = sdk.getSDKVersion().version; // "${version}" or similar
|
|
2286
|
+
|
|
2284
2287
|
var connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("http://acc-sdk:8080", "admin", "admin", {});
|
|
2285
2288
|
var client = await sdk.init(connectionParameters);
|
|
2286
|
-
expect(client._optionCache._storage._rootKey).toBe(
|
|
2289
|
+
expect(client._optionCache._storage._rootKey).toBe(`acc.js.sdk.${version}.acc-sdk:8080.cache.OptionCache$`);
|
|
2287
2290
|
|
|
2288
2291
|
connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("https://acc-sdk:8080", "admin", "admin", {});
|
|
2289
2292
|
client = await sdk.init(connectionParameters);
|
|
2290
|
-
expect(client._optionCache._storage._rootKey).toBe(
|
|
2293
|
+
expect(client._optionCache._storage._rootKey).toBe(`acc.js.sdk.${version}.acc-sdk:8080.cache.OptionCache$`);
|
|
2291
2294
|
|
|
2292
2295
|
connectionParameters = sdk.ConnectionParameters.ofUserAndPassword("acc-sdk:8080", "admin", "admin", {});
|
|
2293
2296
|
client = await sdk.init(connectionParameters);
|
|
2294
|
-
expect(client._optionCache._storage._rootKey).toBe(
|
|
2297
|
+
expect(client._optionCache._storage._rootKey).toBe(`acc.js.sdk.${version}.acc-sdk:8080.cache.OptionCache$`);
|
|
2295
2298
|
})
|
|
2296
2299
|
|
|
2297
2300
|
it("Should support no storage", async () => {
|
|
@@ -2350,6 +2353,140 @@ describe('ACC Client', function () {
|
|
|
2350
2353
|
expect(schema["namespace"]).toBe("nms");
|
|
2351
2354
|
expect(schema["name"]).toBe("extAccount");
|
|
2352
2355
|
});
|
|
2356
|
+
|
|
2357
|
+
it("Should get schema from the cache", async () => {
|
|
2358
|
+
const client = await Mock.makeClient();
|
|
2359
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2360
|
+
await client.NLWS.xtkSession.logon();
|
|
2361
|
+
|
|
2362
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE);
|
|
2363
|
+
var schema = await client.getSchema("nms:extAccount");
|
|
2364
|
+
expect(schema["namespace"]).toBe("nms");
|
|
2365
|
+
expect(schema["name"]).toBe("extAccount");
|
|
2366
|
+
|
|
2367
|
+
client._transport.mockReturnValue(Promise.resolve(Mock.GETMODIFIEDENTITIES_RESPONSE));
|
|
2368
|
+
|
|
2369
|
+
jest.useFakeTimers();
|
|
2370
|
+
client.startRefreshCaches(5000); // autorefresh every 5000 ms
|
|
2371
|
+
jest.advanceTimersByTime(6000);
|
|
2372
|
+
jest.useRealTimers();
|
|
2373
|
+
|
|
2374
|
+
schema = await client.getSchema("nms:extAccount");
|
|
2375
|
+
expect(schema["namespace"]).toBe("nms");
|
|
2376
|
+
expect(schema["name"]).toBe("extAccount");
|
|
2377
|
+
|
|
2378
|
+
client.stopRefreshCaches();
|
|
2379
|
+
});
|
|
2380
|
+
|
|
2381
|
+
it("Should get schema from server when removed from cache", async () => {
|
|
2382
|
+
const client = await Mock.makeClient();
|
|
2383
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2384
|
+
await client.NLWS.xtkSession.logon();
|
|
2385
|
+
|
|
2386
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE);
|
|
2387
|
+
var schema = await client.getSchema("nms:extAccount");
|
|
2388
|
+
expect(schema["namespace"]).toBe("nms");
|
|
2389
|
+
expect(schema["name"]).toBe("extAccount");
|
|
2390
|
+
|
|
2391
|
+
client._transport.mockReturnValueOnce(Promise.resolve(Mock.GETMODIFIEDENTITIES_SCHEMA_RESPONSE));
|
|
2392
|
+
client._transport.mockReturnValueOnce(Promise.resolve(Mock.GETMODIFIEDENTITIES_SCHEMA_RESPONSE));
|
|
2393
|
+
|
|
2394
|
+
client._transport.mockReturnValue(Promise.resolve(Mock.GET_NMS_EXTACCOUNT_SCHEMA_RESPONSE));
|
|
2395
|
+
jest.useFakeTimers();
|
|
2396
|
+
client.startRefreshCaches(5000); // autorefresh every 5000 ms
|
|
2397
|
+
jest.advanceTimersByTime(6000);
|
|
2398
|
+
jest.useRealTimers();
|
|
2399
|
+
|
|
2400
|
+
schema = await client.getSchema("nms:extAccount");
|
|
2401
|
+
expect(schema["namespace"]).toBe("nms");
|
|
2402
|
+
expect(schema["name"]).toBe("extAccount");
|
|
2403
|
+
client.stopRefreshCaches();
|
|
2404
|
+
});
|
|
2405
|
+
|
|
2406
|
+
it("Should stop refresh", async () => {
|
|
2407
|
+
const client = await Mock.makeClient();
|
|
2408
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2409
|
+
await client.NLWS.xtkSession.logon();
|
|
2410
|
+
jest.useFakeTimers();
|
|
2411
|
+
client.startRefreshCaches();
|
|
2412
|
+
jest.advanceTimersByTime(6000); // autorefresh for xtk:schema should be started after 5000 ms
|
|
2413
|
+
jest.useRealTimers();
|
|
2414
|
+
expect(client._optionCacheRefresher._intervalId).not.toBeNull();
|
|
2415
|
+
expect(client._entityCacheRefresher._intervalId).not.toBeNull();
|
|
2416
|
+
client.stopRefreshCaches();
|
|
2417
|
+
expect(client._optionCacheRefresher._intervalId).toBeNull();
|
|
2418
|
+
expect(client._entityCacheRefresher._intervalId).toBeNull();
|
|
2419
|
+
});
|
|
2420
|
+
|
|
2421
|
+
it("Should stop refresh when logoff", async () => {
|
|
2422
|
+
const client = await Mock.makeClient();
|
|
2423
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2424
|
+
await client.NLWS.xtkSession.logon();
|
|
2425
|
+
jest.useFakeTimers();
|
|
2426
|
+
client.startRefreshCaches();
|
|
2427
|
+
jest.advanceTimersByTime(6000); // autorefresh for xtk:schema should be started after 5000 ms
|
|
2428
|
+
jest.useRealTimers();
|
|
2429
|
+
expect(client._optionCacheRefresher._intervalId).not.toBeNull();
|
|
2430
|
+
expect(client._entityCacheRefresher._intervalId).not.toBeNull();
|
|
2431
|
+
client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
2432
|
+
await client.logoff();
|
|
2433
|
+
expect(client._optionCacheRefresher._intervalId).toBeNull();
|
|
2434
|
+
expect(client._entityCacheRefresher._intervalId).toBeNull();
|
|
2435
|
+
});
|
|
2436
|
+
|
|
2437
|
+
it("Expired session and refresh cache", async () => {
|
|
2438
|
+
let refreshClient = async () => {
|
|
2439
|
+
const connectionParameters = sdk.ConnectionParameters.ofSecurityToken("http://acc-sdk:8080",
|
|
2440
|
+
"$security_token$", {refreshClient: refreshClient});
|
|
2441
|
+
const newClient = await sdk.init(connectionParameters);
|
|
2442
|
+
newClient._transport = jest.fn();
|
|
2443
|
+
newClient._transport.mockReturnValueOnce(Mock.BEARER_LOGON_RESPONSE);
|
|
2444
|
+
await newClient.logon();
|
|
2445
|
+
return newClient;
|
|
2446
|
+
}
|
|
2447
|
+
const connectionParameters = sdk.ConnectionParameters.ofBearerToken("http://acc-sdk:8080",
|
|
2448
|
+
"$token$", {refreshClient: refreshClient});
|
|
2449
|
+
const client = await sdk.init(connectionParameters);
|
|
2450
|
+
jest.useFakeTimers();
|
|
2451
|
+
client.startRefreshCaches();
|
|
2452
|
+
client._entityCacheRefresher._safeCallAndRefresh = jest.fn();
|
|
2453
|
+
client._optionCacheRefresher._safeCallAndRefresh = jest.fn();
|
|
2454
|
+
jest.advanceTimersByTime(18000);
|
|
2455
|
+
expect(client._entityCacheRefresher._safeCallAndRefresh.mock.calls.length).toBe(1);
|
|
2456
|
+
expect(client._optionCacheRefresher._safeCallAndRefresh.mock.calls.length).toBe(1);
|
|
2457
|
+
client.traceAPICalls(true);
|
|
2458
|
+
client._transport = jest.fn();
|
|
2459
|
+
client._transport.mockReturnValueOnce(Mock.BEARER_LOGON_RESPONSE);
|
|
2460
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`XSV-350008 Session has expired or is invalid. Please reconnect.`));
|
|
2461
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2462
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
2463
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:queryDef' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
2464
|
+
<SOAP-ENV:Body>
|
|
2465
|
+
<ExecuteQueryResponse xmlns='urn:xtk:queryDef' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
2466
|
+
<pdomOutput xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
2467
|
+
<extAccount-collection/>
|
|
2468
|
+
</pdomOutput></ExecuteQueryResponse>
|
|
2469
|
+
</SOAP-ENV:Body>
|
|
2470
|
+
</SOAP-ENV:Envelope>`));
|
|
2471
|
+
await client.logon();
|
|
2472
|
+
var queryDef = {
|
|
2473
|
+
"schema": "nms:extAccount",
|
|
2474
|
+
"operation": "select",
|
|
2475
|
+
"select": {
|
|
2476
|
+
"node": [
|
|
2477
|
+
{ "expr": "@id" },
|
|
2478
|
+
{ "expr": "@name" }
|
|
2479
|
+
]
|
|
2480
|
+
}
|
|
2481
|
+
};
|
|
2482
|
+
var query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
2483
|
+
var extAccount = await query.executeQuery();
|
|
2484
|
+
expect(extAccount).toEqual({ extAccount: [] });
|
|
2485
|
+
jest.advanceTimersByTime(10000);
|
|
2486
|
+
expect(client._entityCacheRefresher._safeCallAndRefresh.mock.calls.length).toBe(2);
|
|
2487
|
+
expect(client._optionCacheRefresher._safeCallAndRefresh.mock.calls.length).toBe(2);
|
|
2488
|
+
jest.useRealTimers();
|
|
2489
|
+
});
|
|
2353
2490
|
});
|
|
2354
2491
|
|
|
2355
2492
|
describe("Calling SOAP method with parameters as a function", () => {
|
|
@@ -2803,4 +2940,175 @@ describe('ACC Client', function () {
|
|
|
2803
2940
|
});
|
|
2804
2941
|
});
|
|
2805
2942
|
});
|
|
2943
|
+
|
|
2944
|
+
describe("Pushdown parameters", () => {
|
|
2945
|
+
it("Should push down custom parameters", async () => {
|
|
2946
|
+
const client = await Mock.makeClient();
|
|
2947
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2948
|
+
await client.NLWS.xtkSession.logon();
|
|
2949
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2950
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2951
|
+
const queryDef = {
|
|
2952
|
+
"schema": "nms:extAccount",
|
|
2953
|
+
"operation": "select",
|
|
2954
|
+
"select": {
|
|
2955
|
+
"node": [
|
|
2956
|
+
{ "expr": "@id" },
|
|
2957
|
+
{ "expr": "@name" }
|
|
2958
|
+
]
|
|
2959
|
+
}
|
|
2960
|
+
};
|
|
2961
|
+
// Pushing down the foo=bar attributes
|
|
2962
|
+
const query = client.NLWS.pushDown({'foo': 'bar'}).xtkQueryDef.create(queryDef);
|
|
2963
|
+
await query.executeQuery();
|
|
2964
|
+
const lastCall = client._transport.mock.calls[client._transport.mock.calls.length-1];
|
|
2965
|
+
expect(lastCall[0].url).toBe("http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef:ExecuteQuery");
|
|
2966
|
+
expect(lastCall[1].charset).toBe("UTF-8");
|
|
2967
|
+
expect(lastCall[1].foo).toBe("bar");
|
|
2968
|
+
});
|
|
2969
|
+
|
|
2970
|
+
it("Should push down custom parameters defined at the connection level", async () => {
|
|
2971
|
+
const client = await Mock.makeClient({ 'cnxDefault': 3, 'foo': 'foo' });
|
|
2972
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2973
|
+
await client.NLWS.xtkSession.logon();
|
|
2974
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
2975
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
2976
|
+
const queryDef = {
|
|
2977
|
+
"schema": "nms:extAccount",
|
|
2978
|
+
"operation": "select",
|
|
2979
|
+
"select": {
|
|
2980
|
+
"node": [
|
|
2981
|
+
{ "expr": "@id" },
|
|
2982
|
+
{ "expr": "@name" }
|
|
2983
|
+
]
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
// Pushing down the foo=bar attributes (should overload the "foo" set in connecion parameters)
|
|
2987
|
+
const query = client.NLWS.pushDown({'foo': 'bar'}).xtkQueryDef.create(queryDef);
|
|
2988
|
+
await query.executeQuery();
|
|
2989
|
+
const lastCall = client._transport.mock.calls[client._transport.mock.calls.length-1];
|
|
2990
|
+
expect(lastCall[0].url).toBe("http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef:ExecuteQuery");
|
|
2991
|
+
expect(lastCall[1].charset).toBe("UTF-8");
|
|
2992
|
+
expect(lastCall[1].foo).toBe("bar");
|
|
2993
|
+
expect(lastCall[1].cnxDefault).toBe(3);
|
|
2994
|
+
});
|
|
2995
|
+
|
|
2996
|
+
it("Should chain push options", async () => {
|
|
2997
|
+
const client = await Mock.makeClient({ 'cnxDefault': 3, 'foo': 'foo' });
|
|
2998
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
2999
|
+
await client.NLWS.xtkSession.logon();
|
|
3000
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
3001
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
3002
|
+
const queryDef = {
|
|
3003
|
+
"schema": "nms:extAccount",
|
|
3004
|
+
"operation": "select",
|
|
3005
|
+
"select": {
|
|
3006
|
+
"node": [
|
|
3007
|
+
{ "expr": "@id" },
|
|
3008
|
+
{ "expr": "@name" }
|
|
3009
|
+
]
|
|
3010
|
+
}
|
|
3011
|
+
};
|
|
3012
|
+
// Supports multiple calls to pushDown. each one overrides the previous in case of duplicate key
|
|
3013
|
+
// Also supports undefined
|
|
3014
|
+
const query = client.NLWS.pushDown({'foo': 'bar'}).pushDown().pushDown({'foo': 'fu', x: 2 }).xtkQueryDef.create(queryDef);
|
|
3015
|
+
await query.executeQuery();
|
|
3016
|
+
const lastCall = client._transport.mock.calls[client._transport.mock.calls.length-1];
|
|
3017
|
+
expect(lastCall[0].url).toBe("http://acc-sdk:8080/nl/jsp/soaprouter.jsp?xtk:queryDef:ExecuteQuery");
|
|
3018
|
+
expect(lastCall[1].charset).toBe("UTF-8");
|
|
3019
|
+
expect(lastCall[1].foo).toBe("fu");
|
|
3020
|
+
expect(lastCall[1].cnxDefault).toBe(3);
|
|
3021
|
+
expect(lastCall[1].x).toBe(2);
|
|
3022
|
+
});
|
|
3023
|
+
});
|
|
3024
|
+
describe("Schema cache refresh", () => {
|
|
3025
|
+
it("Should unregister listener", async () => {
|
|
3026
|
+
const client = await Mock.makeClient();
|
|
3027
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3028
|
+
await client.NLWS.xtkSession.logon();
|
|
3029
|
+
|
|
3030
|
+
class Listener {
|
|
3031
|
+
constructor() {
|
|
3032
|
+
this._schemas = {};
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
invalidateCacheItem(schemaId) {
|
|
3036
|
+
this._schemas[schemaId] = undefined;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
client._unregisterAllCacheChangeListeners();
|
|
3041
|
+
expect(client._cacheChangeListeners.length).toBe(0);
|
|
3042
|
+
const listener = new Listener();
|
|
3043
|
+
|
|
3044
|
+
client._registerCacheChangeListener(listener);
|
|
3045
|
+
expect(client._cacheChangeListeners.length).toBe(1);
|
|
3046
|
+
client._unregisterCacheChangeListener(listener);
|
|
3047
|
+
expect(client._cacheChangeListeners.length).toBe(0);
|
|
3048
|
+
});
|
|
3049
|
+
|
|
3050
|
+
it("Should not unregister unknown listener", async () => {
|
|
3051
|
+
const client = await Mock.makeClient();
|
|
3052
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3053
|
+
await client.NLWS.xtkSession.logon();
|
|
3054
|
+
|
|
3055
|
+
class Listener {
|
|
3056
|
+
constructor() {
|
|
3057
|
+
this._schemas = {};
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
invalidateCacheItem(schemaId) {
|
|
3061
|
+
this._schemas[schemaId] = undefined;
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
client._unregisterAllCacheChangeListeners();
|
|
3066
|
+
expect(client._cacheChangeListeners.length).toBe(0);
|
|
3067
|
+
const listener = new Listener();
|
|
3068
|
+
|
|
3069
|
+
client._registerCacheChangeListener(listener);
|
|
3070
|
+
expect(client._cacheChangeListeners.length).toBe(1);
|
|
3071
|
+
|
|
3072
|
+
const listener2 = new Listener();
|
|
3073
|
+
|
|
3074
|
+
client._unregisterCacheChangeListener(listener2);
|
|
3075
|
+
expect(client._cacheChangeListeners.length).toBe(1);
|
|
3076
|
+
client._unregisterAllCacheChangeListeners();
|
|
3077
|
+
});
|
|
3078
|
+
|
|
3079
|
+
it("Should be notify when register", async () => {
|
|
3080
|
+
const client = await Mock.makeClient();
|
|
3081
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3082
|
+
await client.NLWS.xtkSession.logon();
|
|
3083
|
+
|
|
3084
|
+
class Listener {
|
|
3085
|
+
constructor() {
|
|
3086
|
+
this._schemas = {};
|
|
3087
|
+
}
|
|
3088
|
+
add(schemaId) {
|
|
3089
|
+
this._schemas[schemaId] = "1";
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
invalidateCacheItem(schemaId) {
|
|
3093
|
+
this._schemas[schemaId] = undefined;
|
|
3094
|
+
}
|
|
3095
|
+
getSchema(schemaId) {
|
|
3096
|
+
return this._schemas[schemaId];
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
client._unregisterAllCacheChangeListeners();
|
|
3101
|
+
|
|
3102
|
+
const listener = new Listener();
|
|
3103
|
+
listener.add("nms:recipient");
|
|
3104
|
+
listener.add("xtk:operator");
|
|
3105
|
+
|
|
3106
|
+
client._registerCacheChangeListener(listener);
|
|
3107
|
+
client._notifyCacheChangeListeners("nms:recipient");
|
|
3108
|
+
expect(listener.getSchema("nms:recipient")).toBeUndefined();
|
|
3109
|
+
expect(listener.getSchema("xtk:operator")).toBe("1");
|
|
3110
|
+
|
|
3111
|
+
client._unregisterCacheChangeListener(listener);
|
|
3112
|
+
});
|
|
3113
|
+
});
|
|
2806
3114
|
});
|
package/test/mock.js
CHANGED
|
@@ -614,8 +614,68 @@ const GET_HELLO_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
614
614
|
</SOAP-ENV:Body>
|
|
615
615
|
</SOAP-ENV:Envelope>`);
|
|
616
616
|
|
|
617
|
+
const GETMODIFIEDENTITIES_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
618
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
619
|
+
<SOAP-ENV:Body>
|
|
620
|
+
<GetModifiedEntitiesResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
621
|
+
<pdomDirtyEntities xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
622
|
+
<cache buildNumber="9468" time="2022-07-27T14:38:55.766Z"/>
|
|
623
|
+
</pdomDirtyEntities>
|
|
624
|
+
</GetModifiedEntitiesResponse>
|
|
625
|
+
</SOAP-ENV:Body>
|
|
626
|
+
</SOAP-ENV:Envelope>`);
|
|
627
|
+
|
|
628
|
+
const GETMODIFIEDENTITIES_CLEAR_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
629
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
630
|
+
<SOAP-ENV:Body>
|
|
631
|
+
<GetModifiedEntitiesResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
632
|
+
<pdomDirtyEntities xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
633
|
+
<cache buildNumber="9469" time="2022-07-28T14:38:55.766Z" emptyCache="true"/>
|
|
634
|
+
</pdomDirtyEntities>
|
|
635
|
+
</GetModifiedEntitiesResponse>
|
|
636
|
+
</SOAP-ENV:Body>
|
|
637
|
+
</SOAP-ENV:Envelope>`);
|
|
617
638
|
|
|
618
639
|
|
|
640
|
+
const GETMODIFIEDENTITIES_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
641
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
642
|
+
<SOAP-ENV:Body>
|
|
643
|
+
<GetModifiedEntitiesResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
644
|
+
<pdomDirtyEntities xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
645
|
+
<cache buildNumber="9469" time="2022-07-28T15:32:00.785Z">
|
|
646
|
+
<entityCache lastModified="2022-07-28 15:31:56.331Z" md5="5581959609FEC4B2A9CDBD171BA42E7D" pk="xtk:schema|nms:recipient" schema="xtk:schema"/>
|
|
647
|
+
<entityCache lastModified="2022-07-28 15:31:56.353Z" md5="B27CC681D00C3FA85DDA0B210FE76566" pk="xtk:schema|nms:replicationStrategy" schema="xtk:schema"/>
|
|
648
|
+
<entityCache lastModified="2022-07-28 15:31:56.478Z" md5="E39D051D4D00805693EBA4F72F5ABD7D" pk="xtk:schema|nms:recipientStg" schema="xtk:schema"/>
|
|
649
|
+
<entityCache lastModified="2022-07-28 15:31:56.440Z" md5="23B1FE988F0DCDC88C9F96D06C97FA14" pk="xtk:schema|xxl:xtkFolderXl" schema="xtk:schema"/>
|
|
650
|
+
<entityCache lastModified="2022-07-28 15:31:56.440Z" md5="23B1FE988F0DCDC88C9F96D06C97FA14" pk="xtk:schema|nms:extAccount" schema="xtk:schema"/>
|
|
651
|
+
<entityCache lastModified="2022-07-28 15:31:56.440Z" md5="23B1FE988F0DCDC88C9F96D06C97FA14" pk="xtk:option|testOption" schema="xtk:option"/>
|
|
652
|
+
</cache>
|
|
653
|
+
</pdomDirtyEntities>
|
|
654
|
+
</GetModifiedEntitiesResponse>
|
|
655
|
+
</SOAP-ENV:Body>
|
|
656
|
+
</SOAP-ENV:Envelope>`);
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
const GETMODIFIEDENTITIES_UNDEFINED_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
660
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
661
|
+
<SOAP-ENV:Body>
|
|
662
|
+
<SOAP-ENV:Fault>
|
|
663
|
+
<faultcode>SOAP-ENV:Client</faultcode>
|
|
664
|
+
<faultstring xsi:type='xsd:string'>SOP-330006 The method 'GetModifiedEntities' is not defined in SOAP service 'xtk:session'.</faultstring>
|
|
665
|
+
</SOAP-ENV:Fault>
|
|
666
|
+
</SOAP-ENV:Body>
|
|
667
|
+
</SOAP-ENV:Envelope>`);
|
|
668
|
+
|
|
669
|
+
const GETMODIFIEDENTITIES_ERROR_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
670
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
671
|
+
<SOAP-ENV:Body>
|
|
672
|
+
<SOAP-ENV:Fault>
|
|
673
|
+
<faultcode>SOAP-ENV:Client</faultcode>
|
|
674
|
+
<faultstring xsi:type='xsd:string'>SOP-330011 Error while executing the method 'GetModifiedEntities' of service 'xtk:session'.</faultstring>
|
|
675
|
+
</SOAP-ENV:Fault>
|
|
676
|
+
</SOAP-ENV:Body>
|
|
677
|
+
</SOAP-ENV:Envelope>`);
|
|
678
|
+
|
|
619
679
|
// Public exports
|
|
620
680
|
exports.Mock = {
|
|
621
681
|
makeClient: makeClient,
|
|
@@ -656,5 +716,10 @@ exports.Mock = {
|
|
|
656
716
|
GET_SETELEMENT_RESPONSE: GET_SETELEMENT_RESPONSE,
|
|
657
717
|
GET_GETSCHEMA_HELLO_RESPONSE: GET_GETSCHEMA_HELLO_RESPONSE,
|
|
658
718
|
GET_HELLO_RESPONSE: GET_HELLO_RESPONSE,
|
|
659
|
-
LOGON_RESPONSE_NO_USERINFO: LOGON_RESPONSE_NO_USERINFO
|
|
719
|
+
LOGON_RESPONSE_NO_USERINFO: LOGON_RESPONSE_NO_USERINFO,
|
|
720
|
+
GETMODIFIEDENTITIES_RESPONSE: GETMODIFIEDENTITIES_RESPONSE,
|
|
721
|
+
GETMODIFIEDENTITIES_CLEAR_RESPONSE: GETMODIFIEDENTITIES_CLEAR_RESPONSE,
|
|
722
|
+
GETMODIFIEDENTITIES_SCHEMA_RESPONSE: GETMODIFIEDENTITIES_SCHEMA_RESPONSE,
|
|
723
|
+
GETMODIFIEDENTITIES_UNDEFINED_RESPONSE: GETMODIFIEDENTITIES_UNDEFINED_RESPONSE,
|
|
724
|
+
GETMODIFIEDENTITIES_ERROR_RESPONSE: GETMODIFIEDENTITIES_ERROR_RESPONSE
|
|
660
725
|
}
|