@fluid-experimental/property-properties 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
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/README.md +1 -0
- package/dist/containerSerializer.d.ts.map +1 -1
- package/dist/containerSerializer.js +5 -5
- package/dist/containerSerializer.js.map +1 -1
- package/dist/enableValidations.js.map +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/properties/abstractStaticCollectionProperty.d.ts +10 -10
- package/dist/properties/abstractStaticCollectionProperty.d.ts.map +1 -1
- package/dist/properties/abstractStaticCollectionProperty.js +70 -53
- package/dist/properties/abstractStaticCollectionProperty.js.map +1 -1
- package/dist/properties/arrayProperty.d.ts.map +1 -1
- package/dist/properties/arrayProperty.js +152 -103
- package/dist/properties/arrayProperty.js.map +1 -1
- package/dist/properties/baseProperty.d.ts +4 -4
- package/dist/properties/baseProperty.d.ts.map +1 -1
- package/dist/properties/baseProperty.js +69 -47
- package/dist/properties/baseProperty.js.map +1 -1
- package/dist/properties/boolProperty.d.ts.map +1 -1
- package/dist/properties/boolProperty.js +3 -3
- package/dist/properties/boolProperty.js.map +1 -1
- package/dist/properties/containerProperty.d.ts +8 -8
- package/dist/properties/containerProperty.d.ts.map +1 -1
- package/dist/properties/containerProperty.js +33 -26
- package/dist/properties/containerProperty.js.map +1 -1
- package/dist/properties/enumArrayProperty.d.ts.map +1 -1
- package/dist/properties/enumArrayProperty.js +14 -14
- package/dist/properties/enumArrayProperty.js.map +1 -1
- package/dist/properties/enumProperty.d.ts.map +1 -1
- package/dist/properties/enumProperty.js +17 -17
- package/dist/properties/enumProperty.js.map +1 -1
- package/dist/properties/floatProperties.js +4 -4
- package/dist/properties/floatProperties.js.map +1 -1
- package/dist/properties/index.d.ts +23 -23
- package/dist/properties/index.d.ts.map +1 -1
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.js +47 -37
- package/dist/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/dist/properties/intProperties.d.ts.map +1 -1
- package/dist/properties/intProperties.js +10 -10
- package/dist/properties/intProperties.js.map +1 -1
- package/dist/properties/lazyLoadedProperties.js.map +1 -1
- package/dist/properties/mapProperty.d.ts.map +1 -1
- package/dist/properties/mapProperty.js +21 -17
- package/dist/properties/mapProperty.js.map +1 -1
- package/dist/properties/namedNodeProperty.d.ts.map +1 -1
- package/dist/properties/namedNodeProperty.js +3 -3
- package/dist/properties/namedNodeProperty.js.map +1 -1
- package/dist/properties/namedProperty.d.ts.map +1 -1
- package/dist/properties/namedProperty.js +7 -5
- package/dist/properties/namedProperty.js.map +1 -1
- package/dist/properties/nodeProperty.d.ts.map +1 -1
- package/dist/properties/nodeProperty.js +5 -3
- package/dist/properties/nodeProperty.js.map +1 -1
- package/dist/properties/primitiveTypeCasts.d.ts.map +1 -1
- package/dist/properties/primitiveTypeCasts.js +9 -9
- package/dist/properties/primitiveTypeCasts.js.map +1 -1
- package/dist/properties/referenceArrayProperty.d.ts.map +1 -1
- package/dist/properties/referenceArrayProperty.js +31 -25
- package/dist/properties/referenceArrayProperty.js.map +1 -1
- package/dist/properties/referenceMapProperty.d.ts.map +1 -1
- package/dist/properties/referenceMapProperty.js +18 -18
- package/dist/properties/referenceMapProperty.js.map +1 -1
- package/dist/properties/referenceProperty.d.ts.map +1 -1
- package/dist/properties/referenceProperty.js +33 -29
- package/dist/properties/referenceProperty.js.map +1 -1
- package/dist/properties/setProperty.d.ts.map +1 -1
- package/dist/properties/setProperty.js +31 -29
- package/dist/properties/setProperty.js.map +1 -1
- package/dist/properties/stringProperty.d.ts.map +1 -1
- package/dist/properties/stringProperty.js +56 -40
- package/dist/properties/stringProperty.js.map +1 -1
- package/dist/properties/uintProperties.js +5 -5
- package/dist/properties/uintProperties.js.map +1 -1
- package/dist/properties/valueArrayProperty.d.ts +1 -1
- package/dist/properties/valueArrayProperty.d.ts.map +1 -1
- package/dist/properties/valueArrayProperty.js +30 -29
- package/dist/properties/valueArrayProperty.js.map +1 -1
- package/dist/properties/valueMapProperty.d.ts.map +1 -1
- package/dist/properties/valueMapProperty.js +31 -29
- package/dist/properties/valueMapProperty.js.map +1 -1
- package/dist/properties/valueProperty.d.ts.map +1 -1
- package/dist/properties/valueProperty.js +11 -9
- package/dist/properties/valueProperty.js.map +1 -1
- package/dist/propertyFactory.d.ts.map +1 -1
- package/dist/propertyFactory.js +309 -252
- package/dist/propertyFactory.js.map +1 -1
- package/dist/propertyTemplate.d.ts +17 -17
- package/dist/propertyTemplate.d.ts.map +1 -1
- package/dist/propertyTemplate.js +64 -45
- package/dist/propertyTemplate.js.map +1 -1
- package/dist/propertyTemplateWrapper.d.ts.map +1 -1
- package/dist/propertyTemplateWrapper.js +40 -25
- package/dist/propertyTemplateWrapper.js.map +1 -1
- package/dist/propertyUtils.d.ts.map +1 -1
- package/dist/propertyUtils.js.map +1 -1
- package/dist/test/properties/arrayProperty.spec.js +566 -490
- package/dist/test/properties/arrayProperty.spec.js.map +1 -1
- package/dist/test/properties/baseProperty.spec.js +293 -280
- package/dist/test/properties/baseProperty.spec.js.map +1 -1
- package/dist/test/properties/containerProperty.spec.js +100 -94
- package/dist/test/properties/containerProperty.spec.js.map +1 -1
- package/dist/test/properties/customArrayProperty.spec.js +174 -147
- package/dist/test/properties/customArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/enumArrayProperty.spec.js +67 -63
- package/dist/test/properties/enumArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/enumProperty.spec.js +115 -97
- package/dist/test/properties/enumProperty.spec.js.map +1 -1
- package/dist/test/properties/float32.spec.js +5 -5
- package/dist/test/properties/float32.spec.js.map +1 -1
- package/dist/test/properties/int64ArrayProperty.spec.js +157 -93
- package/dist/test/properties/int64ArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/int64MapProperty.spec.js +185 -166
- package/dist/test/properties/int64MapProperty.spec.js.map +1 -1
- package/dist/test/properties/int64Property.spec.js +109 -109
- package/dist/test/properties/int64Property.spec.js.map +1 -1
- package/dist/test/properties/isLeafNode.spec.js +75 -76
- package/dist/test/properties/isLeafNode.spec.js.map +1 -1
- package/dist/test/properties/mapProperty.spec.js +571 -531
- package/dist/test/properties/mapProperty.spec.js.map +1 -1
- package/dist/test/properties/namedNodeProperty.spec.js +31 -31
- package/dist/test/properties/namedNodeProperty.spec.js.map +1 -1
- package/dist/test/properties/nodeProperty.spec.js +805 -795
- package/dist/test/properties/nodeProperty.spec.js.map +1 -1
- package/dist/test/properties/referenceProperty.spec.js +729 -679
- package/dist/test/properties/referenceProperty.spec.js.map +1 -1
- package/dist/test/properties/relationshipProperty.spec.js +16 -16
- package/dist/test/properties/relationshipProperty.spec.js.map +1 -1
- package/dist/test/properties/setProperty.spec.js +288 -227
- package/dist/test/properties/setProperty.spec.js.map +1 -1
- package/dist/test/properties/stringProperty.spec.js +326 -318
- package/dist/test/properties/stringProperty.spec.js.map +1 -1
- package/dist/test/properties/uint64Property.spec.js +46 -36
- package/dist/test/properties/uint64Property.spec.js.map +1 -1
- package/dist/test/properties/valueMapProperty.spec.js +259 -246
- package/dist/test/properties/valueMapProperty.spec.js.map +1 -1
- package/dist/test/properties/valueProperty.spec.js +49 -43
- package/dist/test/properties/valueProperty.spec.js.map +1 -1
- package/dist/test/propertyFactory.spec.js +2038 -1631
- package/dist/test/propertyFactory.spec.js.map +1 -1
- package/dist/test/propertyTemplateWrapper.spec.js +72 -102
- package/dist/test/propertyTemplateWrapper.spec.js.map +1 -1
- package/dist/test/propertyUtils.spec.js +22 -21
- package/dist/test/propertyUtils.spec.js.map +1 -1
- package/dist/test/reversibleChangeset.spec.js +857 -703
- package/dist/test/reversibleChangeset.spec.js.map +1 -1
- package/dist/test/setup.js +5 -5
- package/dist/test/setup.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/utils.spec.js +1334 -1144
- package/dist/test/utils.spec.js.map +1 -1
- package/dist/test/validation/badMissingSemverInTypeid.js +20 -20
- package/dist/test/validation/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/validation/badPrimitiveTypeid.js +12 -12
- package/dist/test/validation/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/validation/goodColorId.js +91 -91
- package/dist/test/validation/goodColorId.js.map +1 -1
- package/dist/test/validation/goodColorPalette.js +4 -4
- package/dist/test/validation/goodColorPalette.js.map +1 -1
- package/dist/test/validation/goodPointId.js +20 -20
- package/dist/test/validation/goodPointId.js.map +1 -1
- package/dist/test/validation/reversibleChangeSetTestData.js +23841 -2
- package/dist/test/validation/reversibleChangeSetTestData.js.map +1 -1
- package/lib/containerSerializer.d.ts.map +1 -1
- package/lib/containerSerializer.js +5 -5
- package/lib/containerSerializer.js.map +1 -1
- package/lib/enableValidations.js.map +1 -1
- package/lib/index.d.ts +19 -19
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -19
- package/lib/index.js.map +1 -1
- package/lib/properties/abstractStaticCollectionProperty.d.ts +10 -10
- package/lib/properties/abstractStaticCollectionProperty.d.ts.map +1 -1
- package/lib/properties/abstractStaticCollectionProperty.js +70 -53
- package/lib/properties/abstractStaticCollectionProperty.js.map +1 -1
- package/lib/properties/arrayProperty.d.ts.map +1 -1
- package/lib/properties/arrayProperty.js +152 -103
- package/lib/properties/arrayProperty.js.map +1 -1
- package/lib/properties/baseProperty.d.ts +4 -4
- package/lib/properties/baseProperty.d.ts.map +1 -1
- package/lib/properties/baseProperty.js +73 -51
- package/lib/properties/baseProperty.js.map +1 -1
- package/lib/properties/boolProperty.d.ts.map +1 -1
- package/lib/properties/boolProperty.js +3 -3
- package/lib/properties/boolProperty.js.map +1 -1
- package/lib/properties/containerProperty.d.ts +8 -8
- package/lib/properties/containerProperty.d.ts.map +1 -1
- package/lib/properties/containerProperty.js +33 -26
- package/lib/properties/containerProperty.js.map +1 -1
- package/lib/properties/enumArrayProperty.d.ts.map +1 -1
- package/lib/properties/enumArrayProperty.js +14 -14
- package/lib/properties/enumArrayProperty.js.map +1 -1
- package/lib/properties/enumProperty.d.ts.map +1 -1
- package/lib/properties/enumProperty.js +17 -17
- package/lib/properties/enumProperty.js.map +1 -1
- package/lib/properties/floatProperties.js +4 -4
- package/lib/properties/floatProperties.js.map +1 -1
- package/lib/properties/index.d.ts +23 -23
- package/lib/properties/index.d.ts.map +1 -1
- package/lib/properties/index.js +23 -23
- package/lib/properties/index.js.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.js +47 -37
- package/lib/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/lib/properties/intProperties.d.ts.map +1 -1
- package/lib/properties/intProperties.js +10 -10
- package/lib/properties/intProperties.js.map +1 -1
- package/lib/properties/lazyLoadedProperties.js.map +1 -1
- package/lib/properties/mapProperty.d.ts.map +1 -1
- package/lib/properties/mapProperty.js +21 -17
- package/lib/properties/mapProperty.js.map +1 -1
- package/lib/properties/namedNodeProperty.d.ts.map +1 -1
- package/lib/properties/namedNodeProperty.js +3 -3
- package/lib/properties/namedNodeProperty.js.map +1 -1
- package/lib/properties/namedProperty.d.ts.map +1 -1
- package/lib/properties/namedProperty.js +7 -5
- package/lib/properties/namedProperty.js.map +1 -1
- package/lib/properties/nodeProperty.d.ts.map +1 -1
- package/lib/properties/nodeProperty.js +5 -3
- package/lib/properties/nodeProperty.js.map +1 -1
- package/lib/properties/primitiveTypeCasts.d.ts.map +1 -1
- package/lib/properties/primitiveTypeCasts.js +9 -9
- package/lib/properties/primitiveTypeCasts.js.map +1 -1
- package/lib/properties/referenceArrayProperty.d.ts.map +1 -1
- package/lib/properties/referenceArrayProperty.js +31 -25
- package/lib/properties/referenceArrayProperty.js.map +1 -1
- package/lib/properties/referenceMapProperty.d.ts.map +1 -1
- package/lib/properties/referenceMapProperty.js +18 -18
- package/lib/properties/referenceMapProperty.js.map +1 -1
- package/lib/properties/referenceProperty.d.ts.map +1 -1
- package/lib/properties/referenceProperty.js +33 -29
- package/lib/properties/referenceProperty.js.map +1 -1
- package/lib/properties/setProperty.d.ts.map +1 -1
- package/lib/properties/setProperty.js +31 -29
- package/lib/properties/setProperty.js.map +1 -1
- package/lib/properties/stringProperty.d.ts.map +1 -1
- package/lib/properties/stringProperty.js +56 -40
- package/lib/properties/stringProperty.js.map +1 -1
- package/lib/properties/uintProperties.js +5 -5
- package/lib/properties/uintProperties.js.map +1 -1
- package/lib/properties/valueArrayProperty.d.ts +1 -1
- package/lib/properties/valueArrayProperty.d.ts.map +1 -1
- package/lib/properties/valueArrayProperty.js +30 -29
- package/lib/properties/valueArrayProperty.js.map +1 -1
- package/lib/properties/valueMapProperty.d.ts.map +1 -1
- package/lib/properties/valueMapProperty.js +31 -29
- package/lib/properties/valueMapProperty.js.map +1 -1
- package/lib/properties/valueProperty.d.ts.map +1 -1
- package/lib/properties/valueProperty.js +11 -9
- package/lib/properties/valueProperty.js.map +1 -1
- package/lib/propertyFactory.d.ts.map +1 -1
- package/lib/propertyFactory.js +309 -252
- package/lib/propertyFactory.js.map +1 -1
- package/lib/propertyTemplate.d.ts +17 -17
- package/lib/propertyTemplate.d.ts.map +1 -1
- package/lib/propertyTemplate.js +64 -45
- package/lib/propertyTemplate.js.map +1 -1
- package/lib/propertyTemplateWrapper.d.ts.map +1 -1
- package/lib/propertyTemplateWrapper.js +40 -25
- package/lib/propertyTemplateWrapper.js.map +1 -1
- package/lib/propertyUtils.d.ts.map +1 -1
- package/lib/propertyUtils.js.map +1 -1
- package/package.json +28 -28
- package/src/index.d.ts +2750 -2681
package/dist/test/utils.spec.js
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @fileoverview In this file, we will test the utils described in /src/utils.js
|
|
8
8
|
*/
|
|
9
|
-
const { ChangeSet } = require(
|
|
10
|
-
const { Utils } = require(
|
|
11
|
-
const { MSG } = require(
|
|
12
|
-
const _ = require(
|
|
13
|
-
const { PropertyFactory } = require(
|
|
14
|
-
const { BaseProperty } = require(
|
|
15
|
-
const { NodeProperty } = require(
|
|
16
|
-
describe(
|
|
9
|
+
const { ChangeSet } = require("@fluid-experimental/property-changeset");
|
|
10
|
+
const { Utils } = require("@fluid-experimental/property-changeset");
|
|
11
|
+
const { MSG } = require("@fluid-experimental/property-common").constants;
|
|
12
|
+
const _ = require("lodash");
|
|
13
|
+
const { PropertyFactory } = require("..");
|
|
14
|
+
const { BaseProperty } = require("..");
|
|
15
|
+
const { NodeProperty } = require("../properties/nodeProperty");
|
|
16
|
+
describe("Utils", function () {
|
|
17
17
|
before(function () {
|
|
18
18
|
var TaskStatus = {
|
|
19
19
|
// inherits : 'Enum',
|
|
20
|
-
typeid:
|
|
20
|
+
typeid: "autodesk.test:utils.spec.task.status-1.0.0",
|
|
21
21
|
/* values : {
|
|
22
22
|
running : 'running',
|
|
23
23
|
created : 'created',
|
|
@@ -29,113 +29,129 @@ describe('Utils', function () {
|
|
|
29
29
|
};
|
|
30
30
|
// The subject property template to be tracked
|
|
31
31
|
var TaskSubject = {
|
|
32
|
-
inherits: [
|
|
33
|
-
typeid:
|
|
32
|
+
inherits: ["NodeProperty"],
|
|
33
|
+
typeid: "autodesk.test:utils.spec.task.subject-1.0.0",
|
|
34
34
|
properties: [
|
|
35
35
|
// {id: 'status', typeid: 'autodesk.test:utils_spec_status-1.0.0'},
|
|
36
|
-
{ id:
|
|
36
|
+
{ id: "errorMsg", typeid: "String" },
|
|
37
37
|
// {id: 'result', typeid: 'BaseProperty'},
|
|
38
|
-
{ id:
|
|
38
|
+
{ id: "progress", typeid: "Uint32", annotation: { min: 0, max: 100 } },
|
|
39
39
|
// {id: 'timeRemaining' , typeid : 'autodesk.test:utils_spec_datedelta-1.0.0'}
|
|
40
40
|
],
|
|
41
41
|
};
|
|
42
42
|
// The observer tracking subject(s)
|
|
43
43
|
var TaskObserver = {
|
|
44
|
-
inherits:
|
|
45
|
-
typeid:
|
|
44
|
+
inherits: "autodesk.test:utils.spec.task.subject-1.0.0",
|
|
45
|
+
typeid: "autodesk.test:utils.spec.task.observer-1.0.0",
|
|
46
46
|
properties: [
|
|
47
|
-
{ id:
|
|
48
|
-
{ id:
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
{ id: "name", typeid: "String" },
|
|
48
|
+
{ id: "creator", typeid: "autodesk.test:utils.spec.user-1.0.0" },
|
|
49
|
+
{
|
|
50
|
+
id: "subjects",
|
|
51
|
+
typeid: "autodesk.test:utils.spec.task.subjectentry-1.0.0",
|
|
52
|
+
context: "array",
|
|
53
|
+
},
|
|
54
|
+
{ id: "startTime", typeid: "autodesk.test:utils.spec.date-1.0.0" },
|
|
55
|
+
{ id: "endTime", typeid: "autodesk.test:utils.spec.date-1.0.0" },
|
|
52
56
|
],
|
|
53
57
|
};
|
|
54
58
|
// Subject entries passed in to the 'subjects' field of the task observer
|
|
55
59
|
var TaskSubjectEntries = {
|
|
56
|
-
typeid:
|
|
57
|
-
properties: [
|
|
58
|
-
{ id: 'path', typeid: 'String' },
|
|
59
|
-
],
|
|
60
|
+
typeid: "autodesk.test:utils.spec.task.subjectentry-1.0.0",
|
|
61
|
+
properties: [{ id: "path", typeid: "String" }],
|
|
60
62
|
};
|
|
61
63
|
// Example usage of task subjects to be tracked
|
|
62
64
|
var Sim = {
|
|
63
|
-
inherits: [
|
|
64
|
-
typeid:
|
|
65
|
+
inherits: ["NodeProperty"],
|
|
66
|
+
typeid: "autodesk.test:utils.spec.pan.sim-1.0.0",
|
|
65
67
|
properties: [
|
|
66
|
-
{ id:
|
|
67
|
-
{ id:
|
|
68
|
+
{ id: "costEstimated", typeid: "autodesk.test:utils.spec.task.subject-1.0.0" },
|
|
69
|
+
{ id: "costFinal", typeid: "autodesk.test:utils.spec.task.subject-1.0.0" },
|
|
68
70
|
// set by client to start or cancel the simulation
|
|
69
|
-
{ id:
|
|
70
|
-
{ id:
|
|
71
|
+
{ id: "start", typeid: "Bool", default: false },
|
|
72
|
+
{ id: "cancel", typeid: "Bool", default: false },
|
|
71
73
|
// { id: 'inputs' , typeid: 'autodesk.test:utils_spec_pan.input-1.0.0' },
|
|
72
|
-
{ id:
|
|
73
|
-
{ id:
|
|
74
|
+
{ id: "thermalResults", typeid: "autodesk.test:utils.spec.task.subject-1.0.0" },
|
|
75
|
+
{ id: "mechanicalResults", typeid: "autodesk.test:utils.spec.task.subject-1.0.0" },
|
|
74
76
|
],
|
|
75
77
|
};
|
|
76
78
|
var nestedTemplate = {
|
|
77
|
-
typeid:
|
|
78
|
-
properties: [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
typeid: "autodesk.tests:nestedTemplate-1.0.0",
|
|
80
|
+
properties: [
|
|
81
|
+
{
|
|
82
|
+
id: "a",
|
|
83
|
+
typeid: "String",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "b",
|
|
87
|
+
typeid: "String",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "c",
|
|
91
|
+
properties: [
|
|
92
|
+
{
|
|
93
|
+
id: "myNestedProp",
|
|
94
|
+
typeid: "autodesk.test:utils.spec.task.subject-1.0.0",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
91
99
|
};
|
|
92
100
|
var QuoatablePropertyObject = {
|
|
93
|
-
typeid:
|
|
94
|
-
properties: [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
typeid: "autodesk.tests:property.with.quotable.characters-1.0.0",
|
|
102
|
+
properties: [
|
|
103
|
+
{
|
|
104
|
+
id: "simple_property",
|
|
105
|
+
typeid: "String",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "test.property",
|
|
109
|
+
typeid: "String",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
101
112
|
id: 'test"property"',
|
|
102
|
-
typeid:
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
typeid: "String",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "test[property]",
|
|
117
|
+
properties: [
|
|
118
|
+
{
|
|
119
|
+
id: ".property.",
|
|
120
|
+
properties: [
|
|
121
|
+
{
|
|
122
|
+
id: "test",
|
|
123
|
+
typeid: "String",
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
113
130
|
};
|
|
114
131
|
var ContainedTemplate = {
|
|
115
|
-
typeid:
|
|
116
|
-
properties: [
|
|
117
|
-
{ id: 'error"Msg"', typeid: 'String' },
|
|
118
|
-
],
|
|
132
|
+
typeid: "autodesk.test:utilsTestContained-1.0.0",
|
|
133
|
+
properties: [{ id: 'error"Msg"', typeid: "String" }],
|
|
119
134
|
};
|
|
120
135
|
var StaticNodeChild = {
|
|
121
|
-
typeid:
|
|
122
|
-
inherits: [
|
|
123
|
-
properties: [
|
|
124
|
-
{ id: 'nodeProperty', typeid: 'NodeProperty' },
|
|
125
|
-
],
|
|
136
|
+
typeid: "autodesk.test:staticNodeChild-1.0.0",
|
|
137
|
+
inherits: ["NodeProperty"],
|
|
138
|
+
properties: [{ id: "nodeProperty", typeid: "NodeProperty" }],
|
|
126
139
|
};
|
|
127
140
|
var ParentTemplate = {
|
|
128
|
-
typeid:
|
|
141
|
+
typeid: "autodesk.test:utilsTestParent-1.0.0",
|
|
129
142
|
properties: [
|
|
130
|
-
{ id:
|
|
131
|
-
{ id:
|
|
143
|
+
{ id: "errorMsg", typeid: "String" },
|
|
144
|
+
{ id: "progress", typeid: "Uint32" },
|
|
132
145
|
{
|
|
133
|
-
id:
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
id: "nested",
|
|
147
|
+
properties: [{ id: 'en"t"ry', typeid: "String" }],
|
|
148
|
+
},
|
|
149
|
+
{ id: "contained", typeid: "autodesk.test:utilsTestContained-1.0.0" },
|
|
150
|
+
{
|
|
151
|
+
id: "containedMap",
|
|
152
|
+
typeid: "autodesk.test:utilsTestContained-1.0.0",
|
|
153
|
+
context: "map",
|
|
136
154
|
},
|
|
137
|
-
{ id: 'contained', typeid: 'autodesk.test:utilsTestContained-1.0.0' },
|
|
138
|
-
{ id: 'containedMap', typeid: 'autodesk.test:utilsTestContained-1.0.0', context: 'map' },
|
|
139
155
|
],
|
|
140
156
|
};
|
|
141
157
|
PropertyFactory._reregister(TaskStatus);
|
|
@@ -149,108 +165,114 @@ describe('Utils', function () {
|
|
|
149
165
|
PropertyFactory._reregister(ContainedTemplate);
|
|
150
166
|
PropertyFactory._reregister(StaticNodeChild);
|
|
151
167
|
});
|
|
152
|
-
describe(
|
|
168
|
+
describe("Utils.traverseChangeSetRecursively", function () {
|
|
153
169
|
var testRoot, contexts, namedNodePropForSet;
|
|
154
|
-
it(
|
|
155
|
-
testRoot = PropertyFactory.create(
|
|
156
|
-
testRoot.insert(
|
|
157
|
-
testRoot.insert('test"Templated"Property', PropertyFactory.create(
|
|
158
|
-
testRoot
|
|
159
|
-
|
|
170
|
+
it("should report correctly for inserts", function () {
|
|
171
|
+
testRoot = PropertyFactory.create("NodeProperty");
|
|
172
|
+
testRoot.insert("string", PropertyFactory.create("String"));
|
|
173
|
+
testRoot.insert('test"Templated"Property', PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0"));
|
|
174
|
+
testRoot
|
|
175
|
+
.resolvePath('"test\\"Templated\\"Property".containedMap')
|
|
176
|
+
.insert("entry", PropertyFactory.create("autodesk.test:utilsTestContained-1.0.0"));
|
|
177
|
+
testRoot.insert("reference", PropertyFactory.create("Reference<String>"));
|
|
160
178
|
// Test an array with a primitive
|
|
161
|
-
testRoot.insert(
|
|
179
|
+
testRoot.insert("floatArray", PropertyFactory.create("Float32", "array"));
|
|
162
180
|
testRoot._properties.floatArray.insertRange(0, [1, 2, 3, 4, 5]);
|
|
163
181
|
// Test an array with a complex type
|
|
164
|
-
testRoot.insert(
|
|
165
|
-
var arrayNode = PropertyFactory.create(
|
|
182
|
+
testRoot.insert("array", PropertyFactory.create("array<>"));
|
|
183
|
+
var arrayNode = PropertyFactory.create("NodeProperty");
|
|
166
184
|
testRoot._properties.array.push(arrayNode);
|
|
167
|
-
arrayNode.insert(
|
|
185
|
+
arrayNode.insert("string", PropertyFactory.create("String"));
|
|
168
186
|
// Test a map with a primitive
|
|
169
|
-
testRoot.insert(
|
|
170
|
-
testRoot._properties.floatMap.insert(
|
|
171
|
-
testRoot._properties.floatMap.insert(
|
|
172
|
-
testRoot._properties.floatMap.insert(
|
|
187
|
+
testRoot.insert("floatMap", PropertyFactory.create("Float32", "map"));
|
|
188
|
+
testRoot._properties.floatMap.insert("test", 1);
|
|
189
|
+
testRoot._properties.floatMap.insert("test2", 2);
|
|
190
|
+
testRoot._properties.floatMap.insert("test3", 3);
|
|
173
191
|
// Test a map with complex types
|
|
174
|
-
testRoot.insert(
|
|
192
|
+
testRoot.insert("map", PropertyFactory.create("map<>"));
|
|
175
193
|
// add members
|
|
176
194
|
// Simple string
|
|
177
|
-
testRoot._properties.map.insert(
|
|
195
|
+
testRoot._properties.map.insert("string", PropertyFactory.create("String"));
|
|
178
196
|
// String with name that has to be escaped
|
|
179
|
-
testRoot._properties.map.insert('s"tr"ing', PropertyFactory.create(
|
|
197
|
+
testRoot._properties.map.insert('s"tr"ing', PropertyFactory.create("String"));
|
|
180
198
|
// A map in a map
|
|
181
|
-
testRoot._properties.map.insert(
|
|
182
|
-
testRoot._properties.map.get(
|
|
199
|
+
testRoot._properties.map.insert("map", PropertyFactory.create("map<>"));
|
|
200
|
+
testRoot._properties.map.get("map").insert("string", PropertyFactory.create("String"));
|
|
183
201
|
// An array in a map
|
|
184
|
-
testRoot._properties.map.insert(
|
|
185
|
-
testRoot._properties.map.get(
|
|
186
|
-
testRoot._properties.map
|
|
202
|
+
testRoot._properties.map.insert("array", PropertyFactory.create("array<>"));
|
|
203
|
+
testRoot._properties.map.get("array").insert(0, PropertyFactory.create("NodeProperty"));
|
|
204
|
+
testRoot._properties.map
|
|
205
|
+
.get("array")
|
|
206
|
+
.get(0)
|
|
207
|
+
.insert("string", PropertyFactory.create("String"));
|
|
187
208
|
// A composed property
|
|
188
|
-
testRoot._properties.map.insert(
|
|
209
|
+
testRoot._properties.map.insert("testParent", PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0"));
|
|
189
210
|
// A NodeProperty
|
|
190
|
-
testRoot._properties.map.insert(
|
|
191
|
-
testRoot._properties.map
|
|
211
|
+
testRoot._properties.map.insert("nodeProperty", PropertyFactory.create("NodeProperty"));
|
|
212
|
+
testRoot._properties.map
|
|
213
|
+
.get("nodeProperty")
|
|
214
|
+
.insert("string", PropertyFactory.create("String"));
|
|
192
215
|
// Test a set property
|
|
193
|
-
testRoot.insert(
|
|
194
|
-
namedNodePropForSet = PropertyFactory.create(
|
|
216
|
+
testRoot.insert("set", PropertyFactory.create("set<>"));
|
|
217
|
+
namedNodePropForSet = PropertyFactory.create("NamedNodeProperty");
|
|
195
218
|
testRoot._properties.set.insert(namedNodePropForSet);
|
|
196
|
-
namedNodePropForSet.insert(
|
|
219
|
+
namedNodePropForSet.insert("string", PropertyFactory.create("String"));
|
|
197
220
|
contexts = [];
|
|
198
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
221
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: false }), {
|
|
199
222
|
preCallback: function (in_context) {
|
|
200
223
|
// Do some basic sanity checks
|
|
201
|
-
var node = testRoot.resolvePath(in_context.getFullPath() +
|
|
224
|
+
var node = testRoot.resolvePath(in_context.getFullPath() + "*");
|
|
202
225
|
expect(node).to.be.instanceof(BaseProperty);
|
|
203
226
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
204
|
-
if (in_context._fullPath !==
|
|
205
|
-
expect(in_context.getOperationType()).to.equal(
|
|
227
|
+
if (in_context._fullPath !== "") {
|
|
228
|
+
expect(in_context.getOperationType()).to.equal("insert");
|
|
206
229
|
}
|
|
207
230
|
else {
|
|
208
|
-
expect(in_context.getOperationType()).to.equal(
|
|
231
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
209
232
|
}
|
|
210
233
|
contexts.push(in_context.clone());
|
|
211
234
|
},
|
|
212
235
|
});
|
|
213
236
|
expect(contexts.length).to.equal(38);
|
|
214
237
|
});
|
|
215
|
-
it(
|
|
238
|
+
it("should work for modifications of primitive types", function () {
|
|
216
239
|
// Clean the old modifications
|
|
217
240
|
testRoot.cleanDirty();
|
|
218
241
|
var modifiedStringCount = 0;
|
|
219
242
|
for (var i = 0; i < contexts.length; i++) {
|
|
220
243
|
var modifyNode = testRoot.resolvePath(contexts[i].getFullPath());
|
|
221
244
|
// modify strings
|
|
222
|
-
if (contexts[i].getTypeid() ===
|
|
223
|
-
modifyNode.
|
|
224
|
-
modifyNode.setValue('modified');
|
|
245
|
+
if (contexts[i].getTypeid() === "String" && modifyNode.getId() !== "guid") {
|
|
246
|
+
modifyNode.setValue("modified");
|
|
225
247
|
modifiedStringCount++;
|
|
226
248
|
}
|
|
227
249
|
// modify float arrays
|
|
228
|
-
if (contexts[i].getTypeid() ===
|
|
250
|
+
if (contexts[i].getTypeid() === "array<Float32>") {
|
|
229
251
|
modifyNode.push(15);
|
|
230
252
|
}
|
|
231
253
|
}
|
|
232
254
|
// modify a float map
|
|
233
255
|
// note: set removed, setValue not implemented yet
|
|
234
|
-
testRoot._properties.floatMap.set(
|
|
235
|
-
testRoot._properties.floatMap.set(
|
|
256
|
+
testRoot._properties.floatMap.set("test", 5);
|
|
257
|
+
testRoot._properties.floatMap.set("new_test", 7);
|
|
236
258
|
var reportedStringModifiedCount = 0;
|
|
237
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
259
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
238
260
|
preCallback: function (in_context) {
|
|
239
261
|
// Do some basic sanity checks
|
|
240
262
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
241
263
|
expect(node).to.be.instanceof(BaseProperty);
|
|
242
264
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
243
|
-
expect(in_context.getOperationType()).to.equal(
|
|
244
|
-
if (node.getTypeid() ===
|
|
265
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
266
|
+
if (node.getTypeid() === "String") {
|
|
245
267
|
reportedStringModifiedCount++;
|
|
246
|
-
expect(in_context.getNestedChangeSet()).to.equal(
|
|
268
|
+
expect(in_context.getNestedChangeSet()).to.equal("modified");
|
|
247
269
|
}
|
|
248
|
-
if (in_context.getTypeid() ===
|
|
270
|
+
if (in_context.getTypeid() === "array<Float32>") {
|
|
249
271
|
expect(in_context.getNestedChangeSet()).to.deep.equal({
|
|
250
272
|
insert: [[5, [15]]],
|
|
251
273
|
});
|
|
252
274
|
}
|
|
253
|
-
if (in_context.getTypeid() ===
|
|
275
|
+
if (in_context.getTypeid() === "map<Float32>") {
|
|
254
276
|
expect(in_context.getNestedChangeSet()).to.deep.equal({
|
|
255
277
|
insert: {
|
|
256
278
|
new_test: 7,
|
|
@@ -265,179 +287,174 @@ describe('Utils', function () {
|
|
|
265
287
|
// Make sure all modified strings have been reported
|
|
266
288
|
expect(reportedStringModifiedCount).to.equal(modifiedStringCount);
|
|
267
289
|
});
|
|
268
|
-
it(
|
|
290
|
+
it("should work for inserts in strings", function () {
|
|
269
291
|
// Clean the old modifications
|
|
270
292
|
testRoot.cleanDirty();
|
|
271
293
|
for (var i = 0; i < contexts.length; i++) {
|
|
272
|
-
if (contexts[i].getTypeid() ===
|
|
294
|
+
if (contexts[i].getTypeid() === "String") {
|
|
273
295
|
var modifyNode = testRoot.resolvePath(contexts[i].getFullPath());
|
|
274
|
-
if (modifyNode.getId() !==
|
|
275
|
-
modifyNode.insert(3,
|
|
296
|
+
if (modifyNode.getId() !== "guid") {
|
|
297
|
+
modifyNode.insert(3, "_inserted_");
|
|
276
298
|
}
|
|
277
299
|
}
|
|
278
300
|
}
|
|
279
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
301
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
280
302
|
preCallback: function (in_context) {
|
|
281
303
|
// Do some basic sanity checks
|
|
282
304
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
283
305
|
expect(node).to.be.instanceof(BaseProperty);
|
|
284
306
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
285
|
-
expect(in_context.getOperationType()).to.equal(
|
|
286
|
-
if (node.getTypeid() ===
|
|
307
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
308
|
+
if (node.getTypeid() === "String") {
|
|
287
309
|
expect(in_context.getNestedChangeSet()).to.deep.equal({
|
|
288
|
-
insert: [[3,
|
|
310
|
+
insert: [[3, "_inserted_"]],
|
|
289
311
|
});
|
|
290
312
|
}
|
|
291
313
|
},
|
|
292
314
|
});
|
|
293
315
|
});
|
|
294
|
-
it(
|
|
316
|
+
it("should work for inserts in arrays", function () {
|
|
295
317
|
// Clean the old modifications
|
|
296
318
|
testRoot.cleanDirty();
|
|
297
|
-
var newArrayNode = PropertyFactory.create(
|
|
319
|
+
var newArrayNode = PropertyFactory.create("NodeProperty");
|
|
298
320
|
testRoot._properties.array.push(newArrayNode);
|
|
299
|
-
newArrayNode.insert(
|
|
300
|
-
newArrayNode._properties.string.value =
|
|
301
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
321
|
+
newArrayNode.insert("string", PropertyFactory.create("String"));
|
|
322
|
+
newArrayNode._properties.string.value = "test";
|
|
323
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
302
324
|
preCallback: function (in_context) {
|
|
303
325
|
// Do some basic sanity checks
|
|
304
326
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
305
327
|
expect(node).to.be.instanceof(BaseProperty);
|
|
306
328
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
307
|
-
if (in_context.getFullPath() !==
|
|
308
|
-
in_context.
|
|
309
|
-
expect(in_context.getOperationType()).to.equal('insert');
|
|
329
|
+
if (in_context.getFullPath() !== "" && in_context.getFullPath() !== "array") {
|
|
330
|
+
expect(in_context.getOperationType()).to.equal("insert");
|
|
310
331
|
}
|
|
311
332
|
else {
|
|
312
|
-
expect(in_context.getOperationType()).to.equal(
|
|
333
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
313
334
|
}
|
|
314
|
-
if (node.getTypeid() ===
|
|
315
|
-
expect(in_context.getNestedChangeSet()).to.equal(
|
|
335
|
+
if (node.getTypeid() === "String") {
|
|
336
|
+
expect(in_context.getNestedChangeSet()).to.equal("test");
|
|
316
337
|
}
|
|
317
338
|
},
|
|
318
339
|
});
|
|
319
340
|
});
|
|
320
|
-
it(
|
|
341
|
+
it("should work for inserts in sets", function () {
|
|
321
342
|
// Clean the old modifications
|
|
322
343
|
testRoot.cleanDirty();
|
|
323
|
-
var newSetNode = PropertyFactory.create(
|
|
344
|
+
var newSetNode = PropertyFactory.create("NamedNodeProperty");
|
|
324
345
|
testRoot._properties.set.insert(newSetNode);
|
|
325
|
-
newSetNode.insert(
|
|
326
|
-
newSetNode._properties.string.setValue(
|
|
327
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
346
|
+
newSetNode.insert("string", PropertyFactory.create("String"));
|
|
347
|
+
newSetNode._properties.string.setValue("test");
|
|
348
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
328
349
|
preCallback: function (in_context) {
|
|
329
350
|
// Do some basic sanity checks
|
|
330
351
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
331
352
|
expect(node).to.be.instanceof(BaseProperty);
|
|
332
353
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
333
|
-
if (in_context.getFullPath() !==
|
|
334
|
-
in_context.
|
|
335
|
-
expect(in_context.getOperationType()).to.equal('insert');
|
|
354
|
+
if (in_context.getFullPath() !== "" && in_context.getFullPath() !== "set") {
|
|
355
|
+
expect(in_context.getOperationType()).to.equal("insert");
|
|
336
356
|
}
|
|
337
357
|
else {
|
|
338
|
-
expect(in_context.getOperationType()).to.equal(
|
|
358
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
339
359
|
}
|
|
340
|
-
if (node.getTypeid() ===
|
|
360
|
+
if (node.getTypeid() === "String") {
|
|
341
361
|
expect(in_context.getNestedChangeSet()).to.equal(node.value);
|
|
342
362
|
}
|
|
343
363
|
},
|
|
344
364
|
});
|
|
345
365
|
});
|
|
346
|
-
it(
|
|
366
|
+
it("should work for node property removals", function () {
|
|
347
367
|
// Clean the old modifications
|
|
348
368
|
testRoot.cleanDirty();
|
|
349
369
|
var removedStrings = [];
|
|
350
370
|
for (var i = 0; i < contexts.length; i++) {
|
|
351
|
-
if (contexts[i].getTypeid() ===
|
|
371
|
+
if (contexts[i].getTypeid() === "NodeProperty") {
|
|
352
372
|
var modifyNode = testRoot.resolvePath(contexts[i].getFullPath());
|
|
353
373
|
removedStrings.push(modifyNode._properties.string.getAbsolutePath());
|
|
354
|
-
modifyNode.remove(
|
|
374
|
+
modifyNode.remove("string");
|
|
355
375
|
}
|
|
356
376
|
}
|
|
357
377
|
var actualStringRemoveCount = 0;
|
|
358
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
378
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
359
379
|
preCallback: function (in_context) {
|
|
360
380
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
361
381
|
if (node) {
|
|
362
|
-
expect(in_context.getOperationType()).to.equal(
|
|
382
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
363
383
|
}
|
|
364
384
|
else {
|
|
365
|
-
expect(in_context.getOperationType()).to.equal(
|
|
366
|
-
expect(removedStrings.indexOf(
|
|
385
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
386
|
+
expect(removedStrings.indexOf("/" + in_context.getFullPath())).to.not.equal(-1);
|
|
367
387
|
actualStringRemoveCount++;
|
|
368
388
|
}
|
|
369
389
|
},
|
|
370
390
|
});
|
|
371
391
|
expect(removedStrings.length).to.equal(actualStringRemoveCount);
|
|
372
392
|
});
|
|
373
|
-
it(
|
|
393
|
+
it("should work for array removals", function () {
|
|
374
394
|
// Clean the old modifications
|
|
375
395
|
testRoot.cleanDirty();
|
|
376
396
|
testRoot._properties.array.removeRange(0, 2);
|
|
377
397
|
var arrayRemovalCount = 0;
|
|
378
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
398
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
379
399
|
preCallback: function (in_context) {
|
|
380
|
-
if (in_context.getFullPath() ===
|
|
381
|
-
in_context.
|
|
382
|
-
expect(in_context.getOperationType()).to.equal('modify');
|
|
400
|
+
if (in_context.getFullPath() === "" || in_context.getFullPath() === "array") {
|
|
401
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
383
402
|
}
|
|
384
403
|
else {
|
|
385
|
-
expect(in_context.getOperationType()).to.equal(
|
|
404
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
386
405
|
arrayRemovalCount++;
|
|
387
406
|
}
|
|
388
407
|
},
|
|
389
408
|
});
|
|
390
409
|
expect(arrayRemovalCount).to.equal(2);
|
|
391
410
|
});
|
|
392
|
-
it(
|
|
411
|
+
it("should work for map removals", function () {
|
|
393
412
|
// Clean the old modifications
|
|
394
413
|
testRoot.cleanDirty();
|
|
395
|
-
testRoot._properties.map.remove(
|
|
414
|
+
testRoot._properties.map.remove("string");
|
|
396
415
|
var mapRemovalCount = 0;
|
|
397
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
416
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
398
417
|
preCallback: function (in_context) {
|
|
399
|
-
if (in_context.getFullPath() ===
|
|
400
|
-
in_context.
|
|
401
|
-
expect(in_context.getOperationType()).to.equal('modify');
|
|
418
|
+
if (in_context.getFullPath() === "" || in_context.getFullPath() === "map") {
|
|
419
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
402
420
|
}
|
|
403
421
|
else {
|
|
404
|
-
expect(in_context.getOperationType()).to.equal(
|
|
422
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
405
423
|
mapRemovalCount++;
|
|
406
424
|
}
|
|
407
425
|
},
|
|
408
426
|
});
|
|
409
427
|
expect(mapRemovalCount).to.equal(1);
|
|
410
428
|
});
|
|
411
|
-
it(
|
|
429
|
+
it("should work for set removals", function () {
|
|
412
430
|
// Clean the old modifications
|
|
413
431
|
testRoot.cleanDirty();
|
|
414
432
|
testRoot._properties.set.remove(namedNodePropForSet);
|
|
415
433
|
var setRemovalCount = 0;
|
|
416
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
434
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
417
435
|
preCallback: function (in_context) {
|
|
418
|
-
if (in_context.getFullPath() ===
|
|
419
|
-
in_context.
|
|
420
|
-
expect(in_context.getOperationType()).to.equal('modify');
|
|
436
|
+
if (in_context.getFullPath() === "" || in_context.getFullPath() === "set") {
|
|
437
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
421
438
|
}
|
|
422
439
|
else {
|
|
423
|
-
expect(in_context.getOperationType()).to.equal(
|
|
440
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
424
441
|
setRemovalCount++;
|
|
425
442
|
}
|
|
426
443
|
},
|
|
427
444
|
});
|
|
428
445
|
expect(setRemovalCount).to.equal(1);
|
|
429
446
|
});
|
|
430
|
-
it(
|
|
431
|
-
testRoot.insert(
|
|
432
|
-
var namedNodePropForSet1 = PropertyFactory.create(
|
|
433
|
-
var namedNodePropForSet2 = PropertyFactory.create(
|
|
434
|
-
var namedNodePropForSet3 = PropertyFactory.create(
|
|
447
|
+
it("should clone the context correctly", function () {
|
|
448
|
+
testRoot.insert("setClone", PropertyFactory.create("set<>"));
|
|
449
|
+
var namedNodePropForSet1 = PropertyFactory.create("NamedNodeProperty");
|
|
450
|
+
var namedNodePropForSet2 = PropertyFactory.create("NamedNodeProperty");
|
|
451
|
+
var namedNodePropForSet3 = PropertyFactory.create("NamedNodeProperty");
|
|
435
452
|
testRoot._properties.setClone.insert(namedNodePropForSet1);
|
|
436
453
|
testRoot._properties.setClone.insert(namedNodePropForSet2);
|
|
437
454
|
testRoot._properties.setClone.insert(namedNodePropForSet3);
|
|
438
|
-
namedNodePropForSet1.insert(
|
|
439
|
-
namedNodePropForSet2.insert(
|
|
440
|
-
namedNodePropForSet3.insert(
|
|
455
|
+
namedNodePropForSet1.insert("string1", PropertyFactory.create("String"));
|
|
456
|
+
namedNodePropForSet2.insert("string2", PropertyFactory.create("String"));
|
|
457
|
+
namedNodePropForSet3.insert("string3", PropertyFactory.create("String"));
|
|
441
458
|
// Clean the old modifications
|
|
442
459
|
testRoot.cleanDirty();
|
|
443
460
|
testRoot._properties.setClone.remove(namedNodePropForSet1);
|
|
@@ -445,14 +462,14 @@ describe('Utils', function () {
|
|
|
445
462
|
testRoot._properties.setClone.remove(namedNodePropForSet3);
|
|
446
463
|
var setRemovalCount = 0;
|
|
447
464
|
var contextCloneCount = 0;
|
|
448
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
465
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
449
466
|
preCallback: function (in_context) {
|
|
450
|
-
if (in_context.getFullPath() ===
|
|
451
|
-
in_context.getFullPath() ===
|
|
452
|
-
expect(in_context.getOperationType()).to.equal(
|
|
467
|
+
if (in_context.getFullPath() === "" ||
|
|
468
|
+
in_context.getFullPath() === "setClone") {
|
|
469
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
453
470
|
}
|
|
454
471
|
else {
|
|
455
|
-
expect(in_context.getOperationType()).to.equal(
|
|
472
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
456
473
|
setRemovalCount++;
|
|
457
474
|
}
|
|
458
475
|
var cloneContext = in_context.clone();
|
|
@@ -463,79 +480,86 @@ describe('Utils', function () {
|
|
|
463
480
|
expect(setRemovalCount).to.equal(3);
|
|
464
481
|
expect(contextCloneCount >= 3).to.be.true; // we should clone at least 3 times (probably more)
|
|
465
482
|
});
|
|
466
|
-
it(
|
|
483
|
+
it("@regression should work when replacing a map element", function () {
|
|
467
484
|
// Clean the old modifications
|
|
468
485
|
testRoot.cleanDirty();
|
|
469
|
-
testRoot._properties.map.set(
|
|
486
|
+
testRoot._properties.map.set("nodeProperty", PropertyFactory.create("NamedNodeProperty"));
|
|
470
487
|
var operationtypes = [];
|
|
471
|
-
Utils.traverseChangeSetRecursively(testRoot.serialize({
|
|
488
|
+
Utils.traverseChangeSetRecursively(testRoot.serialize({ dirtyOnly: true }), {
|
|
472
489
|
preCallback: function (in_context) {
|
|
473
490
|
// expect operations to be 'remove' and 'insert'
|
|
474
|
-
if (in_context.getFullPath() ===
|
|
491
|
+
if (in_context.getFullPath() === "map[nodeProperty]") {
|
|
475
492
|
operationtypes.push(in_context.getOperationType());
|
|
476
493
|
}
|
|
477
494
|
},
|
|
478
495
|
});
|
|
479
|
-
expect(operationtypes).to.deep.equal([
|
|
496
|
+
expect(operationtypes).to.deep.equal(["remove", "insert"]);
|
|
480
497
|
});
|
|
481
498
|
});
|
|
482
|
-
describe(
|
|
499
|
+
describe("Utils.traverseChangeSetRecursivelyAsync", function () {
|
|
483
500
|
var testRoot, contexts, namedNodePropForSet;
|
|
484
|
-
it(
|
|
485
|
-
testRoot = PropertyFactory.create(
|
|
486
|
-
testRoot.insert(
|
|
487
|
-
testRoot.insert('test"Templated"Property', PropertyFactory.create(
|
|
488
|
-
testRoot
|
|
489
|
-
|
|
501
|
+
it("should report correctly for inserts", function (done) {
|
|
502
|
+
testRoot = PropertyFactory.create("NodeProperty");
|
|
503
|
+
testRoot.insert("string", PropertyFactory.create("String"));
|
|
504
|
+
testRoot.insert('test"Templated"Property', PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0"));
|
|
505
|
+
testRoot
|
|
506
|
+
.resolvePath('"test\\"Templated\\"Property".containedMap')
|
|
507
|
+
.insert("entry", PropertyFactory.create("autodesk.test:utilsTestContained-1.0.0"));
|
|
508
|
+
testRoot.insert("reference", PropertyFactory.create("Reference<String>"));
|
|
490
509
|
// Test an array with a primitive
|
|
491
|
-
testRoot.insert(
|
|
510
|
+
testRoot.insert("floatArray", PropertyFactory.create("Float32", "array"));
|
|
492
511
|
testRoot._properties.floatArray.insertRange(0, [1, 2, 3, 4, 5]);
|
|
493
512
|
// Test an array with a complex type
|
|
494
|
-
testRoot.insert(
|
|
495
|
-
var arrayNode = PropertyFactory.create(
|
|
513
|
+
testRoot.insert("array", PropertyFactory.create("array<>"));
|
|
514
|
+
var arrayNode = PropertyFactory.create("NodeProperty");
|
|
496
515
|
testRoot._properties.array.push(arrayNode);
|
|
497
|
-
arrayNode.insert(
|
|
516
|
+
arrayNode.insert("string", PropertyFactory.create("String"));
|
|
498
517
|
// Test a map with a primitive
|
|
499
|
-
testRoot.insert(
|
|
500
|
-
testRoot._properties.floatMap.insert(
|
|
501
|
-
testRoot._properties.floatMap.insert(
|
|
502
|
-
testRoot._properties.floatMap.insert(
|
|
518
|
+
testRoot.insert("floatMap", PropertyFactory.create("Float32", "map"));
|
|
519
|
+
testRoot._properties.floatMap.insert("test", 1);
|
|
520
|
+
testRoot._properties.floatMap.insert("test2", 2);
|
|
521
|
+
testRoot._properties.floatMap.insert("test3", 3);
|
|
503
522
|
// Test a map with complex types
|
|
504
|
-
testRoot.insert(
|
|
523
|
+
testRoot.insert("map", PropertyFactory.create("map<>"));
|
|
505
524
|
// add members
|
|
506
525
|
// Simple string
|
|
507
|
-
testRoot._properties.map.insert(
|
|
526
|
+
testRoot._properties.map.insert("string", PropertyFactory.create("String"));
|
|
508
527
|
// String with name that has to be escaped
|
|
509
|
-
testRoot._properties.map.insert('s"tr"ing', PropertyFactory.create(
|
|
528
|
+
testRoot._properties.map.insert('s"tr"ing', PropertyFactory.create("String"));
|
|
510
529
|
// A map in a map
|
|
511
|
-
testRoot._properties.map.insert(
|
|
512
|
-
testRoot._properties.map.get(
|
|
530
|
+
testRoot._properties.map.insert("map", PropertyFactory.create("map<>"));
|
|
531
|
+
testRoot._properties.map.get("map").insert("string", PropertyFactory.create("String"));
|
|
513
532
|
// An array in a map
|
|
514
|
-
testRoot._properties.map.insert(
|
|
515
|
-
testRoot._properties.map.get(
|
|
516
|
-
testRoot._properties.map
|
|
533
|
+
testRoot._properties.map.insert("array", PropertyFactory.create("array<>"));
|
|
534
|
+
testRoot._properties.map.get("array").insert(0, PropertyFactory.create("NodeProperty"));
|
|
535
|
+
testRoot._properties.map
|
|
536
|
+
.get("array")
|
|
537
|
+
.get(0)
|
|
538
|
+
.insert("string", PropertyFactory.create("String"));
|
|
517
539
|
// A composed property
|
|
518
|
-
testRoot._properties.map.insert(
|
|
540
|
+
testRoot._properties.map.insert("testParent", PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0"));
|
|
519
541
|
// A NodeProperty
|
|
520
|
-
testRoot._properties.map.insert(
|
|
521
|
-
testRoot._properties.map
|
|
542
|
+
testRoot._properties.map.insert("nodeProperty", PropertyFactory.create("NodeProperty"));
|
|
543
|
+
testRoot._properties.map
|
|
544
|
+
.get("nodeProperty")
|
|
545
|
+
.insert("string", PropertyFactory.create("String"));
|
|
522
546
|
// Test a set property
|
|
523
|
-
testRoot.insert(
|
|
524
|
-
namedNodePropForSet = PropertyFactory.create(
|
|
547
|
+
testRoot.insert("set", PropertyFactory.create("set<>"));
|
|
548
|
+
namedNodePropForSet = PropertyFactory.create("NamedNodeProperty");
|
|
525
549
|
testRoot._properties.set.insert(namedNodePropForSet);
|
|
526
|
-
namedNodePropForSet.insert(
|
|
550
|
+
namedNodePropForSet.insert("string", PropertyFactory.create("String"));
|
|
527
551
|
contexts = [];
|
|
528
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
552
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: false }), {
|
|
529
553
|
preCallback: function (in_context, cb) {
|
|
530
554
|
// Do some basic sanity checks
|
|
531
|
-
var node = testRoot.resolvePath(in_context.getFullPath() +
|
|
555
|
+
var node = testRoot.resolvePath(in_context.getFullPath() + "*");
|
|
532
556
|
expect(node).to.be.instanceof(BaseProperty);
|
|
533
557
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
534
|
-
if (in_context._fullPath !==
|
|
535
|
-
expect(in_context.getOperationType()).to.equal(
|
|
558
|
+
if (in_context._fullPath !== "") {
|
|
559
|
+
expect(in_context.getOperationType()).to.equal("insert");
|
|
536
560
|
}
|
|
537
561
|
else {
|
|
538
|
-
expect(in_context.getOperationType()).to.equal(
|
|
562
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
539
563
|
}
|
|
540
564
|
contexts.push(in_context.clone());
|
|
541
565
|
setImmediate(cb);
|
|
@@ -545,45 +569,44 @@ describe('Utils', function () {
|
|
|
545
569
|
done();
|
|
546
570
|
});
|
|
547
571
|
});
|
|
548
|
-
it(
|
|
572
|
+
it("should work for modifications of primitive types", function (done) {
|
|
549
573
|
// Clean the old modifications
|
|
550
574
|
testRoot.cleanDirty();
|
|
551
575
|
var modifiedStringCount = 0;
|
|
552
576
|
for (var i = 0; i < contexts.length; i++) {
|
|
553
577
|
var modifyNode = testRoot.resolvePath(contexts[i].getFullPath());
|
|
554
578
|
// modify strings
|
|
555
|
-
if (contexts[i].getTypeid() ===
|
|
556
|
-
modifyNode.
|
|
557
|
-
modifyNode.setValue('modified');
|
|
579
|
+
if (contexts[i].getTypeid() === "String" && modifyNode.getId() !== "guid") {
|
|
580
|
+
modifyNode.setValue("modified");
|
|
558
581
|
modifiedStringCount++;
|
|
559
582
|
}
|
|
560
583
|
// modify float arrays
|
|
561
|
-
if (contexts[i].getTypeid() ===
|
|
584
|
+
if (contexts[i].getTypeid() === "array<Float32>") {
|
|
562
585
|
modifyNode.push(15);
|
|
563
586
|
}
|
|
564
587
|
}
|
|
565
588
|
// modify a float map
|
|
566
589
|
// note: set removed, setValue not implemented yet
|
|
567
|
-
testRoot._properties.floatMap.set(
|
|
568
|
-
testRoot._properties.floatMap.set(
|
|
590
|
+
testRoot._properties.floatMap.set("test", 5);
|
|
591
|
+
testRoot._properties.floatMap.set("new_test", 7);
|
|
569
592
|
var reportedStringModifiedCount = 0;
|
|
570
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
593
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
571
594
|
preCallback: function (in_context, cb) {
|
|
572
595
|
// Do some basic sanity checks
|
|
573
596
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
574
597
|
expect(node).to.be.instanceof(BaseProperty);
|
|
575
598
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
576
|
-
expect(in_context.getOperationType()).to.equal(
|
|
577
|
-
if (node.getTypeid() ===
|
|
599
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
600
|
+
if (node.getTypeid() === "String") {
|
|
578
601
|
reportedStringModifiedCount++;
|
|
579
|
-
expect(in_context.getNestedChangeSet()).to.equal(
|
|
602
|
+
expect(in_context.getNestedChangeSet()).to.equal("modified");
|
|
580
603
|
}
|
|
581
|
-
if (in_context.getTypeid() ===
|
|
604
|
+
if (in_context.getTypeid() === "array<Float32>") {
|
|
582
605
|
expect(in_context.getNestedChangeSet()).to.deep.equal({
|
|
583
606
|
insert: [[5, [15]]],
|
|
584
607
|
});
|
|
585
608
|
}
|
|
586
|
-
if (in_context.getTypeid() ===
|
|
609
|
+
if (in_context.getTypeid() === "map<Float32>") {
|
|
587
610
|
expect(in_context.getNestedChangeSet()).to.deep.equal({
|
|
588
611
|
insert: {
|
|
589
612
|
new_test: 7,
|
|
@@ -601,27 +624,27 @@ describe('Utils', function () {
|
|
|
601
624
|
done();
|
|
602
625
|
});
|
|
603
626
|
});
|
|
604
|
-
it(
|
|
627
|
+
it("should work for inserts in strings", function (done) {
|
|
605
628
|
// Clean the old modifications
|
|
606
629
|
testRoot.cleanDirty();
|
|
607
630
|
for (var i = 0; i < contexts.length; i++) {
|
|
608
|
-
if (contexts[i].getTypeid() ===
|
|
631
|
+
if (contexts[i].getTypeid() === "String") {
|
|
609
632
|
var modifyNode = testRoot.resolvePath(contexts[i].getFullPath());
|
|
610
|
-
if (modifyNode.getId() !==
|
|
611
|
-
modifyNode.insert(3,
|
|
633
|
+
if (modifyNode.getId() !== "guid") {
|
|
634
|
+
modifyNode.insert(3, "_inserted_");
|
|
612
635
|
}
|
|
613
636
|
}
|
|
614
637
|
}
|
|
615
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
638
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
616
639
|
preCallback: function (in_context, cb) {
|
|
617
640
|
// Do some basic sanity checks
|
|
618
641
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
619
642
|
expect(node).to.be.instanceof(BaseProperty);
|
|
620
643
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
621
|
-
expect(in_context.getOperationType()).to.equal(
|
|
622
|
-
if (node.getTypeid() ===
|
|
644
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
645
|
+
if (node.getTypeid() === "String") {
|
|
623
646
|
expect(in_context.getNestedChangeSet()).to.deep.equal({
|
|
624
|
-
insert: [[3,
|
|
647
|
+
insert: [[3, "_inserted_"]],
|
|
625
648
|
});
|
|
626
649
|
}
|
|
627
650
|
setImmediate(cb);
|
|
@@ -630,28 +653,28 @@ describe('Utils', function () {
|
|
|
630
653
|
done();
|
|
631
654
|
});
|
|
632
655
|
});
|
|
633
|
-
it(
|
|
656
|
+
it("should work for inserts in arrays", function (done) {
|
|
634
657
|
// Clean the old modifications
|
|
635
658
|
testRoot.cleanDirty();
|
|
636
|
-
var newArrayNode = PropertyFactory.create(
|
|
659
|
+
var newArrayNode = PropertyFactory.create("NodeProperty");
|
|
637
660
|
testRoot._properties.array.push(newArrayNode);
|
|
638
|
-
newArrayNode.insert(
|
|
639
|
-
newArrayNode._properties.string.value =
|
|
640
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
661
|
+
newArrayNode.insert("string", PropertyFactory.create("String"));
|
|
662
|
+
newArrayNode._properties.string.value = "test";
|
|
663
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
641
664
|
preCallback: function (in_context, cb) {
|
|
642
665
|
// Do some basic sanity checks
|
|
643
666
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
644
667
|
expect(node).to.be.instanceof(BaseProperty);
|
|
645
668
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
646
|
-
if (in_context.getFullPath() !==
|
|
647
|
-
in_context.getFullPath() !==
|
|
648
|
-
expect(in_context.getOperationType()).to.equal(
|
|
669
|
+
if (in_context.getFullPath() !== "" &&
|
|
670
|
+
in_context.getFullPath() !== "array") {
|
|
671
|
+
expect(in_context.getOperationType()).to.equal("insert");
|
|
649
672
|
}
|
|
650
673
|
else {
|
|
651
|
-
expect(in_context.getOperationType()).to.equal(
|
|
674
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
652
675
|
}
|
|
653
|
-
if (node.getTypeid() ===
|
|
654
|
-
expect(in_context.getNestedChangeSet()).to.equal(
|
|
676
|
+
if (node.getTypeid() === "String") {
|
|
677
|
+
expect(in_context.getNestedChangeSet()).to.equal("test");
|
|
655
678
|
}
|
|
656
679
|
setImmediate(cb);
|
|
657
680
|
},
|
|
@@ -659,54 +682,53 @@ describe('Utils', function () {
|
|
|
659
682
|
done();
|
|
660
683
|
});
|
|
661
684
|
});
|
|
662
|
-
it(
|
|
685
|
+
it("should work for inserts in sets", function (done) {
|
|
663
686
|
// Clean the old modifications
|
|
664
687
|
testRoot.cleanDirty();
|
|
665
|
-
var newSetNode = PropertyFactory.create(
|
|
688
|
+
var newSetNode = PropertyFactory.create("NamedNodeProperty");
|
|
666
689
|
testRoot._properties.set.insert(newSetNode);
|
|
667
|
-
newSetNode.insert(
|
|
668
|
-
newSetNode._properties.string.setValue(
|
|
669
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
690
|
+
newSetNode.insert("string", PropertyFactory.create("String"));
|
|
691
|
+
newSetNode._properties.string.setValue("test");
|
|
692
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
670
693
|
preCallback: function (in_context, cb) {
|
|
671
694
|
// Do some basic sanity checks
|
|
672
695
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
673
696
|
expect(node).to.be.instanceof(BaseProperty);
|
|
674
697
|
expect(node.getTypeid()).to.equal(in_context._splitTypeId.typeid);
|
|
675
|
-
if (in_context.getFullPath() !==
|
|
676
|
-
in_context.
|
|
677
|
-
expect(in_context.getOperationType()).to.equal('insert');
|
|
698
|
+
if (in_context.getFullPath() !== "" && in_context.getFullPath() !== "set") {
|
|
699
|
+
expect(in_context.getOperationType()).to.equal("insert");
|
|
678
700
|
}
|
|
679
701
|
else {
|
|
680
|
-
expect(in_context.getOperationType()).to.equal(
|
|
702
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
681
703
|
}
|
|
682
|
-
if (node.getTypeid() ===
|
|
704
|
+
if (node.getTypeid() === "String") {
|
|
683
705
|
expect(in_context.getNestedChangeSet()).to.equal(node.value);
|
|
684
706
|
}
|
|
685
707
|
setImmediate(cb);
|
|
686
708
|
},
|
|
687
709
|
}, done);
|
|
688
710
|
});
|
|
689
|
-
it(
|
|
711
|
+
it("should work for node property removals", function (done) {
|
|
690
712
|
// Clean the old modifications
|
|
691
713
|
testRoot.cleanDirty();
|
|
692
714
|
var removedStrings = [];
|
|
693
715
|
for (var i = 0; i < contexts.length; i++) {
|
|
694
|
-
if (contexts[i].getTypeid() ===
|
|
716
|
+
if (contexts[i].getTypeid() === "NodeProperty") {
|
|
695
717
|
var modifyNode = testRoot.resolvePath(contexts[i].getFullPath());
|
|
696
718
|
removedStrings.push(modifyNode._properties.string.getAbsolutePath());
|
|
697
|
-
modifyNode.remove(
|
|
719
|
+
modifyNode.remove("string");
|
|
698
720
|
}
|
|
699
721
|
}
|
|
700
722
|
var actualStringRemoveCount = 0;
|
|
701
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
723
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
702
724
|
preCallback: function (in_context, cb) {
|
|
703
725
|
var node = testRoot.resolvePath(in_context.getFullPath());
|
|
704
726
|
if (node) {
|
|
705
|
-
expect(in_context.getOperationType()).to.equal(
|
|
727
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
706
728
|
}
|
|
707
729
|
else {
|
|
708
|
-
expect(in_context.getOperationType()).to.equal(
|
|
709
|
-
expect(removedStrings.indexOf(
|
|
730
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
731
|
+
expect(removedStrings.indexOf("/" + in_context.getFullPath())).to.not.equal(-1);
|
|
710
732
|
actualStringRemoveCount++;
|
|
711
733
|
}
|
|
712
734
|
setImmediate(cb);
|
|
@@ -716,19 +738,19 @@ describe('Utils', function () {
|
|
|
716
738
|
done();
|
|
717
739
|
});
|
|
718
740
|
});
|
|
719
|
-
it(
|
|
741
|
+
it("should work for array removals", function (done) {
|
|
720
742
|
// Clean the old modifications
|
|
721
743
|
testRoot.cleanDirty();
|
|
722
744
|
testRoot._properties.array.removeRange(0, 2);
|
|
723
745
|
var arrayRemovalCount = 0;
|
|
724
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
746
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
725
747
|
preCallback: function (in_context, cb) {
|
|
726
|
-
if (in_context.getFullPath() ===
|
|
727
|
-
in_context.getFullPath() ===
|
|
728
|
-
expect(in_context.getOperationType()).to.equal(
|
|
748
|
+
if (in_context.getFullPath() === "" ||
|
|
749
|
+
in_context.getFullPath() === "array") {
|
|
750
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
729
751
|
}
|
|
730
752
|
else {
|
|
731
|
-
expect(in_context.getOperationType()).to.equal(
|
|
753
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
732
754
|
arrayRemovalCount++;
|
|
733
755
|
}
|
|
734
756
|
setImmediate(cb);
|
|
@@ -738,19 +760,18 @@ describe('Utils', function () {
|
|
|
738
760
|
done();
|
|
739
761
|
});
|
|
740
762
|
});
|
|
741
|
-
it(
|
|
763
|
+
it("should work for map removals", function (done) {
|
|
742
764
|
// Clean the old modifications
|
|
743
765
|
testRoot.cleanDirty();
|
|
744
|
-
testRoot._properties.map.remove(
|
|
766
|
+
testRoot._properties.map.remove("string");
|
|
745
767
|
var mapRemovalCount = 0;
|
|
746
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
768
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
747
769
|
preCallback: function (in_context, cb) {
|
|
748
|
-
if (in_context.getFullPath() ===
|
|
749
|
-
in_context.
|
|
750
|
-
expect(in_context.getOperationType()).to.equal('modify');
|
|
770
|
+
if (in_context.getFullPath() === "" || in_context.getFullPath() === "map") {
|
|
771
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
751
772
|
}
|
|
752
773
|
else {
|
|
753
|
-
expect(in_context.getOperationType()).to.equal(
|
|
774
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
754
775
|
mapRemovalCount++;
|
|
755
776
|
}
|
|
756
777
|
setImmediate(cb);
|
|
@@ -760,19 +781,18 @@ describe('Utils', function () {
|
|
|
760
781
|
done();
|
|
761
782
|
});
|
|
762
783
|
});
|
|
763
|
-
it(
|
|
784
|
+
it("should work for set removals", function (done) {
|
|
764
785
|
// Clean the old modifications
|
|
765
786
|
testRoot.cleanDirty();
|
|
766
787
|
testRoot._properties.set.remove(namedNodePropForSet);
|
|
767
788
|
var setRemovalCount = 0;
|
|
768
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
789
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
769
790
|
preCallback: function (in_context, cb) {
|
|
770
|
-
if (in_context.getFullPath() ===
|
|
771
|
-
in_context.
|
|
772
|
-
expect(in_context.getOperationType()).to.equal('modify');
|
|
791
|
+
if (in_context.getFullPath() === "" || in_context.getFullPath() === "set") {
|
|
792
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
773
793
|
}
|
|
774
794
|
else {
|
|
775
|
-
expect(in_context.getOperationType()).to.equal(
|
|
795
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
776
796
|
setRemovalCount++;
|
|
777
797
|
}
|
|
778
798
|
setImmediate(cb);
|
|
@@ -782,17 +802,17 @@ describe('Utils', function () {
|
|
|
782
802
|
done();
|
|
783
803
|
});
|
|
784
804
|
});
|
|
785
|
-
it(
|
|
786
|
-
testRoot.insert(
|
|
787
|
-
var namedNodePropForSet1 = PropertyFactory.create(
|
|
788
|
-
var namedNodePropForSet2 = PropertyFactory.create(
|
|
789
|
-
var namedNodePropForSet3 = PropertyFactory.create(
|
|
805
|
+
it("should clone the context correctly", function (done) {
|
|
806
|
+
testRoot.insert("setClone", PropertyFactory.create("set<>"));
|
|
807
|
+
var namedNodePropForSet1 = PropertyFactory.create("NamedNodeProperty");
|
|
808
|
+
var namedNodePropForSet2 = PropertyFactory.create("NamedNodeProperty");
|
|
809
|
+
var namedNodePropForSet3 = PropertyFactory.create("NamedNodeProperty");
|
|
790
810
|
testRoot._properties.setClone.insert(namedNodePropForSet1);
|
|
791
811
|
testRoot._properties.setClone.insert(namedNodePropForSet2);
|
|
792
812
|
testRoot._properties.setClone.insert(namedNodePropForSet3);
|
|
793
|
-
namedNodePropForSet1.insert(
|
|
794
|
-
namedNodePropForSet2.insert(
|
|
795
|
-
namedNodePropForSet3.insert(
|
|
813
|
+
namedNodePropForSet1.insert("string1", PropertyFactory.create("String"));
|
|
814
|
+
namedNodePropForSet2.insert("string2", PropertyFactory.create("String"));
|
|
815
|
+
namedNodePropForSet3.insert("string3", PropertyFactory.create("String"));
|
|
796
816
|
// Clean the old modifications
|
|
797
817
|
testRoot.cleanDirty();
|
|
798
818
|
testRoot._properties.setClone.remove(namedNodePropForSet1);
|
|
@@ -800,14 +820,14 @@ describe('Utils', function () {
|
|
|
800
820
|
testRoot._properties.setClone.remove(namedNodePropForSet3);
|
|
801
821
|
var setRemovalCount = 0;
|
|
802
822
|
var contextCloneCount = 0;
|
|
803
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
823
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
804
824
|
preCallback: function (in_context, cb) {
|
|
805
|
-
if (in_context.getFullPath() ===
|
|
806
|
-
in_context.getFullPath() ===
|
|
807
|
-
expect(in_context.getOperationType()).to.equal(
|
|
825
|
+
if (in_context.getFullPath() === "" ||
|
|
826
|
+
in_context.getFullPath() === "setClone") {
|
|
827
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
808
828
|
}
|
|
809
829
|
else {
|
|
810
|
-
expect(in_context.getOperationType()).to.equal(
|
|
830
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
811
831
|
setRemovalCount++;
|
|
812
832
|
}
|
|
813
833
|
var cloneContext = in_context.clone();
|
|
@@ -821,34 +841,34 @@ describe('Utils', function () {
|
|
|
821
841
|
done();
|
|
822
842
|
});
|
|
823
843
|
});
|
|
824
|
-
it(
|
|
844
|
+
it("@regression should work for mixed modifications and removals", function (done) {
|
|
825
845
|
// This test uses its own property sets tree
|
|
826
|
-
var ownRoot = PropertyFactory.create(
|
|
827
|
-
var userInfo = PropertyFactory.create(
|
|
828
|
-
userInfo.insert(
|
|
829
|
-
userInfo.insert(
|
|
830
|
-
ownRoot.insert(
|
|
831
|
-
var numberOfResidents = PropertyFactory.create(
|
|
832
|
-
ownRoot.insert(
|
|
846
|
+
var ownRoot = PropertyFactory.create("NodeProperty");
|
|
847
|
+
var userInfo = PropertyFactory.create("NodeProperty");
|
|
848
|
+
userInfo.insert("name", PropertyFactory.create("String", "single", "John Doe"));
|
|
849
|
+
userInfo.insert("isResident", PropertyFactory.create("Bool", "single", true));
|
|
850
|
+
ownRoot.insert("userInfo", userInfo);
|
|
851
|
+
var numberOfResidents = PropertyFactory.create("Int32", "single", 1);
|
|
852
|
+
ownRoot.insert("numberOfResidents", numberOfResidents);
|
|
833
853
|
ownRoot.cleanDirty();
|
|
834
|
-
ownRoot.get([
|
|
835
|
-
ownRoot.get(
|
|
836
|
-
ownRoot.get(
|
|
854
|
+
ownRoot.get(["userInfo", "name"]).setValue("Johnny B. Goode");
|
|
855
|
+
ownRoot.get("userInfo").remove("isResident");
|
|
856
|
+
ownRoot.get("numberOfResidents").setValue(0);
|
|
837
857
|
var modifiedCount = 0;
|
|
838
|
-
var serializedCS = ownRoot.serialize({
|
|
858
|
+
var serializedCS = ownRoot.serialize({ dirtyOnly: true });
|
|
839
859
|
Utils.traverseChangeSetRecursivelyAsync(serializedCS, {
|
|
840
860
|
preCallback: function (in_context, cb) {
|
|
841
861
|
var node = ownRoot.resolvePath(in_context.getFullPath());
|
|
842
862
|
if (node) {
|
|
843
|
-
expect(in_context.getOperationType()).to.equal(
|
|
844
|
-
if (in_context.getLastSegment() ===
|
|
845
|
-
in_context.getLastSegment() ===
|
|
863
|
+
expect(in_context.getOperationType()).to.equal("modify");
|
|
864
|
+
if (in_context.getLastSegment() === "name" ||
|
|
865
|
+
in_context.getLastSegment() === "numberOfResidents") {
|
|
846
866
|
modifiedCount++;
|
|
847
867
|
}
|
|
848
868
|
}
|
|
849
869
|
else {
|
|
850
|
-
expect(in_context.getOperationType()).to.equal(
|
|
851
|
-
expect(in_context.getLastSegment()).to.equal(
|
|
870
|
+
expect(in_context.getOperationType()).to.equal("remove");
|
|
871
|
+
expect(in_context.getLastSegment()).to.equal("isResident");
|
|
852
872
|
}
|
|
853
873
|
setImmediate(cb);
|
|
854
874
|
},
|
|
@@ -857,60 +877,63 @@ describe('Utils', function () {
|
|
|
857
877
|
done();
|
|
858
878
|
});
|
|
859
879
|
});
|
|
860
|
-
it(
|
|
880
|
+
it("@regression should work when replacing a map element", function (done) {
|
|
861
881
|
// Clean the old modifications
|
|
862
882
|
testRoot.cleanDirty();
|
|
863
|
-
testRoot._properties.map.set(
|
|
883
|
+
testRoot._properties.map.set("testParent", PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0", "single", {
|
|
884
|
+
errorMsg: "another element",
|
|
885
|
+
progress: 99,
|
|
886
|
+
}));
|
|
864
887
|
var operations = [];
|
|
865
|
-
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({
|
|
888
|
+
Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ dirtyOnly: true }), {
|
|
866
889
|
preCallback: function (in_context, cb) {
|
|
867
|
-
if (in_context.getFullPath() ===
|
|
890
|
+
if (in_context.getFullPath() === "map[testParent]") {
|
|
868
891
|
operations.push(in_context.getOperationType());
|
|
869
892
|
}
|
|
870
|
-
else if (in_context.getFullPath() ===
|
|
871
|
-
expect(in_context.getNestedChangeSet() ===
|
|
893
|
+
else if (in_context.getFullPath() === "map[testParent].errorMsg") {
|
|
894
|
+
expect(in_context.getNestedChangeSet() === "another element");
|
|
872
895
|
}
|
|
873
|
-
else if (in_context.getFullPath() ===
|
|
896
|
+
else if (in_context.getFullPath() === "map[testParent].progress") {
|
|
874
897
|
expect(in_context.getNestedChangeSet() === 99);
|
|
875
898
|
}
|
|
876
899
|
setImmediate(cb);
|
|
877
900
|
},
|
|
878
901
|
}, function () {
|
|
879
|
-
expect(operations).to.deep.equal([
|
|
902
|
+
expect(operations).to.deep.equal(["remove", "insert"]);
|
|
880
903
|
done();
|
|
881
904
|
});
|
|
882
905
|
});
|
|
883
906
|
});
|
|
884
|
-
describe(
|
|
907
|
+
describe("Utils.enumerateSchemas", function () {
|
|
885
908
|
var serializedChangeSet = {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
typeid:
|
|
889
|
-
inherits:
|
|
909
|
+
insertTemplates: {
|
|
910
|
+
"autodesk.tests:property.set.SimpleNamedPoint-1.0.0": {
|
|
911
|
+
typeid: "autodesk.tests:property.set.SimpleNamedPoint-1.0.0",
|
|
912
|
+
inherits: "NamedProperty",
|
|
890
913
|
properties: [
|
|
891
|
-
{ id:
|
|
892
|
-
{ id:
|
|
914
|
+
{ id: "x", typeid: "Uint32" },
|
|
915
|
+
{ id: "y", typeid: "Uint32" },
|
|
893
916
|
],
|
|
894
917
|
},
|
|
895
|
-
|
|
896
|
-
typeid:
|
|
897
|
-
inherits:
|
|
918
|
+
"autodesk.tests:property.set.SimpleNamedPoint-1.2.0": {
|
|
919
|
+
typeid: "autodesk.tests:property.set.SimpleNamedPoint-1.0.0",
|
|
920
|
+
inherits: "NamedProperty",
|
|
898
921
|
properties: [
|
|
899
|
-
{ id:
|
|
900
|
-
{ id:
|
|
922
|
+
{ id: "x", typeid: "Uint64" },
|
|
923
|
+
{ id: "y", typeid: "Uint64" },
|
|
901
924
|
],
|
|
902
925
|
},
|
|
903
926
|
},
|
|
904
927
|
};
|
|
905
|
-
it(
|
|
928
|
+
it("should return the schemas, and then call the finalizer", function (done) {
|
|
906
929
|
var countedTemplates = 0;
|
|
907
930
|
Utils.enumerateSchemas(serializedChangeSet, function (t, cb) {
|
|
908
931
|
countedTemplates++;
|
|
909
|
-
if (t.key ===
|
|
910
|
-
expect(t.value).to.eql(serializedChangeSet.insertTemplates[
|
|
932
|
+
if (t.key === "autodesk.tests:property.set.SimpleNamedPoint-1.0.0") {
|
|
933
|
+
expect(t.value).to.eql(serializedChangeSet.insertTemplates["autodesk.tests:property.set.SimpleNamedPoint-1.0.0"]);
|
|
911
934
|
}
|
|
912
|
-
if (t.key ===
|
|
913
|
-
expect(t.value).to.eql(serializedChangeSet.insertTemplates[
|
|
935
|
+
if (t.key === "autodesk.tests:property.set.SimpleNamedPoint-1.2.0") {
|
|
936
|
+
expect(t.value).to.eql(serializedChangeSet.insertTemplates["autodesk.tests:property.set.SimpleNamedPoint-1.2.0"]);
|
|
914
937
|
}
|
|
915
938
|
setImmediate(cb);
|
|
916
939
|
}, function () {
|
|
@@ -919,135 +942,160 @@ describe('Utils', function () {
|
|
|
919
942
|
});
|
|
920
943
|
});
|
|
921
944
|
});
|
|
922
|
-
describe(
|
|
923
|
-
it(
|
|
924
|
-
var property = PropertyFactory.create(
|
|
925
|
-
var typeids = Utils.extractTypeids(property.serialize({
|
|
945
|
+
describe("Utils.extractTypeids", function () {
|
|
946
|
+
it("Should work for a simple templated property", function () {
|
|
947
|
+
var property = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
948
|
+
var typeids = Utils.extractTypeids(property.serialize({ dirtyOnly: false, includeRootTypeid: true }));
|
|
926
949
|
typeids.sort();
|
|
927
950
|
// Note the map from the template isn't included in the ChangeSet since it is empty
|
|
928
|
-
expect(typeids).to.deep.equal([
|
|
929
|
-
|
|
930
|
-
|
|
951
|
+
expect(typeids).to.deep.equal([
|
|
952
|
+
"String",
|
|
953
|
+
"Uint32",
|
|
954
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
955
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
956
|
+
"map<autodesk.test:utilsTestContained-1.0.0>",
|
|
957
|
+
]);
|
|
931
958
|
});
|
|
932
|
-
it(
|
|
933
|
-
var property = PropertyFactory.create(
|
|
934
|
-
var child = PropertyFactory.create(
|
|
935
|
-
property.insert(
|
|
936
|
-
var typeids = Utils.extractTypeids(property.serialize({
|
|
959
|
+
it("Should work for inserts into a NodePropertý", function () {
|
|
960
|
+
var property = PropertyFactory.create("NodeProperty");
|
|
961
|
+
var child = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
962
|
+
property.insert("child", child);
|
|
963
|
+
var typeids = Utils.extractTypeids(property.serialize({ dirtyOnly: false, includeRootTypeid: true }));
|
|
937
964
|
typeids.sort();
|
|
938
|
-
expect(typeids).to.deep.equal([
|
|
939
|
-
|
|
940
|
-
|
|
965
|
+
expect(typeids).to.deep.equal([
|
|
966
|
+
"NodeProperty",
|
|
967
|
+
"String",
|
|
968
|
+
"Uint32",
|
|
969
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
970
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
971
|
+
"map<autodesk.test:utilsTestContained-1.0.0>",
|
|
972
|
+
]);
|
|
941
973
|
});
|
|
942
|
-
it(
|
|
943
|
-
var property = PropertyFactory.create(
|
|
944
|
-
var child = PropertyFactory.create(
|
|
945
|
-
property.insert(
|
|
974
|
+
it("Should work for inserts into a map", function () {
|
|
975
|
+
var property = PropertyFactory.create("map<>");
|
|
976
|
+
var child = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
977
|
+
property.insert("child", child);
|
|
946
978
|
var typeids = Utils.extractTypeids(property._serialize(false, true));
|
|
947
979
|
typeids.sort();
|
|
948
|
-
expect(typeids).to.deep.equal([
|
|
949
|
-
|
|
950
|
-
|
|
980
|
+
expect(typeids).to.deep.equal([
|
|
981
|
+
"String",
|
|
982
|
+
"Uint32",
|
|
983
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
984
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
985
|
+
"map<>",
|
|
986
|
+
"map<autodesk.test:utilsTestContained-1.0.0>",
|
|
987
|
+
]);
|
|
951
988
|
});
|
|
952
|
-
it(
|
|
953
|
-
var property = PropertyFactory.create(
|
|
954
|
-
var child = PropertyFactory.create(
|
|
989
|
+
it("Should work for inserts into an array", function () {
|
|
990
|
+
var property = PropertyFactory.create("array<>");
|
|
991
|
+
var child = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
955
992
|
property.push(child);
|
|
956
993
|
var typeids = Utils.extractTypeids(property._serialize(false, true));
|
|
957
994
|
typeids.sort();
|
|
958
|
-
expect(typeids).to.deep.equal([
|
|
959
|
-
|
|
960
|
-
|
|
995
|
+
expect(typeids).to.deep.equal([
|
|
996
|
+
"String",
|
|
997
|
+
"Uint32",
|
|
998
|
+
"array<>",
|
|
999
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
1000
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
1001
|
+
"map<autodesk.test:utilsTestContained-1.0.0>",
|
|
1002
|
+
]);
|
|
961
1003
|
});
|
|
962
|
-
it(
|
|
963
|
-
var property = PropertyFactory.create(
|
|
964
|
-
var child = PropertyFactory.create(
|
|
965
|
-
property.insert(
|
|
1004
|
+
it("Should work for modifications of a NodeProperty", function () {
|
|
1005
|
+
var property = PropertyFactory.create("NodeProperty");
|
|
1006
|
+
var child = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
1007
|
+
property.insert("child", child);
|
|
966
1008
|
property.cleanDirty();
|
|
967
|
-
property.resolvePath('child.contained."error\\"Msg\\""').value =
|
|
968
|
-
var typeids = Utils.extractTypeids(property.serialize({
|
|
1009
|
+
property.resolvePath('child.contained."error\\"Msg\\""').value = "modified";
|
|
1010
|
+
var typeids = Utils.extractTypeids(property.serialize({ dirtyOnly: true, in_includeRootTypeid: true }));
|
|
969
1011
|
typeids.sort();
|
|
970
1012
|
expect(typeids).to.deep.equal([
|
|
971
|
-
|
|
1013
|
+
"NodeProperty",
|
|
1014
|
+
"String",
|
|
1015
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
1016
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
972
1017
|
]);
|
|
973
1018
|
});
|
|
974
|
-
it(
|
|
975
|
-
var property = PropertyFactory.create(
|
|
976
|
-
var child = PropertyFactory.create(
|
|
977
|
-
property.insert(
|
|
1019
|
+
it("Should work for modifications of a map", function () {
|
|
1020
|
+
var property = PropertyFactory.create("map<>");
|
|
1021
|
+
var child = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
1022
|
+
property.insert("child", child);
|
|
978
1023
|
property.cleanDirty();
|
|
979
|
-
property.resolvePath('[child].contained."error\\"Msg\\""').value =
|
|
1024
|
+
property.resolvePath('[child].contained."error\\"Msg\\""').value = "modified";
|
|
980
1025
|
var typeids = Utils.extractTypeids(property._serialize(true, true));
|
|
981
1026
|
typeids.sort();
|
|
982
1027
|
expect(typeids).to.deep.equal([
|
|
983
|
-
|
|
1028
|
+
"String",
|
|
1029
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
1030
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
1031
|
+
"map<>",
|
|
984
1032
|
]);
|
|
985
1033
|
});
|
|
986
|
-
it(
|
|
987
|
-
var property = PropertyFactory.create(
|
|
988
|
-
var child = PropertyFactory.create(
|
|
1034
|
+
it("Should work for modifications of an array", function () {
|
|
1035
|
+
var property = PropertyFactory.create("array<>");
|
|
1036
|
+
var child = PropertyFactory.create("autodesk.test:utilsTestParent-1.0.0");
|
|
989
1037
|
property.push(child);
|
|
990
1038
|
property.cleanDirty();
|
|
991
|
-
property.resolvePath('[0].contained."error\\"Msg\\""').setValue(
|
|
1039
|
+
property.resolvePath('[0].contained."error\\"Msg\\""').setValue("modified");
|
|
992
1040
|
var typeids = Utils.extractTypeids(property._serialize(true, true));
|
|
993
1041
|
typeids.sort();
|
|
994
1042
|
expect(typeids).to.deep.equal([
|
|
995
|
-
|
|
1043
|
+
"String",
|
|
1044
|
+
"array<>",
|
|
1045
|
+
"autodesk.test:utilsTestContained-1.0.0",
|
|
1046
|
+
"autodesk.test:utilsTestParent-1.0.0",
|
|
996
1047
|
]);
|
|
997
1048
|
});
|
|
998
|
-
it(
|
|
999
|
-
var typeids = Utils.extractTypeids({ remove: [
|
|
1049
|
+
it("Should work for removals", function () {
|
|
1050
|
+
var typeids = Utils.extractTypeids({ remove: ["xxx-yyy-zzz"] });
|
|
1000
1051
|
expect(typeids).to.have.lengthOf(1);
|
|
1001
|
-
expect(typeids[0]).to.equal(
|
|
1052
|
+
expect(typeids[0]).to.equal("NodeProperty");
|
|
1002
1053
|
});
|
|
1003
1054
|
});
|
|
1004
|
-
describe(
|
|
1055
|
+
describe("Change set helper functions", function () {
|
|
1005
1056
|
var root, sim, subject1, subject2, subject3;
|
|
1006
1057
|
// Create a simple test data-set
|
|
1007
1058
|
before(function () {
|
|
1008
|
-
root = PropertyFactory.create(
|
|
1009
|
-
sim = PropertyFactory.create(
|
|
1010
|
-
subject1 = PropertyFactory.create(
|
|
1011
|
-
subject2 = PropertyFactory.create(
|
|
1012
|
-
root.insert(
|
|
1013
|
-
sim.insert(
|
|
1014
|
-
sim.insert(
|
|
1015
|
-
var arrayProp = PropertyFactory.create(
|
|
1016
|
-
root.insert(
|
|
1017
|
-
arrayProp.push(PropertyFactory.create(
|
|
1018
|
-
arrayProp.push(PropertyFactory.create(
|
|
1059
|
+
root = PropertyFactory.create("NodeProperty");
|
|
1060
|
+
sim = PropertyFactory.create("autodesk.test:utils.spec.pan.sim-1.0.0");
|
|
1061
|
+
subject1 = PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0");
|
|
1062
|
+
subject2 = PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0");
|
|
1063
|
+
root.insert("simulation", sim);
|
|
1064
|
+
sim.insert("subject1", subject1);
|
|
1065
|
+
sim.insert("subject2", subject2);
|
|
1066
|
+
var arrayProp = PropertyFactory.create("array<>");
|
|
1067
|
+
root.insert("array", arrayProp);
|
|
1068
|
+
arrayProp.push(PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"));
|
|
1069
|
+
arrayProp.push(PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"));
|
|
1019
1070
|
arrayProp.get(1)._properties.progress.value = 1;
|
|
1020
|
-
var mapProp = PropertyFactory.create(
|
|
1021
|
-
root.insert(
|
|
1022
|
-
mapProp.insert(
|
|
1071
|
+
var mapProp = PropertyFactory.create("map<>");
|
|
1072
|
+
root.insert("map", mapProp);
|
|
1073
|
+
mapProp.insert("entry", PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"));
|
|
1023
1074
|
});
|
|
1024
|
-
it(
|
|
1025
|
-
var insertedResults = Utils.getChangesByType(
|
|
1075
|
+
it("should work correctly for inserts", function () {
|
|
1076
|
+
var insertedResults = Utils.getChangesByType("autodesk.test:utils.spec.task.subject-1.0.0", root.serialize({ dirtyOnly: true }));
|
|
1026
1077
|
assert(_.keys(insertedResults.insert).length === 9);
|
|
1027
1078
|
for (var i = 0; i < 9; i++) {
|
|
1028
1079
|
assert(root.resolvePath(_.keys(insertedResults.insert)[i]) !== undefined);
|
|
1029
|
-
assert(Utils.getChangesByPath(_.keys(insertedResults.insert)[i], root, root.serialize(), false).insert !==
|
|
1030
|
-
undefined);
|
|
1080
|
+
assert(Utils.getChangesByPath(_.keys(insertedResults.insert)[i], root, root.serialize(), false).insert !== undefined);
|
|
1031
1081
|
}
|
|
1032
1082
|
});
|
|
1033
|
-
it(
|
|
1083
|
+
it("should work correctly for the root path", function () {
|
|
1034
1084
|
var AnonymousTestPropertyTemplate = {
|
|
1035
|
-
typeid:
|
|
1036
|
-
properties: [
|
|
1037
|
-
{ id: 'stringProperty', typeid: 'String' },
|
|
1038
|
-
],
|
|
1085
|
+
typeid: "autodesk.tests:AnonymousMapTestPropertyID-1.0.0",
|
|
1086
|
+
properties: [{ id: "stringProperty", typeid: "String" }],
|
|
1039
1087
|
};
|
|
1040
1088
|
PropertyFactory._reregister(AnonymousTestPropertyTemplate);
|
|
1041
|
-
var prop = PropertyFactory.create(
|
|
1042
|
-
prop.insert(
|
|
1043
|
-
var result = Utils.getChangesByPath(
|
|
1089
|
+
var prop = PropertyFactory.create("NodeProperty");
|
|
1090
|
+
prop.insert("A", PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0"));
|
|
1091
|
+
var result = Utils.getChangesByPath("", null, prop.serialize());
|
|
1044
1092
|
expect(result).to.deep.equal({
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1093
|
+
modify: {
|
|
1094
|
+
insert: {
|
|
1095
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
1096
|
+
A: {
|
|
1097
|
+
String: {
|
|
1098
|
+
stringProperty: "",
|
|
1051
1099
|
},
|
|
1052
1100
|
},
|
|
1053
1101
|
},
|
|
@@ -1055,251 +1103,283 @@ describe('Utils', function () {
|
|
|
1055
1103
|
},
|
|
1056
1104
|
});
|
|
1057
1105
|
});
|
|
1058
|
-
it(
|
|
1059
|
-
var insertionChangeSet = root.serialize({
|
|
1106
|
+
it("should correctly strip typeids in insertions", function () {
|
|
1107
|
+
var insertionChangeSet = root.serialize({ dirtyOnly: true });
|
|
1060
1108
|
Utils._stripTypeids(insertionChangeSet);
|
|
1061
1109
|
expect(insertionChangeSet).to.deep.equal({
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1110
|
+
insert: {
|
|
1111
|
+
simulation: {
|
|
1112
|
+
insert: {
|
|
1113
|
+
subject1: {
|
|
1114
|
+
errorMsg: "",
|
|
1115
|
+
progress: 0,
|
|
1068
1116
|
},
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1117
|
+
subject2: {
|
|
1118
|
+
errorMsg: "",
|
|
1119
|
+
progress: 0,
|
|
1072
1120
|
},
|
|
1073
1121
|
},
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1122
|
+
costEstimated: {
|
|
1123
|
+
errorMsg: "",
|
|
1124
|
+
progress: 0,
|
|
1077
1125
|
},
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1126
|
+
costFinal: {
|
|
1127
|
+
errorMsg: "",
|
|
1128
|
+
progress: 0,
|
|
1081
1129
|
},
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1130
|
+
thermalResults: {
|
|
1131
|
+
errorMsg: "",
|
|
1132
|
+
progress: 0,
|
|
1085
1133
|
},
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1134
|
+
mechanicalResults: {
|
|
1135
|
+
errorMsg: "",
|
|
1136
|
+
progress: 0,
|
|
1089
1137
|
},
|
|
1090
|
-
|
|
1091
|
-
|
|
1138
|
+
start: false,
|
|
1139
|
+
cancel: false,
|
|
1092
1140
|
},
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1141
|
+
map: {
|
|
1142
|
+
insert: {
|
|
1143
|
+
entry: {
|
|
1144
|
+
errorMsg: "",
|
|
1145
|
+
progress: 0,
|
|
1098
1146
|
},
|
|
1099
1147
|
},
|
|
1100
1148
|
},
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1149
|
+
array: {
|
|
1150
|
+
insert: [
|
|
1151
|
+
[
|
|
1152
|
+
0,
|
|
1153
|
+
[
|
|
1154
|
+
{
|
|
1155
|
+
errorMsg: "",
|
|
1156
|
+
progress: 0,
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
errorMsg: "",
|
|
1160
|
+
progress: 1,
|
|
1161
|
+
},
|
|
1162
|
+
],
|
|
1163
|
+
],
|
|
1164
|
+
],
|
|
1109
1165
|
},
|
|
1110
1166
|
},
|
|
1111
1167
|
});
|
|
1112
1168
|
});
|
|
1113
|
-
it(
|
|
1114
|
-
root.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE |
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1169
|
+
it("should work correctly for modifies", function () {
|
|
1170
|
+
root.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE |
|
|
1171
|
+
BaseProperty.MODIFIED_STATE_FLAGS.DIRTY);
|
|
1172
|
+
subject3 = PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0");
|
|
1173
|
+
subject2.insert("subject3", subject3);
|
|
1174
|
+
subject1._properties.errorMsg.value = "test";
|
|
1175
|
+
subject2._properties.errorMsg.value = "test";
|
|
1176
|
+
sim._properties.thermalResults.errorMsg.value = "test44";
|
|
1120
1177
|
// Test array modification
|
|
1121
|
-
root.resolvePath(
|
|
1178
|
+
root.resolvePath("array[1].errorMsg").value = "test";
|
|
1122
1179
|
// Test array insertion
|
|
1123
|
-
root.resolvePath(
|
|
1124
|
-
PropertyFactory.create(
|
|
1125
|
-
PropertyFactory.create(
|
|
1180
|
+
root.resolvePath("array").insertRange(1, [
|
|
1181
|
+
PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"),
|
|
1182
|
+
PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"),
|
|
1126
1183
|
]);
|
|
1127
|
-
root.resolvePath(
|
|
1128
|
-
PropertyFactory.create(
|
|
1184
|
+
root.resolvePath("array").insertRange(0, [
|
|
1185
|
+
PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"),
|
|
1129
1186
|
]);
|
|
1130
1187
|
// Test map modification
|
|
1131
|
-
root.resolvePath(
|
|
1188
|
+
root.resolvePath("map[entry].errorMsg").value = "test";
|
|
1132
1189
|
// Test map insertion
|
|
1133
|
-
root.resolvePath(
|
|
1134
|
-
var modifiedResults = Utils.getChangesByType(
|
|
1190
|
+
root.resolvePath("map").insert("entry2", PropertyFactory.create("autodesk.test:utils.spec.task.subject-1.0.0"));
|
|
1191
|
+
var modifiedResults = Utils.getChangesByType("autodesk.test:utils.spec.task.subject-1.0.0", root.serialize({ dirtyOnly: true }), true);
|
|
1135
1192
|
assert(_.keys(modifiedResults.insert).length === 5);
|
|
1136
1193
|
assert(_.keys(modifiedResults.modify).length === 5);
|
|
1137
1194
|
for (var i = 0; i < 5; i++) {
|
|
1138
|
-
assert(Utils.getChangesByPath(_.keys(modifiedResults.modify)[i], root, root.serialize({
|
|
1195
|
+
assert(Utils.getChangesByPath(_.keys(modifiedResults.modify)[i], root, root.serialize({ dirtyOnly: true }), false).modify !== undefined);
|
|
1139
1196
|
}
|
|
1140
1197
|
for (var i = 0; i < 5; i++) {
|
|
1141
|
-
assert(Utils.getChangesByPath(_.keys(modifiedResults.insert)[i], root, root.serialize({
|
|
1198
|
+
assert(Utils.getChangesByPath(_.keys(modifiedResults.insert)[i], root, root.serialize({ dirtyOnly: true }), false).insert !== undefined);
|
|
1142
1199
|
}
|
|
1143
1200
|
});
|
|
1144
|
-
it(
|
|
1145
|
-
var modifyChangeSet = root.serialize({
|
|
1201
|
+
it("should correctly strip typeids in modifies", function () {
|
|
1202
|
+
var modifyChangeSet = root.serialize({ dirtyOnly: true });
|
|
1146
1203
|
Utils._stripTypeids(modifyChangeSet);
|
|
1147
1204
|
expect(modifyChangeSet).to.deep.equal({
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
},
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1205
|
+
modify: {
|
|
1206
|
+
simulation: {
|
|
1207
|
+
modify: {
|
|
1208
|
+
subject1: {
|
|
1209
|
+
errorMsg: "test",
|
|
1210
|
+
},
|
|
1211
|
+
subject2: {
|
|
1212
|
+
insert: {
|
|
1213
|
+
subject3: {
|
|
1214
|
+
errorMsg: "",
|
|
1215
|
+
progress: 0,
|
|
1159
1216
|
},
|
|
1160
1217
|
},
|
|
1161
|
-
|
|
1218
|
+
errorMsg: "test",
|
|
1162
1219
|
},
|
|
1163
1220
|
},
|
|
1164
|
-
|
|
1165
|
-
|
|
1221
|
+
thermalResults: {
|
|
1222
|
+
errorMsg: "test44",
|
|
1166
1223
|
},
|
|
1167
1224
|
},
|
|
1168
|
-
|
|
1169
|
-
insert: [
|
|
1225
|
+
array: {
|
|
1226
|
+
insert: [
|
|
1227
|
+
[
|
|
1228
|
+
0,
|
|
1229
|
+
[
|
|
1230
|
+
{
|
|
1231
|
+
errorMsg: "",
|
|
1232
|
+
progress: 0,
|
|
1233
|
+
},
|
|
1234
|
+
],
|
|
1235
|
+
],
|
|
1236
|
+
[
|
|
1237
|
+
1,
|
|
1238
|
+
[
|
|
1170
1239
|
{
|
|
1171
|
-
|
|
1172
|
-
|
|
1240
|
+
errorMsg: "",
|
|
1241
|
+
progress: 0,
|
|
1173
1242
|
},
|
|
1174
|
-
]], [1, [
|
|
1175
1243
|
{
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
},
|
|
1179
|
-
|
|
1180
|
-
|
|
1244
|
+
errorMsg: "",
|
|
1245
|
+
progress: 0,
|
|
1246
|
+
},
|
|
1247
|
+
],
|
|
1248
|
+
],
|
|
1249
|
+
],
|
|
1250
|
+
modify: [
|
|
1251
|
+
[
|
|
1252
|
+
1,
|
|
1253
|
+
[
|
|
1254
|
+
{
|
|
1255
|
+
errorMsg: "test",
|
|
1181
1256
|
},
|
|
1182
|
-
]
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
}]]],
|
|
1257
|
+
],
|
|
1258
|
+
],
|
|
1259
|
+
],
|
|
1186
1260
|
},
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1261
|
+
map: {
|
|
1262
|
+
insert: {
|
|
1263
|
+
entry2: {
|
|
1264
|
+
errorMsg: "",
|
|
1265
|
+
progress: 0,
|
|
1192
1266
|
},
|
|
1193
1267
|
},
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1268
|
+
modify: {
|
|
1269
|
+
entry: {
|
|
1270
|
+
errorMsg: "test",
|
|
1197
1271
|
},
|
|
1198
1272
|
},
|
|
1199
1273
|
},
|
|
1200
1274
|
},
|
|
1201
1275
|
});
|
|
1202
1276
|
});
|
|
1203
|
-
it(
|
|
1204
|
-
root.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE |
|
|
1277
|
+
it("should correctly work for removes", function () {
|
|
1278
|
+
root.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE |
|
|
1279
|
+
BaseProperty.MODIFIED_STATE_FLAGS.DIRTY);
|
|
1205
1280
|
subject2.remove(subject3.getId());
|
|
1206
|
-
assert(Utils.getChangesByPath(sim.getId() +
|
|
1281
|
+
assert(Utils.getChangesByPath(sim.getId() + "." + subject2.getId() + "." + subject3.getId(), root, root.serialize({ dirtyOnly: true }), false).removed === true);
|
|
1207
1282
|
root.remove(sim.getId());
|
|
1208
|
-
assert(Utils.getChangesByPath(sim.getId() +
|
|
1209
|
-
assert(Utils.getChangesByPath(sim.getId() +
|
|
1210
|
-
assert(Utils.getChangesByPath(sim.getId(), root, root.serialize({
|
|
1211
|
-
root.resolvePath(
|
|
1212
|
-
root.resolvePath(
|
|
1213
|
-
root.resolvePath(
|
|
1283
|
+
assert(Utils.getChangesByPath(sim.getId() + "." + subject2.getId() + "." + subject3.getId(), root, root.serialize({ dirtyOnly: true }), false).removed === true);
|
|
1284
|
+
assert(Utils.getChangesByPath(sim.getId() + "." + subject2.getId(), root, root.serialize({ dirtyOnly: true }), false).removed === true);
|
|
1285
|
+
assert(Utils.getChangesByPath(sim.getId(), root, root.serialize({ dirtyOnly: true }), false).removed === true);
|
|
1286
|
+
root.resolvePath("map").remove("entry2");
|
|
1287
|
+
root.resolvePath("array").remove(0);
|
|
1288
|
+
root.resolvePath("array").removeRange(1, 2);
|
|
1214
1289
|
});
|
|
1215
|
-
it(
|
|
1290
|
+
it("should correctly strip typeids in removes", function () {
|
|
1216
1291
|
var modifyChangeSet = root._serialize(true);
|
|
1217
1292
|
Utils._stripTypeids(modifyChangeSet);
|
|
1218
1293
|
expect(modifyChangeSet).to.deep.equal({
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1294
|
+
modify: {
|
|
1295
|
+
array: {
|
|
1296
|
+
remove: [
|
|
1297
|
+
[0, 1],
|
|
1298
|
+
[2, 2],
|
|
1299
|
+
],
|
|
1222
1300
|
},
|
|
1223
|
-
|
|
1224
|
-
|
|
1301
|
+
map: {
|
|
1302
|
+
remove: ["entry2"],
|
|
1225
1303
|
},
|
|
1226
1304
|
},
|
|
1227
|
-
|
|
1305
|
+
remove: ["simulation"],
|
|
1228
1306
|
});
|
|
1229
1307
|
});
|
|
1230
|
-
it(
|
|
1231
|
-
var nestedTemplate = PropertyFactory.create(
|
|
1232
|
-
nestedTemplate._properties.c.myNestedProp.errorMsg.value =
|
|
1308
|
+
it("should work for nested templates", function () {
|
|
1309
|
+
var nestedTemplate = PropertyFactory.create("autodesk.tests:nestedTemplate-1.0.0");
|
|
1310
|
+
nestedTemplate._properties.c.myNestedProp.errorMsg.value = "testString";
|
|
1233
1311
|
var changeSet = nestedTemplate._serialize(true);
|
|
1234
|
-
var changes = Utils.getChangesByType(
|
|
1235
|
-
expect(changes.modify[
|
|
1236
|
-
expect(Utils.getChangesByPath(
|
|
1312
|
+
var changes = Utils.getChangesByType("String", changeSet);
|
|
1313
|
+
expect(changes.modify["c.myNestedProp.errorMsg"]).to.equal("testString");
|
|
1314
|
+
expect(Utils.getChangesByPath("c.myNestedProp.errorMsg", nestedTemplate, changeSet, false)).to.have.keys("modify");
|
|
1237
1315
|
});
|
|
1238
|
-
it(
|
|
1239
|
-
var node = PropertyFactory.create(
|
|
1240
|
-
node.get(
|
|
1241
|
-
node.get(
|
|
1242
|
-
node.get('test"property"').value =
|
|
1243
|
-
node.get(
|
|
1316
|
+
it("should work for an object with characters that have to be quoted", function () {
|
|
1317
|
+
var node = PropertyFactory.create("autodesk.tests:property.with.quotable.characters-1.0.0");
|
|
1318
|
+
node.get("simple_property").value = "test";
|
|
1319
|
+
node.get("test.property").value = "test";
|
|
1320
|
+
node.get('test"property"').value = "test";
|
|
1321
|
+
node.get("test[property]").get(".property.").get("test").value = "test";
|
|
1244
1322
|
var changeSet = node._serialize(true);
|
|
1245
|
-
var changes = Utils.getChangesByType(
|
|
1246
|
-
expect(changes.modify).to.have.keys(
|
|
1247
|
-
expect(Utils.getChangesByPath(
|
|
1248
|
-
expect(Utils.getChangesByPath('"test.property"', node, changeSet, false)).to.have.keys(
|
|
1249
|
-
expect(Utils.getChangesByPath('"test\\"property\\""', node, changeSet, false)).to.have.keys(
|
|
1250
|
-
expect(Utils.getChangesByPath('"test[property]".".property.".test', node, changeSet, false)).to.have.keys(
|
|
1323
|
+
var changes = Utils.getChangesByType("String", changeSet);
|
|
1324
|
+
expect(changes.modify).to.have.keys("simple_property", '"test.property"', '"test\\"property\\""', '"test[property]".".property.".test');
|
|
1325
|
+
expect(Utils.getChangesByPath("simple_property", node, changeSet, false)).to.have.keys("modify");
|
|
1326
|
+
expect(Utils.getChangesByPath('"test.property"', node, changeSet, false)).to.have.keys("modify");
|
|
1327
|
+
expect(Utils.getChangesByPath('"test\\"property\\""', node, changeSet, false)).to.have.keys("modify");
|
|
1328
|
+
expect(Utils.getChangesByPath('"test[property]".".property.".test', node, changeSet, false)).to.have.keys("modify");
|
|
1251
1329
|
});
|
|
1252
|
-
it(
|
|
1253
|
-
var node = PropertyFactory.create(
|
|
1254
|
-
node.insert(
|
|
1255
|
-
node.insert(
|
|
1256
|
-
node.insert('test"property"', PropertyFactory.create(
|
|
1257
|
-
node.insert(
|
|
1258
|
-
node.get(
|
|
1259
|
-
node.get(
|
|
1330
|
+
it("should work for a node property with characters that have to be quoted", function () {
|
|
1331
|
+
var node = PropertyFactory.create("NodeProperty");
|
|
1332
|
+
node.insert("simple_property", PropertyFactory.create("String", undefined, "test"));
|
|
1333
|
+
node.insert("test.property", PropertyFactory.create("String", undefined, "test"));
|
|
1334
|
+
node.insert('test"property"', PropertyFactory.create("String", undefined, "test"));
|
|
1335
|
+
node.insert("test[property]", PropertyFactory.create("NodeProperty"));
|
|
1336
|
+
node.get("test[property]").insert(".property.", PropertyFactory.create("NodeProperty"));
|
|
1337
|
+
node.get("test[property]")
|
|
1338
|
+
.get(".property.")
|
|
1339
|
+
.insert("test", PropertyFactory.create("String", undefined, "test"));
|
|
1260
1340
|
var changeSet = node._serialize(true);
|
|
1261
|
-
var changes = Utils.getChangesByType(
|
|
1262
|
-
expect(changes.insert).to.have.keys(
|
|
1263
|
-
expect(Utils.getChangesByPath(
|
|
1264
|
-
expect(Utils.getChangesByPath('"test.property"', node, changeSet, false)).to.have.keys(
|
|
1265
|
-
expect(Utils.getChangesByPath('"test\\"property\\""', node, changeSet, false)).to.have.keys(
|
|
1266
|
-
expect(Utils.getChangesByPath('"test[property]".".property.".test', node, changeSet, false)).to.have.keys(
|
|
1341
|
+
var changes = Utils.getChangesByType("String", changeSet);
|
|
1342
|
+
expect(changes.insert).to.have.keys("simple_property", '"test.property"', '"test\\"property\\""', '"test[property]".".property.".test');
|
|
1343
|
+
expect(Utils.getChangesByPath("simple_property", node, changeSet, false)).to.have.keys("insert");
|
|
1344
|
+
expect(Utils.getChangesByPath('"test.property"', node, changeSet, false)).to.have.keys("insert");
|
|
1345
|
+
expect(Utils.getChangesByPath('"test\\"property\\""', node, changeSet, false)).to.have.keys("insert");
|
|
1346
|
+
expect(Utils.getChangesByPath('"test[property]".".property.".test', node, changeSet, false)).to.have.keys("insert");
|
|
1267
1347
|
});
|
|
1268
1348
|
});
|
|
1269
|
-
describe(
|
|
1349
|
+
describe("Utils.getChangesToTokenizedPaths", function () {
|
|
1270
1350
|
var CS = {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1351
|
+
insert: {
|
|
1352
|
+
"NodeProperty": {
|
|
1353
|
+
nested1: {
|
|
1354
|
+
insert: {
|
|
1355
|
+
NodeProperty: {
|
|
1356
|
+
nested2: {
|
|
1357
|
+
insert: {
|
|
1358
|
+
String: {
|
|
1359
|
+
string: "text",
|
|
1360
|
+
__doubleUnderscore: "text",
|
|
1281
1361
|
},
|
|
1282
1362
|
},
|
|
1283
1363
|
},
|
|
1284
1364
|
},
|
|
1285
1365
|
},
|
|
1286
1366
|
},
|
|
1287
|
-
|
|
1367
|
+
nested2: {},
|
|
1288
1368
|
},
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1369
|
+
"array<>": {
|
|
1370
|
+
nestedArray: {
|
|
1371
|
+
insert: [
|
|
1292
1372
|
[
|
|
1293
1373
|
0,
|
|
1294
1374
|
[
|
|
1295
1375
|
{
|
|
1296
|
-
|
|
1376
|
+
typeid: "NodeProperty",
|
|
1297
1377
|
},
|
|
1298
1378
|
{
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1379
|
+
typeid: "NodeProperty",
|
|
1380
|
+
insert: {
|
|
1381
|
+
String: {
|
|
1382
|
+
text: "",
|
|
1303
1383
|
},
|
|
1304
1384
|
},
|
|
1305
1385
|
},
|
|
@@ -1308,103 +1388,137 @@ describe('Utils', function () {
|
|
|
1308
1388
|
],
|
|
1309
1389
|
},
|
|
1310
1390
|
},
|
|
1311
|
-
|
|
1312
|
-
|
|
1391
|
+
"String": {
|
|
1392
|
+
string: "text",
|
|
1313
1393
|
},
|
|
1314
1394
|
},
|
|
1315
1395
|
};
|
|
1316
|
-
it(
|
|
1396
|
+
it("should work using objects", function () {
|
|
1317
1397
|
var visitedPaths = [];
|
|
1318
1398
|
Utils.getChangesToTokenizedPaths({
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1399
|
+
String: {},
|
|
1400
|
+
nested1: {
|
|
1401
|
+
nested2: {
|
|
1402
|
+
string: {
|
|
1403
|
+
__hidden: {
|
|
1404
|
+
myCallback: function () {
|
|
1405
|
+
return "hello";
|
|
1406
|
+
},
|
|
1407
|
+
myValue: 1,
|
|
1326
1408
|
},
|
|
1327
1409
|
},
|
|
1328
|
-
|
|
1410
|
+
___doubleUnderscore: {}, // Yes, there are 3 '_', as escapeLeadingDoubleUnderscore = true
|
|
1329
1411
|
},
|
|
1330
1412
|
},
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1413
|
+
nestedArray: {
|
|
1414
|
+
1: {
|
|
1415
|
+
String: {},
|
|
1334
1416
|
},
|
|
1335
1417
|
},
|
|
1336
1418
|
}, CS, function (in_context, in_nested, in_tokenizedPath) {
|
|
1337
|
-
var currentPath = in_tokenizedPath.join(
|
|
1419
|
+
var currentPath = in_tokenizedPath.join(".");
|
|
1338
1420
|
visitedPaths.push(currentPath);
|
|
1339
|
-
if (currentPath ===
|
|
1421
|
+
if (currentPath === "nested1.nested2.string") {
|
|
1340
1422
|
expect(in_nested).to.exist;
|
|
1341
1423
|
expect(in_nested.__hidden).to.exist;
|
|
1342
1424
|
expect(in_nested.__hidden.myCallback).to.exist;
|
|
1343
|
-
expect(in_nested.__hidden.myCallback()).to.eql(
|
|
1425
|
+
expect(in_nested.__hidden.myCallback()).to.eql("hello");
|
|
1344
1426
|
expect(in_nested.__hidden.myValue).to.eql(1);
|
|
1345
1427
|
}
|
|
1346
1428
|
}, {
|
|
1347
|
-
rootOperation:
|
|
1348
|
-
rootTypeid:
|
|
1429
|
+
rootOperation: "modify",
|
|
1430
|
+
rootTypeid: "NodeProperty",
|
|
1349
1431
|
escapeLeadingDoubleUnderscore: true,
|
|
1350
1432
|
});
|
|
1351
|
-
expect(visitedPaths).to.deep.equal([
|
|
1352
|
-
|
|
1433
|
+
expect(visitedPaths).to.deep.equal([
|
|
1434
|
+
"",
|
|
1435
|
+
"nested1",
|
|
1436
|
+
"nested1.nested2",
|
|
1437
|
+
"nested1.nested2.string",
|
|
1438
|
+
"nested1.nested2.__doubleUnderscore",
|
|
1439
|
+
"nestedArray",
|
|
1440
|
+
"nestedArray.1",
|
|
1441
|
+
]);
|
|
1353
1442
|
});
|
|
1354
|
-
it(
|
|
1443
|
+
it("should work using maps", function () {
|
|
1355
1444
|
var visitedPaths = [];
|
|
1356
1445
|
Utils.getChangesToTokenizedPaths(new Map([
|
|
1357
|
-
[
|
|
1358
|
-
[
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1446
|
+
["String", new Map()],
|
|
1447
|
+
[
|
|
1448
|
+
"nested1",
|
|
1449
|
+
new Map([
|
|
1450
|
+
[
|
|
1451
|
+
"nested2",
|
|
1452
|
+
new Map([
|
|
1453
|
+
[
|
|
1454
|
+
"string",
|
|
1455
|
+
new Map([
|
|
1456
|
+
[
|
|
1457
|
+
"__hidden",
|
|
1458
|
+
new Map([
|
|
1459
|
+
[
|
|
1460
|
+
"myCallback",
|
|
1461
|
+
function () {
|
|
1462
|
+
return "hello";
|
|
1463
|
+
},
|
|
1464
|
+
],
|
|
1465
|
+
["myValue", 1],
|
|
1466
|
+
]),
|
|
1467
|
+
],
|
|
1468
|
+
]),
|
|
1469
|
+
],
|
|
1470
|
+
["___doubleUnderscore", new Map()], // Yes, there are 3 '_', as escapeLeadingDoubleUnderscore = true
|
|
1471
|
+
]),
|
|
1472
|
+
],
|
|
1473
|
+
]),
|
|
1474
|
+
],
|
|
1475
|
+
["nestedArray", new Map([["1", new Map([["String", new Map()]])]])],
|
|
1374
1476
|
]), CS, function (in_context, in_nested, in_tokenizedPath) {
|
|
1375
|
-
var currentPath = in_tokenizedPath.join(
|
|
1477
|
+
var currentPath = in_tokenizedPath.join(".");
|
|
1376
1478
|
visitedPaths.push(currentPath);
|
|
1377
|
-
if (currentPath ===
|
|
1479
|
+
if (currentPath === "nested1.nested2.string") {
|
|
1378
1480
|
expect(in_nested).to.exist;
|
|
1379
|
-
expect(in_nested).to.have.key(
|
|
1380
|
-
expect(in_nested.get(
|
|
1381
|
-
expect(in_nested.get(
|
|
1382
|
-
expect(in_nested.get(
|
|
1481
|
+
expect(in_nested).to.have.key("__hidden");
|
|
1482
|
+
expect(in_nested.get("__hidden")).to.have.all.keys("myCallback", "myValue");
|
|
1483
|
+
expect(in_nested.get("__hidden").get("myCallback")()).to.eql("hello");
|
|
1484
|
+
expect(in_nested.get("__hidden").get("myValue")).to.eql(1);
|
|
1383
1485
|
}
|
|
1384
1486
|
}, {
|
|
1385
|
-
rootOperation:
|
|
1386
|
-
rootTypeid:
|
|
1487
|
+
rootOperation: "modify",
|
|
1488
|
+
rootTypeid: "NodeProperty",
|
|
1387
1489
|
escapeLeadingDoubleUnderscore: true,
|
|
1388
1490
|
});
|
|
1389
|
-
expect(visitedPaths).to.deep.equal([
|
|
1390
|
-
|
|
1491
|
+
expect(visitedPaths).to.deep.equal([
|
|
1492
|
+
"",
|
|
1493
|
+
"nested1",
|
|
1494
|
+
"nested1.nested2",
|
|
1495
|
+
"nested1.nested2.string",
|
|
1496
|
+
"nested1.nested2.__doubleUnderscore",
|
|
1497
|
+
"nestedArray",
|
|
1498
|
+
"nestedArray.1",
|
|
1499
|
+
]);
|
|
1391
1500
|
});
|
|
1392
|
-
it(
|
|
1501
|
+
it("should assume paths as literal when the escapeLeadingDoubleUnderscore flag is off ", function () {
|
|
1393
1502
|
var visitedPaths = [];
|
|
1394
1503
|
Utils.getChangesToTokenizedPaths({
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1504
|
+
nested1: {
|
|
1505
|
+
nested2: {
|
|
1506
|
+
__doubleUnderscore: {}, // The amount of underscores is the same as in the changeSet
|
|
1398
1507
|
},
|
|
1399
1508
|
},
|
|
1400
1509
|
}, CS, function (in_context, in_nested, in_tokenizedPath) {
|
|
1401
|
-
visitedPaths.push(in_tokenizedPath.join(
|
|
1510
|
+
visitedPaths.push(in_tokenizedPath.join("."));
|
|
1402
1511
|
}, {
|
|
1403
|
-
rootOperation:
|
|
1404
|
-
rootTypeid:
|
|
1512
|
+
rootOperation: "modify",
|
|
1513
|
+
rootTypeid: "NodeProperty",
|
|
1405
1514
|
escapeLeadingDoubleUnderscore: false,
|
|
1406
1515
|
});
|
|
1407
|
-
expect(visitedPaths).to.deep.equal([
|
|
1516
|
+
expect(visitedPaths).to.deep.equal([
|
|
1517
|
+
"",
|
|
1518
|
+
"nested1",
|
|
1519
|
+
"nested1.nested2",
|
|
1520
|
+
"nested1.nested2.__doubleUnderscore",
|
|
1521
|
+
]);
|
|
1408
1522
|
});
|
|
1409
1523
|
});
|
|
1410
1524
|
/* describe('Utils.insertPropertyChangeIntoChangeset', function() {
|
|
@@ -1558,35 +1672,35 @@ describe('Utils', function () {
|
|
|
1558
1672
|
expect(result.insert).to.be.false;
|
|
1559
1673
|
});
|
|
1560
1674
|
}); */
|
|
1561
|
-
describe(
|
|
1675
|
+
describe("Utils.getFilteredChangeSetByPaths", function () {
|
|
1562
1676
|
var changeSet = {
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1677
|
+
insert: {
|
|
1678
|
+
"NodeProperty": {
|
|
1679
|
+
nested1: {
|
|
1680
|
+
insert: {
|
|
1681
|
+
"NodeProperty": {
|
|
1682
|
+
nested2: {
|
|
1683
|
+
insert: {
|
|
1684
|
+
String: {
|
|
1685
|
+
string: "text",
|
|
1572
1686
|
},
|
|
1573
1687
|
},
|
|
1574
1688
|
},
|
|
1575
1689
|
},
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1690
|
+
"array<>": {
|
|
1691
|
+
nestedArray: {
|
|
1692
|
+
insert: [
|
|
1579
1693
|
[
|
|
1580
1694
|
0,
|
|
1581
1695
|
[
|
|
1582
1696
|
{
|
|
1583
|
-
|
|
1697
|
+
typeid: "NodeProperty",
|
|
1584
1698
|
},
|
|
1585
1699
|
{
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1700
|
+
typeid: "NodeProperty",
|
|
1701
|
+
insert: {
|
|
1702
|
+
String: {
|
|
1703
|
+
text: "",
|
|
1590
1704
|
},
|
|
1591
1705
|
},
|
|
1592
1706
|
},
|
|
@@ -1595,101 +1709,101 @@ describe('Utils', function () {
|
|
|
1595
1709
|
],
|
|
1596
1710
|
},
|
|
1597
1711
|
},
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1712
|
+
"map<>": {
|
|
1713
|
+
trulyNestedMap: {
|
|
1714
|
+
insert: {
|
|
1715
|
+
String: {
|
|
1716
|
+
key1: "The value is 1",
|
|
1603
1717
|
},
|
|
1604
1718
|
},
|
|
1605
1719
|
},
|
|
1606
1720
|
},
|
|
1607
1721
|
},
|
|
1608
1722
|
},
|
|
1609
|
-
|
|
1723
|
+
nested3: {},
|
|
1610
1724
|
},
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1725
|
+
"map<>": {
|
|
1726
|
+
nestedMap: {
|
|
1727
|
+
insert: {
|
|
1728
|
+
String: {
|
|
1729
|
+
nestedMapString: "Sirius",
|
|
1616
1730
|
},
|
|
1617
|
-
|
|
1618
|
-
|
|
1731
|
+
Bool: {
|
|
1732
|
+
nestedMapBoolean: true,
|
|
1619
1733
|
},
|
|
1620
1734
|
},
|
|
1621
1735
|
},
|
|
1622
1736
|
},
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1737
|
+
"map<mysample:asset-1.0.0>": {
|
|
1738
|
+
assetMap: {
|
|
1739
|
+
insert: {
|
|
1740
|
+
"mysample:asset-1.0.0": {
|
|
1741
|
+
1: {
|
|
1742
|
+
String: {
|
|
1743
|
+
name: "test asset 1",
|
|
1630
1744
|
},
|
|
1631
|
-
|
|
1632
|
-
|
|
1745
|
+
NodeProperty: {
|
|
1746
|
+
components: {},
|
|
1633
1747
|
},
|
|
1634
1748
|
},
|
|
1635
1749
|
},
|
|
1636
1750
|
},
|
|
1637
1751
|
},
|
|
1638
1752
|
},
|
|
1639
|
-
|
|
1640
|
-
|
|
1753
|
+
"Reference<String>": {
|
|
1754
|
+
refProp: "/test.prop",
|
|
1641
1755
|
},
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1756
|
+
"RepositoryReferenceProperty": {
|
|
1757
|
+
refRepoProp: {
|
|
1758
|
+
Bool: {
|
|
1759
|
+
followBranch: false,
|
|
1646
1760
|
},
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1761
|
+
String: {
|
|
1762
|
+
branchGUID: "846fe4a1-e595-44bf-8cc0-f1d8f6d104a6",
|
|
1763
|
+
commitGUID: "4c611c89-8241-4764-958e-77470bba3b9b",
|
|
1764
|
+
repositoryGUID: "f438bed5-d8f2-4c70-a7e0-aa52b8929d2a",
|
|
1651
1765
|
},
|
|
1652
1766
|
},
|
|
1653
1767
|
},
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1768
|
+
"NamedProperty": {
|
|
1769
|
+
namedProp: {
|
|
1770
|
+
String: {
|
|
1771
|
+
guid: "e763527c-7f49-417c-8df3-9fb7f90a1932",
|
|
1658
1772
|
},
|
|
1659
1773
|
},
|
|
1660
1774
|
},
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1775
|
+
"NamedNodeProperty": {
|
|
1776
|
+
namedNodeProp: {
|
|
1777
|
+
String: {
|
|
1778
|
+
guid: "efc68477-53b1-49ac-bd3f-e05a21f85a32",
|
|
1665
1779
|
},
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1780
|
+
insert: {
|
|
1781
|
+
"enum<autodesk.core:UnitsEnum-1.0.0>": {
|
|
1782
|
+
enumProp: 0,
|
|
1669
1783
|
},
|
|
1670
|
-
|
|
1671
|
-
|
|
1784
|
+
"String": {
|
|
1785
|
+
test: "blah",
|
|
1672
1786
|
},
|
|
1673
1787
|
},
|
|
1674
1788
|
},
|
|
1675
1789
|
},
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1790
|
+
"autodesk.test:testProp-1.0.0": {
|
|
1791
|
+
customTemplate: {
|
|
1792
|
+
"Uint32": {
|
|
1793
|
+
a: 922337203685,
|
|
1680
1794
|
},
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1795
|
+
"String": {
|
|
1796
|
+
"b": "hello",
|
|
1797
|
+
"nested.c.d.e": "world",
|
|
1798
|
+
"nested.c.d.f": "hello",
|
|
1685
1799
|
},
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1800
|
+
"set<NamedProperty>": {
|
|
1801
|
+
nestedSet: {
|
|
1802
|
+
insert: {
|
|
1803
|
+
NamedProperty: {
|
|
1804
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
1805
|
+
String: {
|
|
1806
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
1693
1807
|
},
|
|
1694
1808
|
},
|
|
1695
1809
|
},
|
|
@@ -1698,61 +1812,63 @@ describe('Utils', function () {
|
|
|
1698
1812
|
},
|
|
1699
1813
|
},
|
|
1700
1814
|
},
|
|
1701
|
-
|
|
1702
|
-
|
|
1815
|
+
"String": {
|
|
1816
|
+
emptyString: "",
|
|
1703
1817
|
},
|
|
1704
1818
|
},
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1819
|
+
modify: {
|
|
1820
|
+
"NodeProperty": {
|
|
1821
|
+
nested4: {
|
|
1822
|
+
insert: {
|
|
1823
|
+
Uint32: {
|
|
1824
|
+
number: 4,
|
|
1711
1825
|
},
|
|
1712
1826
|
},
|
|
1713
|
-
|
|
1827
|
+
remove: ["nested5", "nested6"],
|
|
1714
1828
|
},
|
|
1715
1829
|
},
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1830
|
+
"array<Float32>": {
|
|
1831
|
+
nestedArray2: {
|
|
1832
|
+
modify: [[0, [0.707, 0.707, 0], [0, 0, 1]]],
|
|
1719
1833
|
},
|
|
1720
1834
|
},
|
|
1721
1835
|
},
|
|
1722
|
-
|
|
1723
|
-
'nested7',
|
|
1724
|
-
],
|
|
1836
|
+
remove: ["nested7"],
|
|
1725
1837
|
};
|
|
1726
|
-
it(
|
|
1727
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1838
|
+
it("should filter change sets by paths resolving to all types (NodeProperty, array, map, set, NamedNodeProperty, Reference, Primitive types)", function () {
|
|
1839
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1840
|
+
"nested1",
|
|
1841
|
+
"nested4.nested5",
|
|
1842
|
+
"nested4.number",
|
|
1843
|
+
]);
|
|
1728
1844
|
expect(filteredCS).to.eql({
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1845
|
+
insert: {
|
|
1846
|
+
NodeProperty: {
|
|
1847
|
+
nested1: {
|
|
1848
|
+
insert: {
|
|
1849
|
+
"NodeProperty": {
|
|
1850
|
+
nested2: {
|
|
1851
|
+
insert: {
|
|
1852
|
+
String: {
|
|
1853
|
+
string: "text",
|
|
1738
1854
|
},
|
|
1739
1855
|
},
|
|
1740
1856
|
},
|
|
1741
1857
|
},
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1858
|
+
"array<>": {
|
|
1859
|
+
nestedArray: {
|
|
1860
|
+
insert: [
|
|
1745
1861
|
[
|
|
1746
1862
|
0,
|
|
1747
1863
|
[
|
|
1748
1864
|
{
|
|
1749
|
-
|
|
1865
|
+
typeid: "NodeProperty",
|
|
1750
1866
|
},
|
|
1751
1867
|
{
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1868
|
+
typeid: "NodeProperty",
|
|
1869
|
+
insert: {
|
|
1870
|
+
String: {
|
|
1871
|
+
text: "",
|
|
1756
1872
|
},
|
|
1757
1873
|
},
|
|
1758
1874
|
},
|
|
@@ -1761,11 +1877,11 @@ describe('Utils', function () {
|
|
|
1761
1877
|
],
|
|
1762
1878
|
},
|
|
1763
1879
|
},
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1880
|
+
"map<>": {
|
|
1881
|
+
trulyNestedMap: {
|
|
1882
|
+
insert: {
|
|
1883
|
+
String: {
|
|
1884
|
+
key1: "The value is 1",
|
|
1769
1885
|
},
|
|
1770
1886
|
},
|
|
1771
1887
|
},
|
|
@@ -1774,30 +1890,34 @@ describe('Utils', function () {
|
|
|
1774
1890
|
},
|
|
1775
1891
|
},
|
|
1776
1892
|
},
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1893
|
+
modify: {
|
|
1894
|
+
NodeProperty: {
|
|
1895
|
+
nested4: {
|
|
1896
|
+
remove: ["nested5"],
|
|
1897
|
+
insert: {
|
|
1898
|
+
Uint32: {
|
|
1899
|
+
number: 4,
|
|
1784
1900
|
},
|
|
1785
1901
|
},
|
|
1786
1902
|
},
|
|
1787
1903
|
},
|
|
1788
1904
|
},
|
|
1789
1905
|
});
|
|
1790
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1906
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1907
|
+
"nested7",
|
|
1908
|
+
"nested4",
|
|
1909
|
+
"nested1.nested2",
|
|
1910
|
+
]);
|
|
1791
1911
|
expect(filteredCS).to.eql({
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1912
|
+
insert: {
|
|
1913
|
+
NodeProperty: {
|
|
1914
|
+
nested1: {
|
|
1915
|
+
insert: {
|
|
1916
|
+
NodeProperty: {
|
|
1917
|
+
nested2: {
|
|
1918
|
+
insert: {
|
|
1919
|
+
String: {
|
|
1920
|
+
string: "text",
|
|
1801
1921
|
},
|
|
1802
1922
|
},
|
|
1803
1923
|
},
|
|
@@ -1806,42 +1926,44 @@ describe('Utils', function () {
|
|
|
1806
1926
|
},
|
|
1807
1927
|
},
|
|
1808
1928
|
},
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1929
|
+
modify: {
|
|
1930
|
+
NodeProperty: {
|
|
1931
|
+
nested4: {
|
|
1932
|
+
insert: {
|
|
1933
|
+
Uint32: {
|
|
1934
|
+
number: 4,
|
|
1815
1935
|
},
|
|
1816
1936
|
},
|
|
1817
|
-
|
|
1937
|
+
remove: ["nested5", "nested6"],
|
|
1818
1938
|
},
|
|
1819
1939
|
},
|
|
1820
1940
|
},
|
|
1821
|
-
|
|
1822
|
-
'nested7',
|
|
1823
|
-
],
|
|
1941
|
+
remove: ["nested7"],
|
|
1824
1942
|
});
|
|
1825
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1943
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1944
|
+
"nested1.nestedArray",
|
|
1945
|
+
"nestedMap.nestedMapBoolean",
|
|
1946
|
+
"nestedArray2",
|
|
1947
|
+
]);
|
|
1826
1948
|
expect(filteredCS).to.eql({
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1949
|
+
insert: {
|
|
1950
|
+
"NodeProperty": {
|
|
1951
|
+
nested1: {
|
|
1952
|
+
insert: {
|
|
1953
|
+
"array<>": {
|
|
1954
|
+
nestedArray: {
|
|
1955
|
+
insert: [
|
|
1834
1956
|
[
|
|
1835
1957
|
0,
|
|
1836
1958
|
[
|
|
1837
1959
|
{
|
|
1838
|
-
|
|
1960
|
+
typeid: "NodeProperty",
|
|
1839
1961
|
},
|
|
1840
1962
|
{
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1963
|
+
typeid: "NodeProperty",
|
|
1964
|
+
insert: {
|
|
1965
|
+
String: {
|
|
1966
|
+
text: "",
|
|
1845
1967
|
},
|
|
1846
1968
|
},
|
|
1847
1969
|
},
|
|
@@ -1853,66 +1975,74 @@ describe('Utils', function () {
|
|
|
1853
1975
|
},
|
|
1854
1976
|
},
|
|
1855
1977
|
},
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1978
|
+
"map<>": {
|
|
1979
|
+
nestedMap: {
|
|
1980
|
+
insert: {
|
|
1981
|
+
Bool: {
|
|
1982
|
+
nestedMapBoolean: true,
|
|
1861
1983
|
},
|
|
1862
1984
|
},
|
|
1863
1985
|
},
|
|
1864
1986
|
},
|
|
1865
1987
|
},
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1988
|
+
modify: {
|
|
1989
|
+
"array<Float32>": {
|
|
1990
|
+
nestedArray2: {
|
|
1991
|
+
modify: [[0, [0.707, 0.707, 0], [0, 0, 1]]],
|
|
1870
1992
|
},
|
|
1871
1993
|
},
|
|
1872
1994
|
},
|
|
1873
1995
|
});
|
|
1874
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1996
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
1997
|
+
"namedProp.guid",
|
|
1998
|
+
"namedNodeProp.enumProp",
|
|
1999
|
+
"namedNodeProp.guid",
|
|
2000
|
+
]);
|
|
1875
2001
|
expect(filteredCS).to.eql({
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
2002
|
+
insert: {
|
|
2003
|
+
NamedProperty: {
|
|
2004
|
+
namedProp: {
|
|
2005
|
+
String: {
|
|
2006
|
+
guid: "e763527c-7f49-417c-8df3-9fb7f90a1932",
|
|
1881
2007
|
},
|
|
1882
2008
|
},
|
|
1883
2009
|
},
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
},
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2010
|
+
NamedNodeProperty: {
|
|
2011
|
+
namedNodeProp: {
|
|
2012
|
+
String: {
|
|
2013
|
+
guid: "efc68477-53b1-49ac-bd3f-e05a21f85a32",
|
|
2014
|
+
},
|
|
2015
|
+
insert: {
|
|
2016
|
+
"enum<autodesk.core:UnitsEnum-1.0.0>": {
|
|
2017
|
+
enumProp: 0,
|
|
1892
2018
|
},
|
|
1893
2019
|
},
|
|
1894
2020
|
},
|
|
1895
2021
|
},
|
|
1896
2022
|
},
|
|
1897
2023
|
});
|
|
1898
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2024
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2025
|
+
"customTemplate.a",
|
|
2026
|
+
"customTemplate.nested.c.d.e",
|
|
2027
|
+
"customTemplate.nestedSet",
|
|
2028
|
+
]);
|
|
1899
2029
|
expect(filteredCS).to.eql({
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
},
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
},
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2030
|
+
insert: {
|
|
2031
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2032
|
+
customTemplate: {
|
|
2033
|
+
"Uint32": {
|
|
2034
|
+
a: 922337203685,
|
|
2035
|
+
},
|
|
2036
|
+
"String": {
|
|
2037
|
+
"nested.c.d.e": "world",
|
|
2038
|
+
},
|
|
2039
|
+
"set<NamedProperty>": {
|
|
2040
|
+
nestedSet: {
|
|
2041
|
+
insert: {
|
|
2042
|
+
NamedProperty: {
|
|
2043
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
2044
|
+
String: {
|
|
2045
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
1916
2046
|
},
|
|
1917
2047
|
},
|
|
1918
2048
|
},
|
|
@@ -1923,36 +2053,36 @@ describe('Utils', function () {
|
|
|
1923
2053
|
},
|
|
1924
2054
|
},
|
|
1925
2055
|
});
|
|
1926
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, new Map([
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
['nestedSet', new Map()],
|
|
2056
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, new Map([
|
|
2057
|
+
[
|
|
2058
|
+
"customTemplate",
|
|
2059
|
+
new Map([
|
|
2060
|
+
["a", new Map()],
|
|
2061
|
+
[
|
|
2062
|
+
"nested",
|
|
2063
|
+
new Map([["c", new Map([["d", new Map([["e", new Map()]])]])]]),
|
|
2064
|
+
],
|
|
2065
|
+
["nestedSet", new Map()],
|
|
1937
2066
|
]),
|
|
1938
|
-
]
|
|
2067
|
+
],
|
|
2068
|
+
]));
|
|
1939
2069
|
expect(filteredCS).to.eql({
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
},
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
},
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2070
|
+
insert: {
|
|
2071
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2072
|
+
customTemplate: {
|
|
2073
|
+
"Uint32": {
|
|
2074
|
+
a: 922337203685,
|
|
2075
|
+
},
|
|
2076
|
+
"String": {
|
|
2077
|
+
"nested.c.d.e": "world",
|
|
2078
|
+
},
|
|
2079
|
+
"set<NamedProperty>": {
|
|
2080
|
+
nestedSet: {
|
|
2081
|
+
insert: {
|
|
2082
|
+
NamedProperty: {
|
|
2083
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
2084
|
+
String: {
|
|
2085
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
1956
2086
|
},
|
|
1957
2087
|
},
|
|
1958
2088
|
},
|
|
@@ -1963,60 +2093,68 @@ describe('Utils', function () {
|
|
|
1963
2093
|
},
|
|
1964
2094
|
},
|
|
1965
2095
|
});
|
|
1966
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2096
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2097
|
+
"customTemplate.nested.c",
|
|
2098
|
+
]);
|
|
1967
2099
|
expect(filteredCS).to.eql({
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
2100
|
+
insert: {
|
|
2101
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2102
|
+
customTemplate: {
|
|
2103
|
+
String: {
|
|
2104
|
+
"nested.c.d.e": "world",
|
|
2105
|
+
"nested.c.d.f": "hello",
|
|
1974
2106
|
},
|
|
1975
2107
|
},
|
|
1976
2108
|
},
|
|
1977
2109
|
},
|
|
1978
2110
|
});
|
|
1979
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2111
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2112
|
+
"customTemplate.nested.c.d",
|
|
2113
|
+
]);
|
|
1980
2114
|
expect(filteredCS).to.eql({
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2115
|
+
insert: {
|
|
2116
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2117
|
+
customTemplate: {
|
|
2118
|
+
String: {
|
|
2119
|
+
"nested.c.d.e": "world",
|
|
2120
|
+
"nested.c.d.f": "hello",
|
|
1987
2121
|
},
|
|
1988
2122
|
},
|
|
1989
2123
|
},
|
|
1990
2124
|
},
|
|
1991
2125
|
});
|
|
1992
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2126
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2127
|
+
"refProp",
|
|
2128
|
+
"refRepoProp.commitGUID",
|
|
2129
|
+
"refRepoProp.followBranch",
|
|
2130
|
+
]);
|
|
1993
2131
|
expect(filteredCS).to.eql({
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2132
|
+
insert: {
|
|
2133
|
+
"Reference<String>": {
|
|
2134
|
+
refProp: "/test.prop",
|
|
1997
2135
|
},
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2136
|
+
"RepositoryReferenceProperty": {
|
|
2137
|
+
refRepoProp: {
|
|
2138
|
+
Bool: {
|
|
2139
|
+
followBranch: false,
|
|
2002
2140
|
},
|
|
2003
|
-
|
|
2004
|
-
|
|
2141
|
+
String: {
|
|
2142
|
+
commitGUID: "4c611c89-8241-4764-958e-77470bba3b9b",
|
|
2005
2143
|
},
|
|
2006
2144
|
},
|
|
2007
2145
|
},
|
|
2008
2146
|
},
|
|
2009
2147
|
});
|
|
2010
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2148
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ["assetMap[1].name"]);
|
|
2011
2149
|
expect(filteredCS).to.eql({
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2150
|
+
insert: {
|
|
2151
|
+
"map<mysample:asset-1.0.0>": {
|
|
2152
|
+
assetMap: {
|
|
2153
|
+
insert: {
|
|
2154
|
+
"mysample:asset-1.0.0": {
|
|
2155
|
+
1: {
|
|
2156
|
+
String: {
|
|
2157
|
+
name: "test asset 1",
|
|
2020
2158
|
},
|
|
2021
2159
|
},
|
|
2022
2160
|
},
|
|
@@ -2026,16 +2164,16 @@ describe('Utils', function () {
|
|
|
2026
2164
|
},
|
|
2027
2165
|
});
|
|
2028
2166
|
// For maps, using dots as separators, instead of brackets, is also supported.
|
|
2029
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2167
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ["assetMap.1.name"]);
|
|
2030
2168
|
expect(filteredCS).to.eql({
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2169
|
+
insert: {
|
|
2170
|
+
"map<mysample:asset-1.0.0>": {
|
|
2171
|
+
assetMap: {
|
|
2172
|
+
insert: {
|
|
2173
|
+
"mysample:asset-1.0.0": {
|
|
2174
|
+
1: {
|
|
2175
|
+
String: {
|
|
2176
|
+
name: "test asset 1",
|
|
2039
2177
|
},
|
|
2040
2178
|
},
|
|
2041
2179
|
},
|
|
@@ -2045,27 +2183,32 @@ describe('Utils', function () {
|
|
|
2045
2183
|
},
|
|
2046
2184
|
});
|
|
2047
2185
|
});
|
|
2048
|
-
it(
|
|
2049
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2186
|
+
it("should ignore overlapping paths", function () {
|
|
2187
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2188
|
+
"customTemplate",
|
|
2189
|
+
"customTemplate.a",
|
|
2190
|
+
"customTemplate.nested.c.d.e",
|
|
2191
|
+
"customTemplate.nestedSet",
|
|
2192
|
+
]);
|
|
2050
2193
|
expect(filteredCS).to.eql({
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
},
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
},
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2194
|
+
insert: {
|
|
2195
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2196
|
+
customTemplate: {
|
|
2197
|
+
"Uint32": {
|
|
2198
|
+
a: 922337203685,
|
|
2199
|
+
},
|
|
2200
|
+
"String": {
|
|
2201
|
+
"b": "hello",
|
|
2202
|
+
"nested.c.d.e": "world",
|
|
2203
|
+
"nested.c.d.f": "hello",
|
|
2204
|
+
},
|
|
2205
|
+
"set<NamedProperty>": {
|
|
2206
|
+
nestedSet: {
|
|
2207
|
+
insert: {
|
|
2208
|
+
NamedProperty: {
|
|
2209
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
2210
|
+
String: {
|
|
2211
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
2069
2212
|
},
|
|
2070
2213
|
},
|
|
2071
2214
|
},
|
|
@@ -2076,18 +2219,20 @@ describe('Utils', function () {
|
|
|
2076
2219
|
},
|
|
2077
2220
|
},
|
|
2078
2221
|
});
|
|
2079
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2222
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2223
|
+
"customTemplate.nestedSet[91a59cb6-9881-2b5f-2366-84dbdc8b6838].guid",
|
|
2224
|
+
]);
|
|
2080
2225
|
expect(filteredCS).to.eql({
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2226
|
+
insert: {
|
|
2227
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2228
|
+
customTemplate: {
|
|
2229
|
+
"set<NamedProperty>": {
|
|
2230
|
+
nestedSet: {
|
|
2231
|
+
insert: {
|
|
2232
|
+
NamedProperty: {
|
|
2233
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
2234
|
+
String: {
|
|
2235
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
2091
2236
|
},
|
|
2092
2237
|
},
|
|
2093
2238
|
},
|
|
@@ -2099,26 +2244,31 @@ describe('Utils', function () {
|
|
|
2099
2244
|
},
|
|
2100
2245
|
});
|
|
2101
2246
|
// Flip order
|
|
2102
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2247
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2248
|
+
"customTemplate.a",
|
|
2249
|
+
"customTemplate.nested.c.d.e",
|
|
2250
|
+
"customTemplate",
|
|
2251
|
+
"customTemplate.nestedSet",
|
|
2252
|
+
]);
|
|
2103
2253
|
expect(filteredCS).to.eql({
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
},
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
},
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2254
|
+
insert: {
|
|
2255
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2256
|
+
customTemplate: {
|
|
2257
|
+
"Uint32": {
|
|
2258
|
+
a: 922337203685,
|
|
2259
|
+
},
|
|
2260
|
+
"String": {
|
|
2261
|
+
"b": "hello",
|
|
2262
|
+
"nested.c.d.e": "world",
|
|
2263
|
+
"nested.c.d.f": "hello",
|
|
2264
|
+
},
|
|
2265
|
+
"set<NamedProperty>": {
|
|
2266
|
+
nestedSet: {
|
|
2267
|
+
insert: {
|
|
2268
|
+
NamedProperty: {
|
|
2269
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
2270
|
+
String: {
|
|
2271
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
2122
2272
|
},
|
|
2123
2273
|
},
|
|
2124
2274
|
},
|
|
@@ -2130,26 +2280,32 @@ describe('Utils', function () {
|
|
|
2130
2280
|
},
|
|
2131
2281
|
});
|
|
2132
2282
|
// Duplicate paths
|
|
2133
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2283
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2284
|
+
"customTemplate.a",
|
|
2285
|
+
"customTemplate",
|
|
2286
|
+
"customTemplate.nested.c.d.e",
|
|
2287
|
+
"customTemplate",
|
|
2288
|
+
"customTemplate.nestedSet",
|
|
2289
|
+
]);
|
|
2134
2290
|
expect(filteredCS).to.eql({
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
},
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
},
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2291
|
+
insert: {
|
|
2292
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2293
|
+
customTemplate: {
|
|
2294
|
+
"Uint32": {
|
|
2295
|
+
a: 922337203685,
|
|
2296
|
+
},
|
|
2297
|
+
"String": {
|
|
2298
|
+
"b": "hello",
|
|
2299
|
+
"nested.c.d.e": "world",
|
|
2300
|
+
"nested.c.d.f": "hello",
|
|
2301
|
+
},
|
|
2302
|
+
"set<NamedProperty>": {
|
|
2303
|
+
nestedSet: {
|
|
2304
|
+
insert: {
|
|
2305
|
+
NamedProperty: {
|
|
2306
|
+
"91a59cb6-9881-2b5f-2366-84dbdc8b6838": {
|
|
2307
|
+
String: {
|
|
2308
|
+
guid: "91a59cb6-9881-2b5f-2366-84dbdc8b6838",
|
|
2153
2309
|
},
|
|
2154
2310
|
},
|
|
2155
2311
|
},
|
|
@@ -2160,29 +2316,40 @@ describe('Utils', function () {
|
|
|
2160
2316
|
},
|
|
2161
2317
|
},
|
|
2162
2318
|
});
|
|
2163
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2319
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ["emptyString"]);
|
|
2164
2320
|
expect(filteredCS).to.eql({
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2321
|
+
insert: {
|
|
2322
|
+
String: {
|
|
2323
|
+
emptyString: "",
|
|
2168
2324
|
},
|
|
2169
2325
|
},
|
|
2170
2326
|
});
|
|
2171
2327
|
});
|
|
2172
|
-
it(
|
|
2173
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2328
|
+
it("should return an empty change set when filtering by a path that does not exist", function () {
|
|
2329
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2330
|
+
"path.that.does.not.exist",
|
|
2331
|
+
"dontExist",
|
|
2332
|
+
"does.not.exist",
|
|
2333
|
+
]);
|
|
2174
2334
|
expect(filteredCS).to.be.eql({});
|
|
2175
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2335
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2336
|
+
"nested7",
|
|
2337
|
+
"nested4",
|
|
2338
|
+
"nested1.nested2",
|
|
2339
|
+
"path.that.does.not.exist",
|
|
2340
|
+
"dontExist",
|
|
2341
|
+
"does.not.exist",
|
|
2342
|
+
]);
|
|
2176
2343
|
expect(filteredCS).to.eql({
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2344
|
+
insert: {
|
|
2345
|
+
NodeProperty: {
|
|
2346
|
+
nested1: {
|
|
2347
|
+
insert: {
|
|
2348
|
+
NodeProperty: {
|
|
2349
|
+
nested2: {
|
|
2350
|
+
insert: {
|
|
2351
|
+
String: {
|
|
2352
|
+
string: "text",
|
|
2186
2353
|
},
|
|
2187
2354
|
},
|
|
2188
2355
|
},
|
|
@@ -2191,33 +2358,34 @@ describe('Utils', function () {
|
|
|
2191
2358
|
},
|
|
2192
2359
|
},
|
|
2193
2360
|
},
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2361
|
+
modify: {
|
|
2362
|
+
NodeProperty: {
|
|
2363
|
+
nested4: {
|
|
2364
|
+
insert: {
|
|
2365
|
+
Uint32: {
|
|
2366
|
+
number: 4,
|
|
2200
2367
|
},
|
|
2201
2368
|
},
|
|
2202
|
-
|
|
2369
|
+
remove: ["nested5", "nested6"],
|
|
2203
2370
|
},
|
|
2204
2371
|
},
|
|
2205
2372
|
},
|
|
2206
|
-
|
|
2207
|
-
'nested7',
|
|
2208
|
-
],
|
|
2373
|
+
remove: ["nested7"],
|
|
2209
2374
|
});
|
|
2210
|
-
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2375
|
+
filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2376
|
+
"nested1.nested2",
|
|
2377
|
+
"nested1.nested6",
|
|
2378
|
+
]);
|
|
2211
2379
|
expect(filteredCS).to.eql({
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2380
|
+
insert: {
|
|
2381
|
+
NodeProperty: {
|
|
2382
|
+
nested1: {
|
|
2383
|
+
insert: {
|
|
2384
|
+
NodeProperty: {
|
|
2385
|
+
nested2: {
|
|
2386
|
+
insert: {
|
|
2387
|
+
String: {
|
|
2388
|
+
string: "text",
|
|
2221
2389
|
},
|
|
2222
2390
|
},
|
|
2223
2391
|
},
|
|
@@ -2228,32 +2396,36 @@ describe('Utils', function () {
|
|
|
2228
2396
|
},
|
|
2229
2397
|
});
|
|
2230
2398
|
// Partially matched paths are included
|
|
2231
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2399
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ["assetMap[2]"]);
|
|
2232
2400
|
expect(filteredCS).to.eql({
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2401
|
+
insert: {
|
|
2402
|
+
"map<mysample:asset-1.0.0>": {
|
|
2403
|
+
assetMap: {},
|
|
2236
2404
|
},
|
|
2237
2405
|
},
|
|
2238
2406
|
});
|
|
2239
2407
|
// Closest partially matched path 'customTemplate.nested.c.d' cannot be included
|
|
2240
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2408
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2409
|
+
"customTemplate.nested.c.d.g",
|
|
2410
|
+
]);
|
|
2241
2411
|
expect(filteredCS).to.eql({
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2412
|
+
insert: {
|
|
2413
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2414
|
+
customTemplate: {},
|
|
2245
2415
|
},
|
|
2246
2416
|
},
|
|
2247
2417
|
});
|
|
2248
2418
|
// Partial match should also work with nested properties
|
|
2249
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2419
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2420
|
+
"nested1.trulyNestedMap[newKey]",
|
|
2421
|
+
]);
|
|
2250
2422
|
expect(filteredCS).to.eql({
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2423
|
+
insert: {
|
|
2424
|
+
NodeProperty: {
|
|
2425
|
+
nested1: {
|
|
2426
|
+
insert: {
|
|
2427
|
+
"map<>": {
|
|
2428
|
+
trulyNestedMap: {},
|
|
2257
2429
|
},
|
|
2258
2430
|
},
|
|
2259
2431
|
},
|
|
@@ -2261,105 +2433,120 @@ describe('Utils', function () {
|
|
|
2261
2433
|
},
|
|
2262
2434
|
});
|
|
2263
2435
|
// Filter a nested non existing entry from a templated property
|
|
2264
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2436
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2437
|
+
"customTemplate.nestedSet.nonExisting",
|
|
2438
|
+
"customTemplate.a",
|
|
2439
|
+
]);
|
|
2265
2440
|
expect(filteredCS).to.eql({
|
|
2266
2441
|
insert: {
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2442
|
+
"autodesk.test:testProp-1.0.0": {
|
|
2443
|
+
customTemplate: {
|
|
2444
|
+
"Uint32": {
|
|
2445
|
+
a: 922337203685,
|
|
2271
2446
|
},
|
|
2272
|
-
|
|
2273
|
-
|
|
2447
|
+
"set<NamedProperty>": {
|
|
2448
|
+
nestedSet: {},
|
|
2274
2449
|
},
|
|
2275
2450
|
},
|
|
2276
2451
|
},
|
|
2277
2452
|
},
|
|
2278
2453
|
});
|
|
2279
2454
|
// Make sure, nested removes are treated correctly
|
|
2280
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, [
|
|
2455
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ["nested7.abcd"]);
|
|
2281
2456
|
expect(filteredCS).to.eql({
|
|
2282
|
-
|
|
2457
|
+
remove: ["nested7"],
|
|
2283
2458
|
});
|
|
2284
2459
|
});
|
|
2285
|
-
it(
|
|
2286
|
-
var failedFilteredFunc = Utils.getFilteredChangeSetByPaths.bind(null, changeSet, [
|
|
2460
|
+
it("should fail filtering change sets with paths that resolve into arrays and sets", function () {
|
|
2461
|
+
var failedFilteredFunc = Utils.getFilteredChangeSetByPaths.bind(null, changeSet, [
|
|
2462
|
+
"nested1.nestedArray[0]",
|
|
2463
|
+
]);
|
|
2287
2464
|
expect(failedFilteredFunc).to.throw(Error, MSG.FILTER_PATH_WITHIN_ARRAY);
|
|
2288
2465
|
// With valid paths
|
|
2289
|
-
failedFilteredFunc = Utils.getFilteredChangeSetByPaths.bind(null, changeSet, [
|
|
2466
|
+
failedFilteredFunc = Utils.getFilteredChangeSetByPaths.bind(null, changeSet, [
|
|
2467
|
+
"customTemplate",
|
|
2468
|
+
"nested1.nestedArray[0]",
|
|
2469
|
+
]);
|
|
2290
2470
|
expect(failedFilteredFunc).to.throw(Error, MSG.FILTER_PATH_WITHIN_ARRAY);
|
|
2291
2471
|
});
|
|
2292
|
-
it(
|
|
2293
|
-
var node = PropertyFactory.create(
|
|
2294
|
-
node.insert('."test".', PropertyFactory.create(
|
|
2295
|
-
node.get('."test".').insert(
|
|
2472
|
+
it("should work for ChangeSet with segments requiring escapes for NodeProperties", function () {
|
|
2473
|
+
var node = PropertyFactory.create("NodeProperty");
|
|
2474
|
+
node.insert('."test".', PropertyFactory.create("NodeProperty"));
|
|
2475
|
+
node.get('."test".').insert("[abcd]", PropertyFactory.create("String", undefined, "test"));
|
|
2296
2476
|
var CS = node.serialize();
|
|
2297
2477
|
var filteredCS = Utils.getFilteredChangeSetByPaths(CS, ['".\\"test\\"."."[abcd]"']);
|
|
2298
2478
|
expect(filteredCS).to.deep.equal(CS);
|
|
2299
2479
|
node.cleanDirty();
|
|
2300
|
-
node.get('."test".').get(
|
|
2480
|
+
node.get('."test".').get("[abcd]").setValue("test2");
|
|
2301
2481
|
// Test a modification
|
|
2302
2482
|
CS = node.serialize({ dirtyOnly: true });
|
|
2303
2483
|
filteredCS = Utils.getFilteredChangeSetByPaths(CS, ['".\\"test\\"."."[abcd]"']);
|
|
2304
2484
|
expect(filteredCS).to.deep.equal(CS);
|
|
2305
2485
|
// Test a removal
|
|
2306
2486
|
node.cleanDirty();
|
|
2307
|
-
node.get('."test".').remove(
|
|
2487
|
+
node.get('."test".').remove("[abcd]");
|
|
2308
2488
|
CS = node.serialize({ dirtyOnly: true });
|
|
2309
2489
|
filteredCS = Utils.getFilteredChangeSetByPaths(CS, ['".\\"test\\"."']);
|
|
2310
2490
|
expect(filteredCS).to.deep.equal(CS);
|
|
2311
2491
|
});
|
|
2312
|
-
it(
|
|
2313
|
-
var node = PropertyFactory.create(
|
|
2492
|
+
it("should work for ChangeSet with segments requiring escapes in template", function () {
|
|
2493
|
+
var node = PropertyFactory.create("autodesk.tests:property.with.quotable.characters-1.0.0");
|
|
2314
2494
|
node.cleanDirty();
|
|
2315
|
-
node.get([
|
|
2495
|
+
node.get(["test[property]", ".property."]).get("test").value = "test";
|
|
2316
2496
|
var CS = node.serialize({ dirtyOnly: true });
|
|
2317
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(CS, [
|
|
2497
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(CS, [
|
|
2498
|
+
'"test[property]".".property."',
|
|
2499
|
+
]);
|
|
2318
2500
|
expect(filteredCS).to.deep.equal(CS);
|
|
2319
2501
|
});
|
|
2320
|
-
it(
|
|
2502
|
+
it("should work for reversible ChangeSet", function () {
|
|
2321
2503
|
var originalChangeSet = {
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2504
|
+
insert: {
|
|
2505
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
2506
|
+
F: { String: { stringProperty: "" } },
|
|
2325
2507
|
},
|
|
2326
2508
|
},
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2509
|
+
remove: ["B", "C"],
|
|
2510
|
+
modify: {
|
|
2511
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
2512
|
+
A: { String: { stringProperty: "hello" } },
|
|
2331
2513
|
},
|
|
2332
2514
|
},
|
|
2333
2515
|
};
|
|
2334
2516
|
var parentChangeSet = {
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2517
|
+
insert: {
|
|
2518
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
2519
|
+
A: { String: { stringProperty: "" } },
|
|
2520
|
+
B: { String: { stringProperty: "" } },
|
|
2521
|
+
C: { String: { stringProperty: "" } },
|
|
2340
2522
|
},
|
|
2341
2523
|
},
|
|
2342
2524
|
};
|
|
2343
2525
|
var cs = new ChangeSet(originalChangeSet);
|
|
2344
2526
|
cs._toReversibleChangeSet(parentChangeSet);
|
|
2345
|
-
var filteredCS = Utils.getFilteredChangeSetByPaths(cs.getSerializedChangeSet(), [
|
|
2527
|
+
var filteredCS = Utils.getFilteredChangeSetByPaths(cs.getSerializedChangeSet(), [
|
|
2528
|
+
"A",
|
|
2529
|
+
"B",
|
|
2530
|
+
"F",
|
|
2531
|
+
]);
|
|
2346
2532
|
expect(filteredCS).to.eql({
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2533
|
+
insert: {
|
|
2534
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
2535
|
+
F: { String: { stringProperty: "" } },
|
|
2350
2536
|
},
|
|
2351
2537
|
},
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2538
|
+
remove: {
|
|
2539
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
2540
|
+
B: { String: { stringProperty: "" } },
|
|
2355
2541
|
},
|
|
2356
|
-
},
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2542
|
+
},
|
|
2543
|
+
modify: {
|
|
2544
|
+
"autodesk.tests:AnonymousMapTestPropertyID-1.0.0": {
|
|
2545
|
+
A: {
|
|
2546
|
+
String: {
|
|
2547
|
+
stringProperty: {
|
|
2548
|
+
value: "hello",
|
|
2549
|
+
oldValue: "",
|
|
2363
2550
|
},
|
|
2364
2551
|
},
|
|
2365
2552
|
},
|
|
@@ -2368,26 +2555,26 @@ describe('Utils', function () {
|
|
|
2368
2555
|
});
|
|
2369
2556
|
});
|
|
2370
2557
|
});
|
|
2371
|
-
describe(
|
|
2558
|
+
describe("Utils.getFilteredOutChangeSetByPaths", () => {
|
|
2372
2559
|
const changeset = {
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2560
|
+
insert: {
|
|
2561
|
+
"map<NodeProperty>": {
|
|
2562
|
+
assets: {
|
|
2563
|
+
insert: {
|
|
2564
|
+
"autodesk.test:sample-1.0.0": {
|
|
2565
|
+
Prop1: {
|
|
2566
|
+
String: {
|
|
2567
|
+
guid: "Prop1",
|
|
2381
2568
|
},
|
|
2382
2569
|
},
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2570
|
+
Prop2: {
|
|
2571
|
+
String: {
|
|
2572
|
+
guid: "Prop2",
|
|
2386
2573
|
},
|
|
2387
2574
|
},
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2575
|
+
Prop3: {
|
|
2576
|
+
String: {
|
|
2577
|
+
guid: "Prop3",
|
|
2391
2578
|
},
|
|
2392
2579
|
},
|
|
2393
2580
|
},
|
|
@@ -2397,19 +2584,19 @@ describe('Utils', function () {
|
|
|
2397
2584
|
},
|
|
2398
2585
|
};
|
|
2399
2586
|
const singleExclusion = {
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2587
|
+
insert: {
|
|
2588
|
+
"map<NodeProperty>": {
|
|
2589
|
+
assets: {
|
|
2590
|
+
insert: {
|
|
2591
|
+
"autodesk.test:sample-1.0.0": {
|
|
2592
|
+
Prop1: {
|
|
2593
|
+
String: {
|
|
2594
|
+
guid: "Prop1",
|
|
2408
2595
|
},
|
|
2409
2596
|
},
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2597
|
+
Prop2: {
|
|
2598
|
+
String: {
|
|
2599
|
+
guid: "Prop2",
|
|
2413
2600
|
},
|
|
2414
2601
|
},
|
|
2415
2602
|
},
|
|
@@ -2419,14 +2606,14 @@ describe('Utils', function () {
|
|
|
2419
2606
|
},
|
|
2420
2607
|
};
|
|
2421
2608
|
const multiExclusion = {
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2609
|
+
insert: {
|
|
2610
|
+
"map<NodeProperty>": {
|
|
2611
|
+
assets: {
|
|
2612
|
+
insert: {
|
|
2613
|
+
"autodesk.test:sample-1.0.0": {
|
|
2614
|
+
Prop1: {
|
|
2615
|
+
String: {
|
|
2616
|
+
guid: "Prop1",
|
|
2430
2617
|
},
|
|
2431
2618
|
},
|
|
2432
2619
|
},
|
|
@@ -2435,32 +2622,35 @@ describe('Utils', function () {
|
|
|
2435
2622
|
},
|
|
2436
2623
|
},
|
|
2437
2624
|
};
|
|
2438
|
-
it(
|
|
2439
|
-
let res = Utils.excludePathsFromChangeSet(changeset,
|
|
2625
|
+
it("should exclude single given path", () => {
|
|
2626
|
+
let res = Utils.excludePathsFromChangeSet(changeset, "assets[Prop3]");
|
|
2440
2627
|
expect(res).to.be.deep.equal(singleExclusion);
|
|
2441
2628
|
});
|
|
2442
|
-
it(
|
|
2443
|
-
let res = Utils.excludePathsFromChangeSet(changeset, [
|
|
2629
|
+
it("should exclude single given path in array", () => {
|
|
2630
|
+
let res = Utils.excludePathsFromChangeSet(changeset, ["assets[Prop3]"]);
|
|
2444
2631
|
expect(res).to.be.deep.equal(singleExclusion);
|
|
2445
2632
|
});
|
|
2446
|
-
it(
|
|
2447
|
-
let res = Utils.excludePathsFromChangeSet(changeset, [
|
|
2633
|
+
it("should exclude every given path in array", () => {
|
|
2634
|
+
let res = Utils.excludePathsFromChangeSet(changeset, [
|
|
2635
|
+
"assets[Prop3]",
|
|
2636
|
+
"assets[Prop2]",
|
|
2637
|
+
]);
|
|
2448
2638
|
expect(res).to.be.deep.equal(multiExclusion);
|
|
2449
2639
|
});
|
|
2450
|
-
it(
|
|
2451
|
-
let res = Utils.excludePathsFromChangeSet(undefined, [
|
|
2640
|
+
it("should return undefined if no changeset is passed", () => {
|
|
2641
|
+
let res = Utils.excludePathsFromChangeSet(undefined, ["assets[Prop3]"]);
|
|
2452
2642
|
expect(res).to.be.undefined;
|
|
2453
2643
|
});
|
|
2454
|
-
it(
|
|
2644
|
+
it("should not exclude if no paths are passed", () => {
|
|
2455
2645
|
expect(Utils.excludePathsFromChangeSet(changeset)).to.be.deep.equal(changeset);
|
|
2456
|
-
expect(Utils.excludePathsFromChangeSet(changeset,
|
|
2646
|
+
expect(Utils.excludePathsFromChangeSet(changeset, "")).to.be.deep.equal(changeset);
|
|
2457
2647
|
expect(Utils.excludePathsFromChangeSet(changeset, [])).to.be.deep.equal(changeset);
|
|
2458
2648
|
});
|
|
2459
|
-
it(
|
|
2460
|
-
expect(Utils.excludePathsFromChangeSet(changeset, [
|
|
2649
|
+
it("should not exclude if an invalid path is passed", () => {
|
|
2650
|
+
expect(Utils.excludePathsFromChangeSet(changeset, ["a.b.c"])).to.be.deep.equal(changeset);
|
|
2461
2651
|
});
|
|
2462
|
-
it(
|
|
2463
|
-
expect(Utils.excludePathsFromChangeSet(changeset, [
|
|
2652
|
+
it("should copy the changeset", () => {
|
|
2653
|
+
expect(Utils.excludePathsFromChangeSet(changeset, ["assets[prop3]"])).to.not.be.equal(changeset);
|
|
2464
2654
|
});
|
|
2465
2655
|
});
|
|
2466
2656
|
});
|