@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
|
@@ -6,103 +6,97 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @fileoverview In this file, we will test the NodeProperty object described in properties/nodeProperty.js
|
|
8
8
|
*/
|
|
9
|
-
const { ChangeSet } = require(
|
|
10
|
-
const { generateGUID } = require(
|
|
11
|
-
const { MSG } = require(
|
|
12
|
-
const _ = require(
|
|
13
|
-
const { PropertyFactory } = require(
|
|
14
|
-
const { BaseProperty } = require(
|
|
15
|
-
const { NodeProperty } = require(
|
|
16
|
-
const { MapProperty } = require(
|
|
17
|
-
describe(
|
|
9
|
+
const { ChangeSet } = require("@fluid-experimental/property-changeset");
|
|
10
|
+
const { generateGUID } = require("@fluid-experimental/property-common").GuidUtils;
|
|
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
|
+
const { MapProperty } = require("../../properties/mapProperty");
|
|
17
|
+
describe("NodeProperty", function () {
|
|
18
18
|
var changeSetWithTwoMapEntries, changeSetWithTwoMapEntries_full, removalChangeSet;
|
|
19
19
|
var myNode, mapNode1, mapNode2;
|
|
20
20
|
before(function () {
|
|
21
21
|
// Register a template with a set property for the tests
|
|
22
22
|
var MixedNodePropertyTemplate = {
|
|
23
|
-
typeid:
|
|
24
|
-
inherits: [
|
|
23
|
+
typeid: "autodesk.tests:MixedNodeTestProperty-1.0.0",
|
|
24
|
+
inherits: ["NodeProperty"],
|
|
25
25
|
properties: [
|
|
26
|
-
{ id:
|
|
27
|
-
{ id:
|
|
26
|
+
{ id: "stringProperty", typeid: "String" },
|
|
27
|
+
{ id: "stringProperty2", typeid: "String" },
|
|
28
28
|
],
|
|
29
29
|
};
|
|
30
30
|
var AnonymousTestPropertyTemplate = {
|
|
31
|
-
typeid:
|
|
32
|
-
properties: [
|
|
33
|
-
{ id: 'stringProperty', typeid: 'String' },
|
|
34
|
-
],
|
|
31
|
+
typeid: "autodesk.tests:AnonymousProperty-1.0.0",
|
|
32
|
+
properties: [{ id: "stringProperty", typeid: "String" }],
|
|
35
33
|
};
|
|
36
34
|
var MixedNamedNodePropertyTemplate = {
|
|
37
|
-
typeid:
|
|
38
|
-
inherits: [
|
|
39
|
-
properties: [
|
|
40
|
-
{ id: 'stringProperty', typeid: 'String' },
|
|
41
|
-
],
|
|
35
|
+
typeid: "autodesk.tests:MixedNamedNodeProperty-1.0.0",
|
|
36
|
+
inherits: ["NodeProperty", "NamedProperty"],
|
|
37
|
+
properties: [{ id: "stringProperty", typeid: "String" }],
|
|
42
38
|
};
|
|
43
39
|
var TestEnumTemplate = {
|
|
44
|
-
typeid:
|
|
45
|
-
inherits:
|
|
46
|
-
annotation: { description:
|
|
40
|
+
typeid: "autodesk.core:UnitsEnum-1.0.0",
|
|
41
|
+
inherits: "Enum",
|
|
42
|
+
annotation: { description: "The metric units" },
|
|
47
43
|
properties: [
|
|
48
|
-
{ id:
|
|
49
|
-
{ id:
|
|
50
|
-
{ id:
|
|
44
|
+
{ id: "m", value: 1, annotation: { description: "meter" } },
|
|
45
|
+
{ id: "cm", value: 2, annotation: { description: "centimeter" } },
|
|
46
|
+
{ id: "mm", value: 3, annotation: { description: "millimeter" } },
|
|
51
47
|
],
|
|
52
48
|
};
|
|
53
49
|
PropertyFactory._reregister(TestEnumTemplate);
|
|
54
50
|
PropertyFactory._reregister(MixedNodePropertyTemplate);
|
|
55
51
|
PropertyFactory._reregister(MixedNamedNodePropertyTemplate);
|
|
56
52
|
PropertyFactory._reregister(AnonymousTestPropertyTemplate);
|
|
57
|
-
myNode = PropertyFactory.create(
|
|
58
|
-
mapNode1 = PropertyFactory.create(
|
|
59
|
-
mapNode2 = PropertyFactory.create(
|
|
53
|
+
myNode = PropertyFactory.create("NodeProperty");
|
|
54
|
+
mapNode1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
55
|
+
mapNode2 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
60
56
|
// Register the templates from the discussion document
|
|
61
57
|
var Vec3Template = {
|
|
62
|
-
typeid:
|
|
58
|
+
typeid: "autodesk.test:vector3-1.0.0",
|
|
63
59
|
properties: [
|
|
64
|
-
{ id:
|
|
65
|
-
{ id:
|
|
66
|
-
{ id:
|
|
60
|
+
{ id: "x", typeid: "Float32" },
|
|
61
|
+
{ id: "y", typeid: "Float32" },
|
|
62
|
+
{ id: "z", typeid: "Float32" },
|
|
67
63
|
],
|
|
68
64
|
};
|
|
69
65
|
var Point2DTemplate = {
|
|
70
|
-
typeid:
|
|
66
|
+
typeid: "autodesk.test:point2d-1.0.0",
|
|
71
67
|
properties: [
|
|
72
68
|
{
|
|
73
|
-
id:
|
|
74
|
-
|
|
75
|
-
{ id:
|
|
69
|
+
id: "position",
|
|
70
|
+
properties: [
|
|
71
|
+
{ id: "x", typeid: "Float32" },
|
|
72
|
+
{ id: "y", typeid: "Float32" },
|
|
76
73
|
],
|
|
77
74
|
},
|
|
78
|
-
{ id:
|
|
79
|
-
{ id:
|
|
80
|
-
{ id:
|
|
75
|
+
{ id: "normal", typeid: "autodesk.test:vector3-1.0.0" },
|
|
76
|
+
{ id: "neighbours", typeid: "autodesk.test:vector3-1.0.0", context: "map" },
|
|
77
|
+
{ id: "temperature", typeid: "Float32" },
|
|
81
78
|
],
|
|
82
79
|
};
|
|
83
80
|
var SceneObjectTemplate = {
|
|
84
|
-
inherits:
|
|
85
|
-
typeid:
|
|
81
|
+
inherits: "NodeProperty",
|
|
82
|
+
typeid: "autodesk.test:SceneObject-1.0.0",
|
|
86
83
|
properties: [
|
|
87
|
-
{ id:
|
|
88
|
-
{ id:
|
|
84
|
+
{ id: "name", typeid: "String" },
|
|
85
|
+
{ id: "revitId", typeid: "String" },
|
|
89
86
|
],
|
|
90
87
|
};
|
|
91
88
|
var nestedNodeProperty = {
|
|
92
|
-
typeid:
|
|
89
|
+
typeid: "autodesk.tests:nested.node.property-1.0.0",
|
|
93
90
|
properties: [
|
|
94
91
|
{
|
|
95
|
-
id:
|
|
96
|
-
|
|
97
|
-
],
|
|
92
|
+
id: "nested",
|
|
93
|
+
properties: [{ id: "property", typeid: "NodeProperty" }],
|
|
98
94
|
},
|
|
99
95
|
],
|
|
100
96
|
};
|
|
101
97
|
var testArrayProperty = {
|
|
102
|
-
typeid:
|
|
103
|
-
properties: [
|
|
104
|
-
{ id: 'array', typeid: 'Float32', context: 'array' },
|
|
105
|
-
],
|
|
98
|
+
typeid: "autodesk.tests:test.array.property-1.0.0",
|
|
99
|
+
properties: [{ id: "array", typeid: "Float32", context: "array" }],
|
|
106
100
|
};
|
|
107
101
|
PropertyFactory._reregister(Vec3Template);
|
|
108
102
|
PropertyFactory._reregister(Point2DTemplate);
|
|
@@ -117,9 +111,9 @@ describe('NodeProperty', function () {
|
|
|
117
111
|
};
|
|
118
112
|
// Inserts a node with the given guid (a new one is generated when undefined)
|
|
119
113
|
var insertNodeInRootWithKeyAndGuid = function (key, guid, root) {
|
|
120
|
-
var node = PropertyFactory.create(
|
|
114
|
+
var node = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
121
115
|
if (key === undefined) {
|
|
122
|
-
key =
|
|
116
|
+
key = "node" + keyCounter++;
|
|
123
117
|
}
|
|
124
118
|
root.insert(key, node);
|
|
125
119
|
};
|
|
@@ -129,7 +123,7 @@ describe('NodeProperty', function () {
|
|
|
129
123
|
};
|
|
130
124
|
// Returns a functor that will insert a node with a constant GUID
|
|
131
125
|
var insertUniqueNodeInRoot = function () {
|
|
132
|
-
var key =
|
|
126
|
+
var key = "node" + keyCounter++;
|
|
133
127
|
return insertNodeInRootWithKeyAndGuid.bind(undefined, key, generateGUID());
|
|
134
128
|
};
|
|
135
129
|
// Inserts a new node as leaf
|
|
@@ -138,8 +132,8 @@ describe('NodeProperty', function () {
|
|
|
138
132
|
while (leaf.getDynamicIds().length > 0) {
|
|
139
133
|
leaf = _.values(leaf._getDynamicChildrenReadOnly())[0];
|
|
140
134
|
}
|
|
141
|
-
var node = PropertyFactory.create(
|
|
142
|
-
var key =
|
|
135
|
+
var node = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
136
|
+
var key = "node" + keyCounter++;
|
|
143
137
|
leaf.insert(key, node);
|
|
144
138
|
};
|
|
145
139
|
// Removes the first node from the root
|
|
@@ -153,162 +147,162 @@ describe('NodeProperty', function () {
|
|
|
153
147
|
while (leaf.getDynamicIds().length > 0) {
|
|
154
148
|
leaf = _.values(leaf._getDynamicChildrenReadOnly())[0];
|
|
155
149
|
}
|
|
156
|
-
leaf._properties.stringProperty.value = leaf._properties.stringProperty.value +
|
|
150
|
+
leaf._properties.stringProperty.value = leaf._properties.stringProperty.value + "+";
|
|
157
151
|
};
|
|
158
|
-
describe(
|
|
159
|
-
it(
|
|
152
|
+
describe("Testing creation, assignment and serialization", function () {
|
|
153
|
+
it("should be empty at the beginning", function () {
|
|
160
154
|
expect(myNode.getIds()).to.be.empty;
|
|
161
|
-
expect(myNode.serialize({
|
|
155
|
+
expect(myNode.serialize({ dirtyOnly: true })).to.be.empty;
|
|
162
156
|
});
|
|
163
|
-
it(
|
|
157
|
+
it("should be possible to insert into the map", function () {
|
|
164
158
|
// Test insertion of the first node
|
|
165
|
-
myNode.insert(
|
|
166
|
-
expect(myNode.has(
|
|
167
|
-
expect(myNode.has(
|
|
168
|
-
expect(myNode.get(
|
|
159
|
+
myNode.insert("node1", mapNode1);
|
|
160
|
+
expect(myNode.has("node1")).to.be.ok;
|
|
161
|
+
expect(myNode.has("node2")).to.be.not.ok;
|
|
162
|
+
expect(myNode.get("node2")).to.equal(undefined);
|
|
169
163
|
expect(mapNode1.getParent()).to.equal(myNode);
|
|
170
|
-
var CS = myNode.serialize({
|
|
164
|
+
var CS = myNode.serialize({ dirtyOnly: true });
|
|
171
165
|
expect(CS.insert &&
|
|
172
|
-
CS.insert[
|
|
173
|
-
_.keys(CS.insert[
|
|
174
|
-
_.keys(CS.insert[
|
|
166
|
+
CS.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"] &&
|
|
167
|
+
_.keys(CS.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"]).length === 1 &&
|
|
168
|
+
_.keys(CS.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"])[0] === "node1").to.be.ok;
|
|
175
169
|
// Test insertion of the second node
|
|
176
|
-
myNode.insert(
|
|
177
|
-
expect(myNode.has(
|
|
178
|
-
expect(myNode.get(
|
|
179
|
-
changeSetWithTwoMapEntries = myNode.serialize({
|
|
170
|
+
myNode.insert("node2", mapNode2);
|
|
171
|
+
expect(myNode.has("node2")).to.be.ok;
|
|
172
|
+
expect(myNode.get("node2")).to.equal(mapNode2);
|
|
173
|
+
changeSetWithTwoMapEntries = myNode.serialize({ dirtyOnly: true });
|
|
180
174
|
expect(changeSetWithTwoMapEntries.insert &&
|
|
181
|
-
changeSetWithTwoMapEntries.insert[
|
|
182
|
-
_.keys(changeSetWithTwoMapEntries.insert[
|
|
183
|
-
_.includes(_.keys(changeSetWithTwoMapEntries.insert[
|
|
184
|
-
_.includes(_.keys(changeSetWithTwoMapEntries.insert[
|
|
185
|
-
changeSetWithTwoMapEntries_full = myNode.serialize({
|
|
175
|
+
changeSetWithTwoMapEntries.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"] &&
|
|
176
|
+
_.keys(changeSetWithTwoMapEntries.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"]).length === 2 &&
|
|
177
|
+
_.includes(_.keys(changeSetWithTwoMapEntries.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"]), "node1") &&
|
|
178
|
+
_.includes(_.keys(changeSetWithTwoMapEntries.insert["autodesk.tests:MixedNodeTestProperty-1.0.0"]), "node2")).to.be.ok;
|
|
179
|
+
changeSetWithTwoMapEntries_full = myNode.serialize({ dirtyOnly: false });
|
|
186
180
|
expect(changeSetWithTwoMapEntries).to.deep.equal(changeSetWithTwoMapEntries_full);
|
|
187
181
|
});
|
|
188
|
-
it(
|
|
189
|
-
var myNode1 = PropertyFactory.create(
|
|
190
|
-
var mapNode3 = PropertyFactory.create(
|
|
191
|
-
expect(() => myNode1.insert(
|
|
192
|
-
});
|
|
193
|
-
it(
|
|
194
|
-
var myNode1 = PropertyFactory.create(
|
|
195
|
-
expect(() => myNode1.insert(
|
|
196
|
-
});
|
|
197
|
-
it(
|
|
198
|
-
var myNodeParent = PropertyFactory.create(
|
|
199
|
-
var myNodeChild = PropertyFactory.create(
|
|
200
|
-
myNodeParent.insert(
|
|
201
|
-
expect(() => myNodeChild.insert(
|
|
202
|
-
});
|
|
203
|
-
it(
|
|
204
|
-
var myNodeParent = PropertyFactory.create(
|
|
205
|
-
var myNodeChild = PropertyFactory.create(
|
|
206
|
-
var myNodeGrandChild = PropertyFactory.create(
|
|
207
|
-
myNodeParent.insert(
|
|
208
|
-
myNodeChild.insert(
|
|
209
|
-
expect(() => myNodeGrandChild.insert(
|
|
210
|
-
});
|
|
211
|
-
it(
|
|
212
|
-
var myNode1 = PropertyFactory.create(
|
|
213
|
-
var mapNode3 = PropertyFactory.create(
|
|
214
|
-
var mapNode4 = PropertyFactory.create(
|
|
215
|
-
myNode1.insert(
|
|
216
|
-
myNode1.insert(
|
|
217
|
-
expect(myNode1.remove(
|
|
182
|
+
it("should fail when trying to insert with empty id", function () {
|
|
183
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
184
|
+
var mapNode3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
185
|
+
expect(() => myNode1.insert("", mapNode3)).to.throw(MSG.ID_SHOULD_NOT_BE_EMPTY_STRING);
|
|
186
|
+
});
|
|
187
|
+
it("should fail when trying to insert in itself", function () {
|
|
188
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
189
|
+
expect(() => myNode1.insert("a", myNode1)).to.throw(MSG.INSERTED_IN_OWN_CHILDREN);
|
|
190
|
+
});
|
|
191
|
+
it("should fail when trying to insert in child", function () {
|
|
192
|
+
var myNodeParent = PropertyFactory.create("NodeProperty");
|
|
193
|
+
var myNodeChild = PropertyFactory.create("NodeProperty");
|
|
194
|
+
myNodeParent.insert("a", myNodeChild);
|
|
195
|
+
expect(() => myNodeChild.insert("a", myNodeParent)).to.throw(MSG.INSERTED_IN_OWN_CHILDREN);
|
|
196
|
+
});
|
|
197
|
+
it("should fail when trying to insert in grand-child", function () {
|
|
198
|
+
var myNodeParent = PropertyFactory.create("NodeProperty");
|
|
199
|
+
var myNodeChild = PropertyFactory.create("NodeProperty");
|
|
200
|
+
var myNodeGrandChild = PropertyFactory.create("NodeProperty");
|
|
201
|
+
myNodeParent.insert("a", myNodeChild);
|
|
202
|
+
myNodeChild.insert("a", myNodeGrandChild);
|
|
203
|
+
expect(() => myNodeGrandChild.insert("a", myNodeParent)).to.throw(MSG.INSERTED_IN_OWN_CHILDREN);
|
|
204
|
+
});
|
|
205
|
+
it(".remove should return the property removed", function () {
|
|
206
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
207
|
+
var mapNode3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
208
|
+
var mapNode4 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
209
|
+
myNode1.insert("node1", mapNode3);
|
|
210
|
+
myNode1.insert("node2", mapNode4);
|
|
211
|
+
expect(myNode1.remove("node1")).to.deep.equal(mapNode3);
|
|
218
212
|
expect(myNode1.remove(mapNode4)).to.deep.equal(mapNode4);
|
|
219
213
|
expect(myNode1.getIds()).to.be.empty;
|
|
220
214
|
});
|
|
221
|
-
it(
|
|
222
|
-
var myNode1 = PropertyFactory.create(
|
|
223
|
-
var mapNode3 = PropertyFactory.create(
|
|
224
|
-
var mapNode4 = PropertyFactory.create(
|
|
225
|
-
myNode1.insert(
|
|
226
|
-
myNode1.insert(
|
|
215
|
+
it(".clear should remove all nodes", function () {
|
|
216
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
217
|
+
var mapNode3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
218
|
+
var mapNode4 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
219
|
+
myNode1.insert("node1", mapNode3);
|
|
220
|
+
myNode1.insert("node2", mapNode4);
|
|
227
221
|
expect(myNode1.clear()).to.be.undefined;
|
|
228
222
|
expect(myNode1.getIds()).to.be.empty;
|
|
229
223
|
});
|
|
230
|
-
it(
|
|
231
|
-
var myNode1 = PropertyFactory.create(
|
|
232
|
-
var mapNode3 = PropertyFactory.create(
|
|
233
|
-
var mapNode4 = PropertyFactory.create(
|
|
234
|
-
myNode1.insert(
|
|
235
|
-
myNode1.insert(
|
|
224
|
+
it(".getValues should work", function () {
|
|
225
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
226
|
+
var mapNode3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
227
|
+
var mapNode4 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
228
|
+
myNode1.insert("node1", mapNode3);
|
|
229
|
+
myNode1.insert("node2", mapNode4);
|
|
236
230
|
expect(myNode1.getValues()).to.deep.equal({
|
|
237
|
-
node1: { stringProperty:
|
|
238
|
-
node2: { stringProperty:
|
|
231
|
+
node1: { stringProperty: "", stringProperty2: "" },
|
|
232
|
+
node2: { stringProperty: "", stringProperty2: "" },
|
|
239
233
|
});
|
|
240
234
|
});
|
|
241
|
-
it(
|
|
242
|
-
var myNode1 = PropertyFactory.create(
|
|
243
|
-
var myArray = PropertyFactory.create(
|
|
244
|
-
myNode1.insert(
|
|
245
|
-
myNode1.get(
|
|
246
|
-
expect(myNode1.getIds()).to.deep.equal([
|
|
235
|
+
it("getValues should work with nested arrays", function () {
|
|
236
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
237
|
+
var myArray = PropertyFactory.create("autodesk.tests:test.array.property-1.0.0");
|
|
238
|
+
myNode1.insert("array1", myArray);
|
|
239
|
+
myNode1.get("array1").get("array").insertRange(0, [1, 2, 3]);
|
|
240
|
+
expect(myNode1.getIds()).to.deep.equal(["array1"]);
|
|
247
241
|
expect(myNode1.getValues()).to.deep.equal({
|
|
248
242
|
array1: { array: [1, 2, 3] },
|
|
249
243
|
});
|
|
250
244
|
});
|
|
251
|
-
it.skip(
|
|
252
|
-
var myNode1 = PropertyFactory.create(
|
|
253
|
-
var myRef1 = PropertyFactory.create(
|
|
254
|
-
var myRef2 = PropertyFactory.create(
|
|
255
|
-
myNode1.insert(
|
|
256
|
-
myNode1.insert(
|
|
245
|
+
it.skip("@bugfix getValues should work with circular references", function () {
|
|
246
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
247
|
+
var myRef1 = PropertyFactory.create("Reference", "single", "/ref2");
|
|
248
|
+
var myRef2 = PropertyFactory.create("Reference", "single", "/ref1");
|
|
249
|
+
myNode1.insert("ref1", myRef1);
|
|
250
|
+
myNode1.insert("ref2", myRef2);
|
|
257
251
|
myNode1.getValues();
|
|
258
|
-
expect(myNode1.getIds()).to.deep.equal([
|
|
252
|
+
expect(myNode1.getIds()).to.deep.equal(["ref1", "ref2"]);
|
|
259
253
|
expect(myNode1.getValues()).to.deep.equal({
|
|
260
|
-
|
|
261
|
-
|
|
254
|
+
ref1: "/ref2",
|
|
255
|
+
ref2: "/ref1",
|
|
262
256
|
});
|
|
263
257
|
});
|
|
264
|
-
it(
|
|
265
|
-
var myNode1 = PropertyFactory.create(
|
|
266
|
-
var myRef = PropertyFactory.create(
|
|
267
|
-
myNode1.insert(
|
|
258
|
+
it("getValues should work with bad references", function () {
|
|
259
|
+
var myNode1 = PropertyFactory.create("NodeProperty");
|
|
260
|
+
var myRef = PropertyFactory.create("Reference", "single");
|
|
261
|
+
myNode1.insert("badref", myRef);
|
|
268
262
|
myNode1.getValues();
|
|
269
|
-
expect(myNode1.getIds()).to.deep.equal([
|
|
263
|
+
expect(myNode1.getIds()).to.deep.equal(["badref"]);
|
|
270
264
|
expect(myNode1.getValues()).to.deep.equal({
|
|
271
|
-
|
|
265
|
+
badref: undefined,
|
|
272
266
|
});
|
|
273
267
|
});
|
|
274
|
-
it(
|
|
268
|
+
it("Should track dirtiness", function () {
|
|
275
269
|
myNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY);
|
|
276
270
|
expect(myNode.serialize({
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
271
|
+
dirtyOnly: true,
|
|
272
|
+
includeRootTypeid: false,
|
|
273
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY,
|
|
280
274
|
})).to.be.empty;
|
|
281
275
|
expect(myNode.serialize({
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
276
|
+
dirtyOnly: true,
|
|
277
|
+
includeRootTypeid: false,
|
|
278
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE,
|
|
285
279
|
})).deep.equal(changeSetWithTwoMapEntries_full);
|
|
286
|
-
expect(myNode.serialize({
|
|
280
|
+
expect(myNode.serialize({ dirtyOnly: false })).deep.equal(changeSetWithTwoMapEntries_full);
|
|
287
281
|
});
|
|
288
|
-
it(
|
|
289
|
-
myNode.remove(
|
|
282
|
+
it("Should handle removals correctly", function () {
|
|
283
|
+
myNode.remove("node1");
|
|
290
284
|
expect(mapNode1.getParent()).to.be.undefined;
|
|
291
|
-
myNode.remove(
|
|
285
|
+
myNode.remove("node2");
|
|
292
286
|
expect(myNode.serialize({
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
287
|
+
dirtyOnly: true,
|
|
288
|
+
includeRootTypeid: false,
|
|
289
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE,
|
|
296
290
|
})).to.be.empty;
|
|
297
|
-
expect(myNode.serialize({
|
|
291
|
+
expect(myNode.serialize({ dirtyOnly: false })).to.be.empty;
|
|
298
292
|
removalChangeSet = myNode.serialize({
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
dirtyOnly: true,
|
|
294
|
+
includeRootTypeid: false,
|
|
295
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY,
|
|
302
296
|
});
|
|
303
|
-
expect(removalChangeSet).to.have.all.keys([
|
|
297
|
+
expect(removalChangeSet).to.have.all.keys(["remove"]);
|
|
304
298
|
expect(removalChangeSet.remove).to.have.length(2);
|
|
305
|
-
expect(removalChangeSet.remove).to.contain(
|
|
306
|
-
expect(removalChangeSet.remove).to.contain(
|
|
299
|
+
expect(removalChangeSet.remove).to.contain("node1");
|
|
300
|
+
expect(removalChangeSet.remove).to.contain("node2");
|
|
307
301
|
});
|
|
308
|
-
it(
|
|
309
|
-
var deserializedNode = PropertyFactory.create(
|
|
302
|
+
it("Should support deserialization", function () {
|
|
303
|
+
var deserializedNode = PropertyFactory.create("NodeProperty");
|
|
310
304
|
var deserializedChanges1 = deserializedNode.deserialize(changeSetWithTwoMapEntries);
|
|
311
|
-
var CS4 = deserializedNode.serialize({
|
|
305
|
+
var CS4 = deserializedNode.serialize({ dirtyOnly: false });
|
|
312
306
|
expect(CS4).to.deep.equal(changeSetWithTwoMapEntries);
|
|
313
307
|
expect(deserializedChanges1).to.deep.equal(changeSetWithTwoMapEntries);
|
|
314
308
|
var deserializedChanges2 = deserializedNode.deserialize(changeSetWithTwoMapEntries);
|
|
@@ -316,100 +310,99 @@ describe('NodeProperty', function () {
|
|
|
316
310
|
var deserializedChanges3 = deserializedNode.deserialize({});
|
|
317
311
|
expect(deserializedChanges3).to.deep.equal(removalChangeSet);
|
|
318
312
|
});
|
|
319
|
-
it(
|
|
320
|
-
var P1 = PropertyFactory.create(
|
|
321
|
-
var P2 = PropertyFactory.create(
|
|
322
|
-
P1._properties.nested.property.propertyNode.insert(
|
|
323
|
-
P1._properties.nested.property.testProperty.value =
|
|
324
|
-
P2.deserialize(P1.serialize({
|
|
325
|
-
expect(P1.serialize({
|
|
326
|
-
expect(P2._properties.nested.property.testProperty.value).to.equal(
|
|
327
|
-
});
|
|
328
|
-
it(
|
|
329
|
-
var modifyNode1 = PropertyFactory.create(
|
|
330
|
-
var modifyNode2 = PropertyFactory.create(
|
|
313
|
+
it("should support deserialization for nested properties", function () {
|
|
314
|
+
var P1 = PropertyFactory.create("autodesk.tests:nested.node.property-1.0.0");
|
|
315
|
+
var P2 = PropertyFactory.create("autodesk.tests:nested.node.property-1.0.0");
|
|
316
|
+
P1._properties.nested.property.propertyNode.insert("testProperty", PropertyFactory.create("String"));
|
|
317
|
+
P1._properties.nested.property.testProperty.value = "testString";
|
|
318
|
+
P2.deserialize(P1.serialize({ dirtyOnly: false }));
|
|
319
|
+
expect(P1.serialize({ dirtyOnly: false })).to.deep.equal(P2.serialize({ dirtyOnly: false }));
|
|
320
|
+
expect(P2._properties.nested.property.testProperty.value).to.equal("testString");
|
|
321
|
+
});
|
|
322
|
+
it("Should track modifies", function () {
|
|
323
|
+
var modifyNode1 = PropertyFactory.create("NodeProperty");
|
|
324
|
+
var modifyNode2 = PropertyFactory.create("NodeProperty");
|
|
331
325
|
modifyNode1.deserialize(changeSetWithTwoMapEntries);
|
|
332
326
|
modifyNode2.deserialize(changeSetWithTwoMapEntries);
|
|
333
327
|
modifyNode1.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
334
328
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
335
|
-
var child1 = modifyNode1.get(
|
|
336
|
-
child1._properties.stringProperty.value =
|
|
337
|
-
var modifyChangeSet = modifyNode1.serialize({
|
|
329
|
+
var child1 = modifyNode1.get("node1");
|
|
330
|
+
child1._properties.stringProperty.value = "modify test";
|
|
331
|
+
var modifyChangeSet = modifyNode1.serialize({ dirtyOnly: true });
|
|
338
332
|
modifyNode2.applyChangeSet(modifyChangeSet);
|
|
339
|
-
expect(modifyNode2.serialize({
|
|
340
|
-
.to.deep.equal(modifyNode1.serialize({ 'dirtyOnly': false }));
|
|
333
|
+
expect(modifyNode2.serialize({ dirtyOnly: false })).to.deep.equal(modifyNode1.serialize({ dirtyOnly: false }));
|
|
341
334
|
});
|
|
342
|
-
it(
|
|
343
|
-
var node1 = PropertyFactory.create(
|
|
344
|
-
var node2 = PropertyFactory.create(
|
|
345
|
-
var node3 = PropertyFactory.create(
|
|
335
|
+
it("Should support hierarchical properties", function () {
|
|
336
|
+
var node1 = PropertyFactory.create("NodeProperty");
|
|
337
|
+
var node2 = PropertyFactory.create("NodeProperty");
|
|
338
|
+
var node3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
346
339
|
// Createa a hierarchy of three nodes
|
|
347
|
-
node1.insert(
|
|
348
|
-
node2.insert(
|
|
349
|
-
node3._properties.stringProperty.value =
|
|
340
|
+
node1.insert("node", node2);
|
|
341
|
+
node2.insert("node", node3);
|
|
342
|
+
node3._properties.stringProperty.value = "test";
|
|
350
343
|
// Check that deserializing and serializing works with a hierarchy
|
|
351
|
-
var hierarchicalChangeSet = node1.serialize({
|
|
352
|
-
var deserializedNode = PropertyFactory.create(
|
|
344
|
+
var hierarchicalChangeSet = node1.serialize({ dirtyOnly: true });
|
|
345
|
+
var deserializedNode = PropertyFactory.create("NodeProperty");
|
|
353
346
|
deserializedNode.deserialize(hierarchicalChangeSet);
|
|
354
347
|
var child1 = deserializedNode.get(deserializedNode.getIds()[0]);
|
|
355
348
|
expect(child1).to.not.equal(undefined);
|
|
356
349
|
var child2 = child1.get(child1.getIds()[0]);
|
|
357
350
|
expect(child2).to.not.equal(undefined);
|
|
358
|
-
expect(child2._properties.stringProperty.value).to.equal(
|
|
351
|
+
expect(child2._properties.stringProperty.value).to.equal("test");
|
|
359
352
|
// Test that hierarchical modifies work
|
|
360
353
|
node1.cleanDirty();
|
|
361
|
-
node3._properties.stringProperty.value =
|
|
362
|
-
var hierarchicalModifyChangeSet = node1.serialize({
|
|
354
|
+
node3._properties.stringProperty.value = "test2";
|
|
355
|
+
var hierarchicalModifyChangeSet = node1.serialize({ dirtyOnly: true });
|
|
363
356
|
deserializedNode.applyChangeSet(hierarchicalModifyChangeSet);
|
|
364
357
|
child1 = deserializedNode.get(deserializedNode.getIds()[0]);
|
|
365
358
|
expect(child1).to.not.equal(undefined);
|
|
366
359
|
child2 = child1.get(child1.getIds()[0]);
|
|
367
360
|
expect(child2).to.not.equal(undefined);
|
|
368
|
-
expect(child2._properties.stringProperty.value).to.equal(
|
|
369
|
-
});
|
|
370
|
-
it(
|
|
371
|
-
var rootNode = PropertyFactory.create(
|
|
372
|
-
var rootNode2 = PropertyFactory.create(
|
|
373
|
-
var node1 = PropertyFactory.create(
|
|
374
|
-
var node2 = PropertyFactory.create(
|
|
375
|
-
rootNode.insert(
|
|
376
|
-
rootNode.insert(
|
|
377
|
-
var testChangeSet = rootNode.serialize({
|
|
378
|
-
expect(rootNode.get(
|
|
379
|
-
expect(rootNode.get(
|
|
361
|
+
expect(child2._properties.stringProperty.value).to.equal("test2");
|
|
362
|
+
});
|
|
363
|
+
it("should be possible to use anonymous properties", function () {
|
|
364
|
+
var rootNode = PropertyFactory.create("NodeProperty");
|
|
365
|
+
var rootNode2 = PropertyFactory.create("NodeProperty");
|
|
366
|
+
var node1 = PropertyFactory.create("autodesk.tests:AnonymousProperty-1.0.0");
|
|
367
|
+
var node2 = PropertyFactory.create("autodesk.tests:AnonymousProperty-1.0.0");
|
|
368
|
+
rootNode.insert("node1", node1);
|
|
369
|
+
rootNode.insert("node2", node2);
|
|
370
|
+
var testChangeSet = rootNode.serialize({ dirtyOnly: false });
|
|
371
|
+
expect(rootNode.get("node1")).to.be.equal(node1);
|
|
372
|
+
expect(rootNode.get("node2")).to.be.equal(node2);
|
|
380
373
|
rootNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
381
374
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
382
|
-
node1._properties.stringProperty.value =
|
|
383
|
-
node2._properties.stringProperty.value =
|
|
375
|
+
node1._properties.stringProperty.value = "1";
|
|
376
|
+
node2._properties.stringProperty.value = "2";
|
|
384
377
|
rootNode2.deserialize(testChangeSet);
|
|
385
|
-
rootNode2.applyChangeSet(rootNode.serialize({
|
|
386
|
-
expect(rootNode2.serialize({
|
|
387
|
-
});
|
|
388
|
-
it(
|
|
389
|
-
var rootNode = PropertyFactory.create(
|
|
390
|
-
var node1 = PropertyFactory.create(
|
|
391
|
-
var node2 = PropertyFactory.create(
|
|
392
|
-
rootNode.insert(
|
|
378
|
+
rootNode2.applyChangeSet(rootNode.serialize({ dirtyOnly: true }));
|
|
379
|
+
expect(rootNode2.serialize({ dirtyOnly: false })).to.be.deep.equal(rootNode.serialize({ dirtyOnly: false }));
|
|
380
|
+
});
|
|
381
|
+
it("inserting the same key twice should throw an exception", function () {
|
|
382
|
+
var rootNode = PropertyFactory.create("NodeProperty");
|
|
383
|
+
var node1 = PropertyFactory.create("NodeProperty");
|
|
384
|
+
var node2 = PropertyFactory.create("NodeProperty");
|
|
385
|
+
rootNode.insert("node1", node1);
|
|
393
386
|
expect(function () {
|
|
394
|
-
rootNode.insert(
|
|
387
|
+
rootNode.insert("node1", node2);
|
|
395
388
|
}).to.throw();
|
|
396
389
|
});
|
|
397
|
-
it(
|
|
398
|
-
var mixedNode = PropertyFactory.create(
|
|
399
|
-
mixedNode.insert(
|
|
400
|
-
mixedNode.insert(
|
|
401
|
-
mixedNode._properties.stringProperty.value =
|
|
402
|
-
mixedNode._properties.stringProperty2.value =
|
|
403
|
-
mixedNode._properties.dynamicString.value =
|
|
390
|
+
it("Should work to create a MixedNodeTemplate", function () {
|
|
391
|
+
var mixedNode = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
392
|
+
mixedNode.insert("dynamicFloat", PropertyFactory.create("Float32"));
|
|
393
|
+
mixedNode.insert("dynamicString", PropertyFactory.create("String"));
|
|
394
|
+
mixedNode._properties.stringProperty.value = "string1";
|
|
395
|
+
mixedNode._properties.stringProperty2.value = "string2";
|
|
396
|
+
mixedNode._properties.dynamicString.value = "dynamic2";
|
|
404
397
|
mixedNode._properties.dynamicFloat.value = 11;
|
|
405
|
-
expect(mixedNode.serialize({
|
|
398
|
+
expect(mixedNode.serialize({ dirtyOnly: false })).to.deep.equal({
|
|
406
399
|
String: {
|
|
407
|
-
stringProperty:
|
|
408
|
-
stringProperty2:
|
|
400
|
+
stringProperty: "string1",
|
|
401
|
+
stringProperty2: "string2",
|
|
409
402
|
},
|
|
410
403
|
insert: {
|
|
411
404
|
String: {
|
|
412
|
-
dynamicString:
|
|
405
|
+
dynamicString: "dynamic2",
|
|
413
406
|
},
|
|
414
407
|
Float32: {
|
|
415
408
|
dynamicFloat: 11,
|
|
@@ -418,88 +411,88 @@ describe('NodeProperty', function () {
|
|
|
418
411
|
});
|
|
419
412
|
mixedNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
420
413
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
421
|
-
mixedNode._properties.stringProperty.value =
|
|
422
|
-
mixedNode._properties.dynamicString.value =
|
|
423
|
-
mixedNode.insert(
|
|
424
|
-
mixedNode._properties.dynamicString2.value =
|
|
425
|
-
expect(mixedNode.serialize({
|
|
414
|
+
mixedNode._properties.stringProperty.value = "modified1";
|
|
415
|
+
mixedNode._properties.dynamicString.value = "modified2";
|
|
416
|
+
mixedNode.insert("dynamicString2", PropertyFactory.create("String"));
|
|
417
|
+
mixedNode._properties.dynamicString2.value = "dynamic3";
|
|
418
|
+
expect(mixedNode.serialize({ dirtyOnly: true })).to.deep.equal({
|
|
426
419
|
String: {
|
|
427
|
-
stringProperty:
|
|
420
|
+
stringProperty: "modified1",
|
|
428
421
|
},
|
|
429
422
|
modify: {
|
|
430
423
|
String: {
|
|
431
|
-
dynamicString:
|
|
424
|
+
dynamicString: "modified2",
|
|
432
425
|
},
|
|
433
426
|
},
|
|
434
427
|
insert: {
|
|
435
428
|
String: {
|
|
436
|
-
dynamicString2:
|
|
429
|
+
dynamicString2: "dynamic3",
|
|
437
430
|
},
|
|
438
431
|
},
|
|
439
432
|
});
|
|
440
433
|
// Pretty printing
|
|
441
|
-
var expectedPrettyStr =
|
|
434
|
+
var expectedPrettyStr = "undefined (autodesk.tests:MixedNodeTestProperty-1.0.0):\n" +
|
|
442
435
|
' stringProperty (String): "modified1"\n' +
|
|
443
436
|
' stringProperty2 (String): "string2"\n' +
|
|
444
|
-
|
|
437
|
+
" dynamicFloat (Float32): 11\n" +
|
|
445
438
|
' dynamicString (String): "modified2"\n' +
|
|
446
439
|
' dynamicString2 (String): "dynamic3"\n';
|
|
447
|
-
var prettyStr =
|
|
440
|
+
var prettyStr = "";
|
|
448
441
|
mixedNode.prettyPrint(function (str) {
|
|
449
|
-
prettyStr += str +
|
|
442
|
+
prettyStr += str + "\n";
|
|
450
443
|
});
|
|
451
444
|
expect(prettyStr).to.equal(expectedPrettyStr);
|
|
452
445
|
});
|
|
453
|
-
it(
|
|
454
|
-
var rootNode = PropertyFactory.create(
|
|
455
|
-
var node = PropertyFactory.create(
|
|
446
|
+
it("inserting the same node twice should be a bug", function () {
|
|
447
|
+
var rootNode = PropertyFactory.create("NodeProperty");
|
|
448
|
+
var node = PropertyFactory.create("NodeProperty");
|
|
456
449
|
// Try to insert the same node object under two keys
|
|
457
|
-
rootNode.insert(
|
|
450
|
+
rootNode.insert("node", node);
|
|
458
451
|
expect(function () {
|
|
459
|
-
rootNode.insert(
|
|
452
|
+
rootNode.insert("node2", node);
|
|
460
453
|
}).to.throw();
|
|
461
454
|
// After removing it, adding it under a new key should be possible
|
|
462
|
-
rootNode.remove(
|
|
463
|
-
rootNode.insert(
|
|
455
|
+
rootNode.remove("node");
|
|
456
|
+
rootNode.insert("node2", node);
|
|
464
457
|
});
|
|
465
|
-
it(
|
|
458
|
+
it("should not allow adding two nodes with same id", function () {
|
|
466
459
|
var NodeTemplate = {
|
|
467
|
-
typeid:
|
|
468
|
-
inherits:
|
|
469
|
-
properties: [{ id:
|
|
460
|
+
typeid: "autodesk.tests:NodeTemplate-1.0.0",
|
|
461
|
+
inherits: "NodeProperty",
|
|
462
|
+
properties: [{ id: "a", typeid: "Float32" }],
|
|
470
463
|
};
|
|
471
464
|
PropertyFactory._reregister(NodeTemplate);
|
|
472
|
-
var node = PropertyFactory.create(
|
|
473
|
-
var child = PropertyFactory.create(
|
|
465
|
+
var node = PropertyFactory.create("autodesk.tests:NodeTemplate-1.0.0");
|
|
466
|
+
var child = PropertyFactory.create("String");
|
|
474
467
|
expect(function () {
|
|
475
|
-
node.insert(
|
|
476
|
-
}).to.throw(MSG.PROPERTY_ALREADY_EXISTS +
|
|
477
|
-
});
|
|
478
|
-
it(
|
|
479
|
-
var root = PropertyFactory.create(
|
|
480
|
-
var child = PropertyFactory.create(
|
|
481
|
-
var stringProperty = child.resolvePath(
|
|
482
|
-
root.insert(
|
|
468
|
+
node.insert("a", child);
|
|
469
|
+
}).to.throw(MSG.PROPERTY_ALREADY_EXISTS + "a");
|
|
470
|
+
});
|
|
471
|
+
it("Should correctly report whether it is a root", function () {
|
|
472
|
+
var root = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
473
|
+
var child = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
474
|
+
var stringProperty = child.resolvePath("stringProperty");
|
|
475
|
+
root.insert("childKey", child);
|
|
483
476
|
assert(root.isRoot());
|
|
484
477
|
assert(!child.isRoot());
|
|
485
|
-
expect(stringProperty.getAbsolutePath()).to.equal(
|
|
486
|
-
expect(stringProperty.getRelativePath(child)).to.equal(
|
|
478
|
+
expect(stringProperty.getAbsolutePath()).to.equal("/childKey.stringProperty");
|
|
479
|
+
expect(stringProperty.getRelativePath(child)).to.equal("stringProperty");
|
|
487
480
|
expect(root.resolvePath(stringProperty.getAbsolutePath())).to.equal(stringProperty);
|
|
488
481
|
expect(child.resolvePath(stringProperty.getRelativePath(child))).to.equal(stringProperty);
|
|
489
482
|
});
|
|
490
|
-
it(
|
|
491
|
-
var property = PropertyFactory.create(
|
|
492
|
-
property.insert(
|
|
483
|
+
it("should correctly report changes when deserializing keys which contain 0", function () {
|
|
484
|
+
var property = PropertyFactory.create("NodeProperty");
|
|
485
|
+
property.insert("test", PropertyFactory.create("Int32"));
|
|
493
486
|
property._properties.test.value = 5; // Make sure, it is marked as modified
|
|
494
487
|
property._properties.test.value = 0;
|
|
495
|
-
var property2 = PropertyFactory.create(
|
|
496
|
-
property2.insert(
|
|
488
|
+
var property2 = PropertyFactory.create("NodeProperty");
|
|
489
|
+
property2.insert("test", PropertyFactory.create("Int32"));
|
|
497
490
|
property2._properties.test.value = 5;
|
|
498
|
-
var actualChanges = property2.deserialize(property.serialize({
|
|
499
|
-
expect(actualChanges).to.deep.equal({ modify: {
|
|
491
|
+
var actualChanges = property2.deserialize(property.serialize({ dirtyOnly: false }));
|
|
492
|
+
expect(actualChanges).to.deep.equal({ modify: { Int32: { test: 0 } } });
|
|
500
493
|
});
|
|
501
494
|
});
|
|
502
|
-
describe(
|
|
495
|
+
describe("squashing", function () {
|
|
503
496
|
//
|
|
504
497
|
// Helper function which takes a sequence of callbacks that are successively executed
|
|
505
498
|
// and the changes applied by the callbacks are separately tracked and squashed in a
|
|
@@ -510,19 +503,19 @@ describe('NodeProperty', function () {
|
|
|
510
503
|
//
|
|
511
504
|
var testChangeSetSquashing = function (in_options) {
|
|
512
505
|
resetKeyCounter();
|
|
513
|
-
var testProperty = PropertyFactory.create(
|
|
506
|
+
var testProperty = PropertyFactory.create("NodeProperty");
|
|
514
507
|
var callbacks = in_options.callbacks;
|
|
515
508
|
if (in_options.pre) {
|
|
516
509
|
in_options.pre(testProperty);
|
|
517
510
|
}
|
|
518
|
-
var initialChangeset = new ChangeSet(testProperty.serialize({
|
|
511
|
+
var initialChangeset = new ChangeSet(testProperty.serialize({ dirtyOnly: false }));
|
|
519
512
|
initialChangeset.setIsNormalized(true);
|
|
520
513
|
var squashedChangeset = new ChangeSet();
|
|
521
514
|
testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
522
515
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
523
516
|
for (var i = 0; i < callbacks.length; i++) {
|
|
524
517
|
callbacks[i](testProperty);
|
|
525
|
-
var changes = testProperty.serialize({
|
|
518
|
+
var changes = testProperty.serialize({ dirtyOnly: true });
|
|
526
519
|
testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
527
520
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
528
521
|
squashedChangeset.applyChangeSet(changes);
|
|
@@ -531,105 +524,131 @@ describe('NodeProperty', function () {
|
|
|
531
524
|
in_options.post(squashedChangeset.getSerializedChangeSet());
|
|
532
525
|
}
|
|
533
526
|
initialChangeset.applyChangeSet(squashedChangeset.getSerializedChangeSet());
|
|
534
|
-
expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({
|
|
527
|
+
expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ dirtyOnly: false }));
|
|
535
528
|
};
|
|
536
|
-
it(
|
|
537
|
-
testChangeSetSquashing({
|
|
529
|
+
it("should work for multiple independent inserts", function () {
|
|
530
|
+
testChangeSetSquashing({
|
|
531
|
+
callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot],
|
|
532
|
+
});
|
|
538
533
|
});
|
|
539
|
-
it(
|
|
540
|
-
testChangeSetSquashing({
|
|
534
|
+
it("should work for multiple hierarchical inserts", function () {
|
|
535
|
+
testChangeSetSquashing({
|
|
536
|
+
callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf],
|
|
537
|
+
});
|
|
541
538
|
});
|
|
542
|
-
it(
|
|
539
|
+
it("should work for inserts followed by removes", function () {
|
|
543
540
|
testChangeSetSquashing({
|
|
544
|
-
callbacks: [
|
|
541
|
+
callbacks: [
|
|
542
|
+
insertNodeInRoot,
|
|
543
|
+
insertNodeInRoot,
|
|
544
|
+
removeFirstNodeInRoot,
|
|
545
|
+
removeFirstNodeInRoot,
|
|
546
|
+
],
|
|
545
547
|
post: function (changeset) {
|
|
546
548
|
expect(changeset).to.be.empty;
|
|
547
549
|
},
|
|
548
550
|
});
|
|
549
551
|
});
|
|
550
|
-
it(
|
|
552
|
+
it("should work for a tree removal", function () {
|
|
551
553
|
testChangeSetSquashing({
|
|
552
|
-
callbacks: [
|
|
554
|
+
callbacks: [
|
|
555
|
+
insertNodeAsLeaf,
|
|
556
|
+
insertNodeAsLeaf,
|
|
557
|
+
insertNodeAsLeaf,
|
|
558
|
+
removeFirstNodeInRoot,
|
|
559
|
+
],
|
|
553
560
|
post: function (changeset) {
|
|
554
561
|
expect(changeset).to.be.empty;
|
|
555
562
|
},
|
|
556
563
|
});
|
|
557
564
|
});
|
|
558
|
-
it(
|
|
565
|
+
it("should work for modifies in a tree", function () {
|
|
559
566
|
testChangeSetSquashing({
|
|
560
|
-
callbacks: [
|
|
567
|
+
callbacks: [
|
|
568
|
+
insertNodeAsLeaf,
|
|
569
|
+
insertNodeAsLeaf,
|
|
570
|
+
insertNodeAsLeaf,
|
|
571
|
+
modifyLeaf,
|
|
572
|
+
modifyLeaf,
|
|
573
|
+
],
|
|
561
574
|
});
|
|
562
575
|
});
|
|
563
|
-
it(
|
|
576
|
+
it("should work for modifies of a primitive type", function () {
|
|
564
577
|
testChangeSetSquashing({
|
|
565
578
|
callbacks: [
|
|
566
579
|
function (root) {
|
|
567
|
-
var newStringNode = PropertyFactory.create(
|
|
568
|
-
newStringNode.value =
|
|
569
|
-
root.insert(
|
|
580
|
+
var newStringNode = PropertyFactory.create("String");
|
|
581
|
+
newStringNode.value = "initial value";
|
|
582
|
+
root.insert("stringProp", newStringNode);
|
|
570
583
|
},
|
|
571
584
|
function (root) {
|
|
572
|
-
root.get(
|
|
585
|
+
root.get("stringProp").value = "new value";
|
|
573
586
|
},
|
|
574
587
|
],
|
|
575
588
|
});
|
|
576
589
|
});
|
|
577
|
-
it(
|
|
590
|
+
it("an insert, modify and a remove should give an empty changeset", function () {
|
|
578
591
|
testChangeSetSquashing({
|
|
579
|
-
callbacks: [
|
|
592
|
+
callbacks: [
|
|
593
|
+
insertNodeAsLeaf,
|
|
594
|
+
insertNodeAsLeaf,
|
|
595
|
+
modifyLeaf,
|
|
596
|
+
modifyLeaf,
|
|
597
|
+
removeFirstNodeInRoot,
|
|
598
|
+
],
|
|
580
599
|
post: function (changeset) {
|
|
581
600
|
expect(changeset).to.be.empty;
|
|
582
601
|
},
|
|
583
602
|
});
|
|
584
603
|
});
|
|
585
|
-
it(
|
|
604
|
+
it("work for modifies after an already existing insert", function () {
|
|
586
605
|
testChangeSetSquashing({
|
|
587
606
|
pre: insertNodeInRoot,
|
|
588
607
|
callbacks: [modifyLeaf, modifyLeaf],
|
|
589
608
|
});
|
|
590
609
|
});
|
|
591
|
-
it(
|
|
610
|
+
it("of modify and remove after an already existing insert should work", function () {
|
|
592
611
|
testChangeSetSquashing({
|
|
593
612
|
pre: insertNodeInRoot,
|
|
594
613
|
callbacks: [modifyLeaf, removeFirstNodeInRoot],
|
|
595
614
|
post: function (changeset) {
|
|
596
|
-
expect(changeset).to.have.all.keys(
|
|
615
|
+
expect(changeset).to.have.all.keys("remove");
|
|
597
616
|
},
|
|
598
617
|
});
|
|
599
618
|
});
|
|
600
|
-
it(
|
|
619
|
+
it("of a replace operation should be possible", function () {
|
|
601
620
|
// Create two nodes
|
|
602
|
-
var node1 = PropertyFactory.create(
|
|
603
|
-
var node2 = PropertyFactory.create(
|
|
604
|
-
node2._properties.stringProperty.value =
|
|
621
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
622
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
623
|
+
node2._properties.stringProperty.value = "testString2";
|
|
605
624
|
testChangeSetSquashing({
|
|
606
625
|
pre: function (root) {
|
|
607
|
-
root.insert(
|
|
626
|
+
root.insert("node1", node1);
|
|
608
627
|
},
|
|
609
628
|
callbacks: [
|
|
610
629
|
removeFirstNodeInRoot,
|
|
611
630
|
function (root) {
|
|
612
|
-
root.insert(
|
|
631
|
+
root.insert("node1", node2);
|
|
613
632
|
},
|
|
614
633
|
],
|
|
615
634
|
post: function (changeset) {
|
|
616
|
-
expect(changeset).to.have.all.keys(
|
|
635
|
+
expect(changeset).to.have.all.keys("remove", "insert");
|
|
617
636
|
},
|
|
618
637
|
});
|
|
619
638
|
});
|
|
620
639
|
});
|
|
621
|
-
describe(
|
|
640
|
+
describe("Rebasing", function () {
|
|
622
641
|
var testRebasing = function (in_options) {
|
|
623
642
|
// Prepare the initial state
|
|
624
|
-
var baseProperty1 = PropertyFactory.create(
|
|
643
|
+
var baseProperty1 = PropertyFactory.create("NodeProperty");
|
|
625
644
|
if (in_options.prepare) {
|
|
626
645
|
in_options.prepare(baseProperty1);
|
|
627
646
|
}
|
|
628
647
|
// Create two copies of this state
|
|
629
|
-
var baseProperty2 = PropertyFactory.create(
|
|
630
|
-
baseProperty2.deserialize(baseProperty1.serialize({
|
|
631
|
-
var baseProperty3 = PropertyFactory.create(
|
|
632
|
-
baseProperty3.deserialize(baseProperty1.serialize({
|
|
648
|
+
var baseProperty2 = PropertyFactory.create("NodeProperty");
|
|
649
|
+
baseProperty2.deserialize(baseProperty1.serialize({ dirtyOnly: false }));
|
|
650
|
+
var baseProperty3 = PropertyFactory.create("NodeProperty");
|
|
651
|
+
baseProperty3.deserialize(baseProperty1.serialize({ dirtyOnly: false }));
|
|
633
652
|
// Make sure the states are clear
|
|
634
653
|
baseProperty1.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
635
654
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
@@ -637,7 +656,7 @@ describe('NodeProperty', function () {
|
|
|
637
656
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
638
657
|
baseProperty3.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
639
658
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
640
|
-
var initialChangeSet = baseProperty1.serialize({
|
|
659
|
+
var initialChangeSet = baseProperty1.serialize({ dirtyOnly: false });
|
|
641
660
|
// Apply the operations to the two properties in parallel
|
|
642
661
|
if (in_options.op1) {
|
|
643
662
|
in_options.op1(baseProperty1);
|
|
@@ -646,8 +665,8 @@ describe('NodeProperty', function () {
|
|
|
646
665
|
in_options.op2(baseProperty2);
|
|
647
666
|
}
|
|
648
667
|
// Get the ChangeSets
|
|
649
|
-
var changeSet1 = new ChangeSet(baseProperty1.serialize({
|
|
650
|
-
var changeSet2 = baseProperty2.serialize({
|
|
668
|
+
var changeSet1 = new ChangeSet(baseProperty1.serialize({ dirtyOnly: true }));
|
|
669
|
+
var changeSet2 = baseProperty2.serialize({ dirtyOnly: true });
|
|
651
670
|
// Perform the actual rebase
|
|
652
671
|
var conflicts = [];
|
|
653
672
|
changeSet1._rebaseChangeSet(changeSet2, conflicts);
|
|
@@ -661,59 +680,59 @@ describe('NodeProperty', function () {
|
|
|
661
680
|
if (in_options.op2) {
|
|
662
681
|
in_options.op2(baseProperty3);
|
|
663
682
|
}
|
|
664
|
-
var finalChangeSet = baseProperty3.serialize({
|
|
683
|
+
var finalChangeSet = baseProperty3.serialize({ dirtyOnly: false });
|
|
665
684
|
expect(finalChangeSet).to.be.deep.equal(combinedChangeSet.getSerializedChangeSet());
|
|
666
685
|
}
|
|
667
686
|
if (in_options.checkResult) {
|
|
668
687
|
in_options.checkResult(conflicts, changeSet2, combinedChangeSet);
|
|
669
688
|
}
|
|
670
689
|
};
|
|
671
|
-
it(
|
|
690
|
+
it("with a NOP should be possible", function () {
|
|
672
691
|
testRebasing({
|
|
673
692
|
op2: insertUniqueNodeInRoot(),
|
|
674
693
|
compareToSequential: true,
|
|
675
694
|
});
|
|
676
695
|
});
|
|
677
|
-
it(
|
|
696
|
+
it("with independent inserts should be possible", function () {
|
|
678
697
|
testRebasing({
|
|
679
698
|
op1: insertUniqueNodeInRoot(),
|
|
680
699
|
op2: insertUniqueNodeInRoot(),
|
|
681
700
|
compareToSequential: true,
|
|
682
701
|
});
|
|
683
702
|
});
|
|
684
|
-
it(
|
|
685
|
-
var node1 = PropertyFactory.create(
|
|
686
|
-
var node2 = PropertyFactory.create(
|
|
703
|
+
it("with independent removes should be possible", function () {
|
|
704
|
+
var node1 = PropertyFactory.create("NodeProperty");
|
|
705
|
+
var node2 = PropertyFactory.create("NodeProperty");
|
|
687
706
|
testRebasing({
|
|
688
707
|
prepare: function (root) {
|
|
689
|
-
root.insert(
|
|
690
|
-
root.insert(
|
|
708
|
+
root.insert("node1", node1);
|
|
709
|
+
root.insert("node2", node2);
|
|
691
710
|
},
|
|
692
711
|
op1: function (root) {
|
|
693
|
-
root.remove(
|
|
712
|
+
root.remove("node1");
|
|
694
713
|
},
|
|
695
714
|
op2: function (root) {
|
|
696
|
-
root.remove(
|
|
715
|
+
root.remove("node2");
|
|
697
716
|
},
|
|
698
717
|
compareToSequential: true,
|
|
699
718
|
});
|
|
700
719
|
});
|
|
701
|
-
it(
|
|
702
|
-
var node1 = PropertyFactory.create(
|
|
720
|
+
it("with a modify and a remove should possible", function () {
|
|
721
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
703
722
|
testRebasing({
|
|
704
723
|
prepare: function (root) {
|
|
705
|
-
root.insert(
|
|
724
|
+
root.insert("node1", node1);
|
|
706
725
|
},
|
|
707
726
|
op1: modifyLeaf,
|
|
708
727
|
op2: removeFirstNodeInRoot,
|
|
709
728
|
compareToSequential: true,
|
|
710
729
|
});
|
|
711
730
|
});
|
|
712
|
-
it(
|
|
713
|
-
var node1 = PropertyFactory.create(
|
|
731
|
+
it("with a remove and a modify should possible", function () {
|
|
732
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
714
733
|
testRebasing({
|
|
715
734
|
prepare: function (root) {
|
|
716
|
-
root.insert(
|
|
735
|
+
root.insert("node1", node1);
|
|
717
736
|
},
|
|
718
737
|
op1: removeFirstNodeInRoot,
|
|
719
738
|
op2: modifyLeaf,
|
|
@@ -721,22 +740,22 @@ describe('NodeProperty', function () {
|
|
|
721
740
|
checkResult: function (conflicts, changeSet) {
|
|
722
741
|
expect(conflicts).to.have.length(1);
|
|
723
742
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE);
|
|
724
|
-
expect(conflicts[0].path).to.be.equal(
|
|
743
|
+
expect(conflicts[0].path).to.be.equal("node1");
|
|
725
744
|
expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok;
|
|
726
745
|
},
|
|
727
746
|
});
|
|
728
747
|
});
|
|
729
|
-
it(
|
|
730
|
-
var node1 = PropertyFactory.create(
|
|
748
|
+
it("with two compatible removes should be possible", function () {
|
|
749
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
731
750
|
testRebasing({
|
|
732
751
|
prepare: function (root) {
|
|
733
|
-
root.insert(
|
|
752
|
+
root.insert("node1", node1);
|
|
734
753
|
},
|
|
735
754
|
op1: function (root) {
|
|
736
|
-
root.remove(
|
|
755
|
+
root.remove("node1");
|
|
737
756
|
},
|
|
738
757
|
op2: function (root) {
|
|
739
|
-
root.remove(
|
|
758
|
+
root.remove("node1");
|
|
740
759
|
},
|
|
741
760
|
compareToSequential: false,
|
|
742
761
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -744,17 +763,17 @@ describe('NodeProperty', function () {
|
|
|
744
763
|
},
|
|
745
764
|
});
|
|
746
765
|
});
|
|
747
|
-
it(
|
|
748
|
-
var node1 = PropertyFactory.create(
|
|
766
|
+
it("with two indendent recursive modifies should be possible", function () {
|
|
767
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
749
768
|
testRebasing({
|
|
750
769
|
prepare: function (root) {
|
|
751
|
-
root.insert(
|
|
770
|
+
root.insert("node1", node1);
|
|
752
771
|
},
|
|
753
772
|
op1: function (root) {
|
|
754
|
-
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value =
|
|
773
|
+
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value = "a";
|
|
755
774
|
},
|
|
756
775
|
op2: function (root) {
|
|
757
|
-
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty2.value =
|
|
776
|
+
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty2.value = "a";
|
|
758
777
|
},
|
|
759
778
|
compareToSequential: true,
|
|
760
779
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -762,125 +781,123 @@ describe('NodeProperty', function () {
|
|
|
762
781
|
},
|
|
763
782
|
});
|
|
764
783
|
});
|
|
765
|
-
it(
|
|
766
|
-
var node1 = PropertyFactory.create(
|
|
784
|
+
it("with two conflicting recursive modifies should be possible and report a conflict", function () {
|
|
785
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
767
786
|
testRebasing({
|
|
768
787
|
prepare: function (root) {
|
|
769
|
-
root.insert(
|
|
788
|
+
root.insert("node1", node1);
|
|
770
789
|
},
|
|
771
790
|
op1: function (root) {
|
|
772
|
-
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value =
|
|
791
|
+
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value = "b";
|
|
773
792
|
},
|
|
774
793
|
op2: function (root) {
|
|
775
|
-
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value =
|
|
794
|
+
_.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value = "a";
|
|
776
795
|
},
|
|
777
796
|
compareToSequential: true,
|
|
778
797
|
checkResult: function (conflicts, changeSet) {
|
|
779
798
|
expect(conflicts).to.have.length(1);
|
|
780
|
-
expect(changeSet.modify[
|
|
781
|
-
.
|
|
799
|
+
expect(changeSet.modify["autodesk.tests:MixedNodeTestProperty-1.0.0"].node1.String
|
|
800
|
+
.stringProperty).to.equal("a");
|
|
782
801
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
783
|
-
expect(conflicts[0].path).to.be.equal(
|
|
802
|
+
expect(conflicts[0].path).to.be.equal("node1.stringProperty");
|
|
784
803
|
},
|
|
785
804
|
});
|
|
786
805
|
});
|
|
787
|
-
it(
|
|
788
|
-
var node1 = PropertyFactory.create(
|
|
806
|
+
it("with modify followed by remove+insert should work", function () {
|
|
807
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
789
808
|
testRebasing({
|
|
790
809
|
prepare: function (root) {
|
|
791
|
-
root.insert(
|
|
810
|
+
root.insert("node1", node1);
|
|
792
811
|
},
|
|
793
812
|
op1: modifyLeaf,
|
|
794
813
|
op2: function (root) {
|
|
795
|
-
var node2 = PropertyFactory.create(
|
|
796
|
-
root.remove(
|
|
797
|
-
root.insert(
|
|
814
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
815
|
+
root.remove("node1");
|
|
816
|
+
root.insert("node1", node2);
|
|
798
817
|
},
|
|
799
818
|
compareToSequential: true,
|
|
800
819
|
checkResult: function (conflicts, changeSet) {
|
|
801
820
|
expect(conflicts).to.have.length(1);
|
|
802
821
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY);
|
|
803
|
-
expect(conflicts[0].path).to.be.equal(
|
|
804
|
-
expect(changeSet).to.have.all.keys(
|
|
822
|
+
expect(conflicts[0].path).to.be.equal("node1");
|
|
823
|
+
expect(changeSet).to.have.all.keys("remove", "insert");
|
|
805
824
|
},
|
|
806
825
|
});
|
|
807
826
|
});
|
|
808
|
-
it(
|
|
809
|
-
var node1 = PropertyFactory.create(
|
|
827
|
+
it("with remove+insert followed by modify should report conflict", function () {
|
|
828
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
810
829
|
testRebasing({
|
|
811
830
|
prepare: function (root) {
|
|
812
|
-
root.insert(
|
|
831
|
+
root.insert("node1", node1);
|
|
813
832
|
},
|
|
814
833
|
op1: function (root) {
|
|
815
|
-
var node2 = PropertyFactory.create(
|
|
816
|
-
root.remove(
|
|
817
|
-
root.insert(
|
|
834
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
835
|
+
root.remove("node1");
|
|
836
|
+
root.insert("node1", node2);
|
|
818
837
|
},
|
|
819
838
|
op2: modifyLeaf,
|
|
820
839
|
compareToSequential: false,
|
|
821
840
|
checkResult: function (conflicts, changeSet) {
|
|
822
841
|
expect(conflicts).to.have.length(1);
|
|
823
842
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFICATION_AFTER_REMOVE_INSERT);
|
|
824
|
-
expect(conflicts[0].path).to.be.equal(
|
|
843
|
+
expect(conflicts[0].path).to.be.equal("node1");
|
|
825
844
|
},
|
|
826
845
|
});
|
|
827
846
|
});
|
|
828
|
-
it(
|
|
829
|
-
var node = PropertyFactory.create(
|
|
847
|
+
it("with remove+insert followed by remove+insert should report conflict", function () {
|
|
848
|
+
var node = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
830
849
|
testRebasing({
|
|
831
850
|
prepare: function (root) {
|
|
832
|
-
root.insert(
|
|
851
|
+
root.insert("node", node);
|
|
833
852
|
},
|
|
834
853
|
op1: function (root) {
|
|
835
|
-
root.remove(
|
|
836
|
-
root.insert(
|
|
854
|
+
root.remove("node");
|
|
855
|
+
root.insert("node", PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0"));
|
|
837
856
|
},
|
|
838
857
|
op2: function (root) {
|
|
839
|
-
root.remove(
|
|
840
|
-
root.insert(
|
|
858
|
+
root.remove("node");
|
|
859
|
+
root.insert("node", PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0"));
|
|
841
860
|
},
|
|
842
861
|
compareToSequential: false,
|
|
843
862
|
checkResult: function (conflicts, changeSet) {
|
|
844
863
|
expect(conflicts).to.have.length(1);
|
|
845
864
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
846
|
-
expect(conflicts[0].path).to.be.equal(
|
|
865
|
+
expect(conflicts[0].path).to.be.equal("node");
|
|
847
866
|
},
|
|
848
867
|
});
|
|
849
868
|
});
|
|
850
|
-
it(
|
|
851
|
-
var node1 = PropertyFactory.create(
|
|
852
|
-
var node2 = PropertyFactory.create(
|
|
869
|
+
it("with conflicting inserts should report conflict", function () {
|
|
870
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
871
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
853
872
|
testRebasing({
|
|
854
|
-
prepare: function (root) {
|
|
855
|
-
},
|
|
873
|
+
prepare: function (root) { },
|
|
856
874
|
op1: function (root) {
|
|
857
|
-
root.insert(
|
|
875
|
+
root.insert("node1", node1);
|
|
858
876
|
},
|
|
859
877
|
op2: function (root) {
|
|
860
|
-
root.insert(
|
|
878
|
+
root.insert("node1", node2);
|
|
861
879
|
},
|
|
862
880
|
compareToSequential: false,
|
|
863
881
|
checkResult: function (conflicts, changeSet) {
|
|
864
882
|
expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok;
|
|
865
883
|
expect(conflicts).to.have.length(1);
|
|
866
884
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY);
|
|
867
|
-
expect(conflicts[0].path).to.be.equal(
|
|
885
|
+
expect(conflicts[0].path).to.be.equal("node1");
|
|
868
886
|
},
|
|
869
887
|
});
|
|
870
888
|
});
|
|
871
|
-
it(
|
|
889
|
+
it("with conflicting inserts of primitive types", function () {
|
|
872
890
|
testRebasing({
|
|
873
|
-
prepare: function (root) {
|
|
874
|
-
},
|
|
891
|
+
prepare: function (root) { },
|
|
875
892
|
op1: function (root) {
|
|
876
|
-
var string1 = PropertyFactory.create(
|
|
877
|
-
string1.value =
|
|
878
|
-
root.insert(
|
|
893
|
+
var string1 = PropertyFactory.create("String");
|
|
894
|
+
string1.value = "test1";
|
|
895
|
+
root.insert("entry", string1);
|
|
879
896
|
},
|
|
880
897
|
op2: function (root) {
|
|
881
|
-
var string2 = PropertyFactory.create(
|
|
882
|
-
string2.value =
|
|
883
|
-
root.insert(
|
|
898
|
+
var string2 = PropertyFactory.create("String");
|
|
899
|
+
string2.value = "test2";
|
|
900
|
+
root.insert("entry", string2);
|
|
884
901
|
},
|
|
885
902
|
compareToSequential: false,
|
|
886
903
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -888,33 +905,32 @@ describe('NodeProperty', function () {
|
|
|
888
905
|
modify: {
|
|
889
906
|
String: {
|
|
890
907
|
entry: {
|
|
891
|
-
oldValue:
|
|
892
|
-
value:
|
|
908
|
+
oldValue: "test1",
|
|
909
|
+
value: "test2",
|
|
893
910
|
},
|
|
894
911
|
},
|
|
895
912
|
},
|
|
896
913
|
});
|
|
897
914
|
expect(conflicts).to.have.length(1);
|
|
898
915
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
899
|
-
expect(conflicts[0].path).to.be.equal(
|
|
900
|
-
expect(conflicts[0].conflictingChange).to.be.equal(
|
|
916
|
+
expect(conflicts[0].path).to.be.equal("entry");
|
|
917
|
+
expect(conflicts[0].conflictingChange).to.be.equal("test2");
|
|
901
918
|
},
|
|
902
919
|
});
|
|
903
920
|
});
|
|
904
921
|
// TODO: 'with conflicting inserts of primitive types' is identical to the below test. Why?
|
|
905
|
-
it(
|
|
922
|
+
it("with conflicting recursive modifies of primitive types should be possible and report a conflict", function () {
|
|
906
923
|
testRebasing({
|
|
907
|
-
prepare: function (root) {
|
|
908
|
-
},
|
|
924
|
+
prepare: function (root) { },
|
|
909
925
|
op1: function (root) {
|
|
910
|
-
var string1 = PropertyFactory.create(
|
|
911
|
-
string1.value =
|
|
912
|
-
root.insert(
|
|
926
|
+
var string1 = PropertyFactory.create("String");
|
|
927
|
+
string1.value = "test1";
|
|
928
|
+
root.insert("entry", string1);
|
|
913
929
|
},
|
|
914
930
|
op2: function (root) {
|
|
915
|
-
var string2 = PropertyFactory.create(
|
|
916
|
-
string2.value =
|
|
917
|
-
root.insert(
|
|
931
|
+
var string2 = PropertyFactory.create("String");
|
|
932
|
+
string2.value = "test2";
|
|
933
|
+
root.insert("entry", string2);
|
|
918
934
|
},
|
|
919
935
|
compareToSequential: false,
|
|
920
936
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -922,38 +938,37 @@ describe('NodeProperty', function () {
|
|
|
922
938
|
modify: {
|
|
923
939
|
String: {
|
|
924
940
|
entry: {
|
|
925
|
-
oldValue:
|
|
926
|
-
value:
|
|
941
|
+
oldValue: "test1",
|
|
942
|
+
value: "test2",
|
|
927
943
|
},
|
|
928
944
|
},
|
|
929
945
|
},
|
|
930
946
|
});
|
|
931
947
|
expect(conflicts).to.have.length(1);
|
|
932
948
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
933
|
-
expect(conflicts[0].path).to.be.equal(
|
|
934
|
-
expect(conflicts[0].conflictingChange).to.be.equal(
|
|
949
|
+
expect(conflicts[0].path).to.be.equal("entry");
|
|
950
|
+
expect(conflicts[0].conflictingChange).to.be.equal("test2");
|
|
935
951
|
},
|
|
936
952
|
});
|
|
937
953
|
});
|
|
938
|
-
it(
|
|
954
|
+
it("with conflicting recursive modifies of enums should be possible and report a conflict", function () {
|
|
939
955
|
testRebasing({
|
|
940
|
-
prepare: function (root) {
|
|
941
|
-
},
|
|
956
|
+
prepare: function (root) { },
|
|
942
957
|
op1: function (root) {
|
|
943
|
-
var enum1 = PropertyFactory.create(
|
|
958
|
+
var enum1 = PropertyFactory.create("autodesk.core:UnitsEnum-1.0.0");
|
|
944
959
|
enum1.value = 1;
|
|
945
|
-
root.insert(
|
|
960
|
+
root.insert("entry", enum1);
|
|
946
961
|
},
|
|
947
962
|
op2: function (root) {
|
|
948
|
-
var enum2 = PropertyFactory.create(
|
|
963
|
+
var enum2 = PropertyFactory.create("autodesk.core:UnitsEnum-1.0.0");
|
|
949
964
|
enum2.value = 2;
|
|
950
|
-
root.insert(
|
|
965
|
+
root.insert("entry", enum2);
|
|
951
966
|
},
|
|
952
967
|
compareToSequential: false,
|
|
953
968
|
checkResult: function (conflicts, changeSet) {
|
|
954
969
|
expect(changeSet).to.deep.equal({
|
|
955
970
|
modify: {
|
|
956
|
-
|
|
971
|
+
"enum<autodesk.core:UnitsEnum-1.0.0>": {
|
|
957
972
|
entry: {
|
|
958
973
|
oldValue: 1,
|
|
959
974
|
value: 2,
|
|
@@ -963,67 +978,67 @@ describe('NodeProperty', function () {
|
|
|
963
978
|
});
|
|
964
979
|
expect(conflicts).to.have.length(1);
|
|
965
980
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
966
|
-
expect(conflicts[0].path).to.be.equal(
|
|
981
|
+
expect(conflicts[0].path).to.be.equal("entry");
|
|
967
982
|
expect(conflicts[0].conflictingChange).to.be.equal(2);
|
|
968
983
|
},
|
|
969
984
|
});
|
|
970
985
|
});
|
|
971
|
-
it(
|
|
986
|
+
it("with conflicting inserts in a deep leaf should report a correct conflict", function () {
|
|
972
987
|
testRebasing({
|
|
973
988
|
prepare: function (root) {
|
|
974
|
-
var node = PropertyFactory.create(
|
|
975
|
-
root.insert(
|
|
989
|
+
var node = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
990
|
+
root.insert("node", node);
|
|
976
991
|
},
|
|
977
992
|
op1: function (root) {
|
|
978
|
-
var node1 = PropertyFactory.create(
|
|
979
|
-
root.resolvePath(
|
|
993
|
+
var node1 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
994
|
+
root.resolvePath("node").insert("node2", node1);
|
|
980
995
|
},
|
|
981
996
|
op2: function (root) {
|
|
982
|
-
var node2 = PropertyFactory.create(
|
|
983
|
-
root.resolvePath(
|
|
997
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
998
|
+
root.resolvePath("node").insert("node2", node2);
|
|
984
999
|
},
|
|
985
1000
|
compareToSequential: false,
|
|
986
1001
|
checkResult: function (conflicts, changeSet) {
|
|
987
1002
|
expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok;
|
|
988
1003
|
expect(conflicts).to.have.length(1);
|
|
989
1004
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY);
|
|
990
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1005
|
+
expect(conflicts[0].path).to.be.equal("node.node2");
|
|
991
1006
|
},
|
|
992
1007
|
});
|
|
993
1008
|
});
|
|
994
1009
|
});
|
|
995
|
-
describe(
|
|
1010
|
+
describe("Compatibility with ChangeSets from spec", function () {
|
|
996
1011
|
// These are the ChangeSets from the discussion minutes document
|
|
997
1012
|
// after some cleanup, mainly missing parameters were added in inserts and
|
|
998
1013
|
// syntax corrections. Additionally, the Vector3 was renamed to autodesk.test:vector3-1.0.0 to avoid
|
|
999
1014
|
// conflicts with the inbuilt type
|
|
1000
1015
|
var insertChangeSet1 = {
|
|
1001
1016
|
insert: {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1017
|
+
"autodesk.test:point2d-1.0.0": {
|
|
1018
|
+
myPoint: {
|
|
1019
|
+
"Float32": {
|
|
1020
|
+
"position.x": 122,
|
|
1021
|
+
"position.y": 122,
|
|
1022
|
+
"temperature": 10,
|
|
1008
1023
|
},
|
|
1009
|
-
|
|
1010
|
-
|
|
1024
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1025
|
+
normal: {
|
|
1011
1026
|
Float32: {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1027
|
+
x: 1,
|
|
1028
|
+
y: 1,
|
|
1029
|
+
z: 1,
|
|
1015
1030
|
},
|
|
1016
1031
|
},
|
|
1017
1032
|
},
|
|
1018
|
-
|
|
1019
|
-
|
|
1033
|
+
"map<autodesk.test:vector3-1.0.0>": {
|
|
1034
|
+
neighbours: {
|
|
1020
1035
|
insert: {
|
|
1021
|
-
|
|
1022
|
-
|
|
1036
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1037
|
+
Point1: {
|
|
1023
1038
|
Float32: {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1039
|
+
x: 1,
|
|
1040
|
+
y: 1,
|
|
1041
|
+
z: 1,
|
|
1027
1042
|
},
|
|
1028
1043
|
},
|
|
1029
1044
|
},
|
|
@@ -1031,38 +1046,38 @@ describe('NodeProperty', function () {
|
|
|
1031
1046
|
},
|
|
1032
1047
|
},
|
|
1033
1048
|
},
|
|
1034
|
-
|
|
1035
|
-
Float32: {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1049
|
+
d23kjda: {
|
|
1050
|
+
"Float32": {
|
|
1051
|
+
"position.x": 122,
|
|
1052
|
+
"position.y": 122,
|
|
1053
|
+
"temperature": 11,
|
|
1039
1054
|
},
|
|
1040
|
-
|
|
1041
|
-
|
|
1055
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1056
|
+
normal: {
|
|
1042
1057
|
Float32: {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1058
|
+
x: 1,
|
|
1059
|
+
y: 1,
|
|
1060
|
+
z: 1,
|
|
1046
1061
|
},
|
|
1047
1062
|
},
|
|
1048
1063
|
},
|
|
1049
|
-
|
|
1050
|
-
|
|
1064
|
+
"map<autodesk.test:vector3-1.0.0>": {
|
|
1065
|
+
neighbours: {},
|
|
1051
1066
|
},
|
|
1052
1067
|
},
|
|
1053
1068
|
},
|
|
1054
|
-
Float32: {
|
|
1055
|
-
|
|
1069
|
+
"Float32": {
|
|
1070
|
+
compression: 0,
|
|
1056
1071
|
},
|
|
1057
|
-
|
|
1072
|
+
"map<>": {
|
|
1058
1073
|
birds: {
|
|
1059
1074
|
insert: {
|
|
1060
|
-
|
|
1061
|
-
|
|
1075
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1076
|
+
Point1: {
|
|
1062
1077
|
Float32: {
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1078
|
+
x: 1,
|
|
1079
|
+
y: 1,
|
|
1080
|
+
z: 1,
|
|
1066
1081
|
},
|
|
1067
1082
|
},
|
|
1068
1083
|
},
|
|
@@ -1075,16 +1090,16 @@ describe('NodeProperty', function () {
|
|
|
1075
1090
|
};
|
|
1076
1091
|
var modifyChangeSet1 = {
|
|
1077
1092
|
modify: {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1093
|
+
"autodesk.test:point2d-1.0.0": {
|
|
1094
|
+
myPoint: {
|
|
1095
|
+
"Float32": {
|
|
1096
|
+
"position.x": 11,
|
|
1097
|
+
"temperature": 31,
|
|
1083
1098
|
},
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1099
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1100
|
+
normal: {
|
|
1101
|
+
Float32: {
|
|
1102
|
+
x: 0.5,
|
|
1088
1103
|
},
|
|
1089
1104
|
},
|
|
1090
1105
|
},
|
|
@@ -1094,17 +1109,17 @@ describe('NodeProperty', function () {
|
|
|
1094
1109
|
};
|
|
1095
1110
|
var modifyChangeSet2 = {
|
|
1096
1111
|
modify: {
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1112
|
+
"autodesk.test:point2d-1.0.0": {
|
|
1113
|
+
myPoint: {
|
|
1114
|
+
"map<autodesk.test:vector3-1.0.0>": {
|
|
1115
|
+
neighbours: {
|
|
1101
1116
|
insert: {
|
|
1102
|
-
|
|
1103
|
-
|
|
1117
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1118
|
+
Point2: {
|
|
1104
1119
|
Float32: {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1120
|
+
x: 1,
|
|
1121
|
+
y: 1,
|
|
1122
|
+
z: 1,
|
|
1108
1123
|
},
|
|
1109
1124
|
},
|
|
1110
1125
|
},
|
|
@@ -1117,15 +1132,15 @@ describe('NodeProperty', function () {
|
|
|
1117
1132
|
};
|
|
1118
1133
|
var modifyChangeSet3 = {
|
|
1119
1134
|
modify: {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1135
|
+
"autodesk.test:point2d-1.0.0": {
|
|
1136
|
+
myPoint: {
|
|
1137
|
+
"map<autodesk.test:vector3-1.0.0>": {
|
|
1138
|
+
neighbours: {
|
|
1124
1139
|
modify: {
|
|
1125
|
-
|
|
1126
|
-
|
|
1140
|
+
"autodesk.test:vector3-1.0.0": {
|
|
1141
|
+
Point2: {
|
|
1127
1142
|
Float32: {
|
|
1128
|
-
|
|
1143
|
+
x: 2,
|
|
1129
1144
|
},
|
|
1130
1145
|
},
|
|
1131
1146
|
},
|
|
@@ -1138,11 +1153,11 @@ describe('NodeProperty', function () {
|
|
|
1138
1153
|
};
|
|
1139
1154
|
var removePreparationChangeSet1 = {
|
|
1140
1155
|
insert: {
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1156
|
+
"autodesk.test:SceneObject-1.0.0": {
|
|
1157
|
+
dasdm23: {
|
|
1158
|
+
String: {
|
|
1159
|
+
revitId: "#23213",
|
|
1160
|
+
name: "Door",
|
|
1146
1161
|
},
|
|
1147
1162
|
},
|
|
1148
1163
|
},
|
|
@@ -1150,14 +1165,14 @@ describe('NodeProperty', function () {
|
|
|
1150
1165
|
};
|
|
1151
1166
|
var removePreparationChangeSet2 = {
|
|
1152
1167
|
modify: {
|
|
1153
|
-
|
|
1154
|
-
|
|
1168
|
+
"autodesk.test:SceneObject-1.0.0": {
|
|
1169
|
+
dasdm23: {
|
|
1155
1170
|
insert: {
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1171
|
+
"autodesk.test:SceneObject-1.0.0": {
|
|
1172
|
+
as2398d: {
|
|
1173
|
+
String: {
|
|
1174
|
+
revitId: "#2231",
|
|
1175
|
+
name: "Room",
|
|
1161
1176
|
},
|
|
1162
1177
|
},
|
|
1163
1178
|
},
|
|
@@ -1167,86 +1182,82 @@ describe('NodeProperty', function () {
|
|
|
1167
1182
|
},
|
|
1168
1183
|
};
|
|
1169
1184
|
var removeChangeSet1 = {
|
|
1170
|
-
remove: [
|
|
1171
|
-
'dasdm23',
|
|
1172
|
-
],
|
|
1185
|
+
remove: ["dasdm23"],
|
|
1173
1186
|
};
|
|
1174
1187
|
var removeChangeSet2 = {
|
|
1175
1188
|
modify: {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
remove: [
|
|
1179
|
-
'as2398d',
|
|
1180
|
-
],
|
|
1189
|
+
"autodesk.test:SceneObject-1.0.0": {
|
|
1190
|
+
dasdm23: {
|
|
1191
|
+
remove: ["as2398d"],
|
|
1181
1192
|
},
|
|
1182
1193
|
},
|
|
1183
1194
|
},
|
|
1184
1195
|
};
|
|
1185
|
-
it(
|
|
1186
|
-
var rootProperty = PropertyFactory.create(
|
|
1196
|
+
it("should be possible to insert properties with the example from the spec", function () {
|
|
1197
|
+
var rootProperty = PropertyFactory.create("NodeProperty");
|
|
1187
1198
|
rootProperty.applyChangeSet(insertChangeSet1);
|
|
1188
1199
|
// Make sure all properties are as expected
|
|
1189
1200
|
expect(rootProperty.getDynamicIds().length).to.equal(6);
|
|
1190
|
-
expect(rootProperty._getDynamicChildrenReadOnly()).to.have.all.keys(
|
|
1201
|
+
expect(rootProperty._getDynamicChildrenReadOnly()).to.have.all.keys("birds", "horses", "forest", "compression", "myPoint", "d23kjda");
|
|
1191
1202
|
expect(rootProperty._properties.compression.value).to.equal(0);
|
|
1192
1203
|
assert(rootProperty._properties.birds instanceof MapProperty);
|
|
1193
1204
|
assert(rootProperty._properties.forest instanceof MapProperty);
|
|
1194
1205
|
assert(rootProperty._properties.horses instanceof MapProperty);
|
|
1195
|
-
expect(rootProperty.resolvePath(
|
|
1196
|
-
expect(rootProperty.resolvePath(
|
|
1197
|
-
expect(rootProperty.resolvePath(
|
|
1198
|
-
expect(rootProperty.resolvePath(
|
|
1199
|
-
expect(rootProperty.resolvePath(
|
|
1200
|
-
expect(rootProperty.resolvePath(
|
|
1201
|
-
var neighbours = rootProperty.resolvePath(
|
|
1202
|
-
assert(neighbours.has(
|
|
1203
|
-
expect(neighbours.get(
|
|
1204
|
-
expect(neighbours.get(
|
|
1205
|
-
expect(neighbours.get(
|
|
1206
|
-
expect(rootProperty.resolvePath(
|
|
1207
|
-
expect(rootProperty.resolvePath(
|
|
1208
|
-
expect(rootProperty.resolvePath(
|
|
1209
|
-
expect(rootProperty.resolvePath(
|
|
1210
|
-
expect(rootProperty.resolvePath(
|
|
1211
|
-
expect(rootProperty.resolvePath(
|
|
1206
|
+
expect(rootProperty.resolvePath("myPoint.position.x").value).to.equal(122);
|
|
1207
|
+
expect(rootProperty.resolvePath("myPoint.position.y").value).to.equal(122);
|
|
1208
|
+
expect(rootProperty.resolvePath("myPoint.temperature").value).to.equal(10);
|
|
1209
|
+
expect(rootProperty.resolvePath("myPoint.normal.x").value).to.equal(1);
|
|
1210
|
+
expect(rootProperty.resolvePath("myPoint.normal.y").value).to.equal(1);
|
|
1211
|
+
expect(rootProperty.resolvePath("myPoint.normal.z").value).to.equal(1);
|
|
1212
|
+
var neighbours = rootProperty.resolvePath("myPoint.neighbours");
|
|
1213
|
+
assert(neighbours.has("Point1"));
|
|
1214
|
+
expect(neighbours.get("Point1")._properties.x.value).to.equal(1);
|
|
1215
|
+
expect(neighbours.get("Point1")._properties.y.value).to.equal(1);
|
|
1216
|
+
expect(neighbours.get("Point1")._properties.z.value).to.equal(1);
|
|
1217
|
+
expect(rootProperty.resolvePath("d23kjda.position.x").value).to.equal(122);
|
|
1218
|
+
expect(rootProperty.resolvePath("d23kjda.position.y").value).to.equal(122);
|
|
1219
|
+
expect(rootProperty.resolvePath("d23kjda.temperature").value).to.equal(11);
|
|
1220
|
+
expect(rootProperty.resolvePath("d23kjda.normal.x").value).to.equal(1);
|
|
1221
|
+
expect(rootProperty.resolvePath("d23kjda.normal.y").value).to.equal(1);
|
|
1222
|
+
expect(rootProperty.resolvePath("d23kjda.normal.z").value).to.equal(1);
|
|
1212
1223
|
// Make sure serialization gives the same result as the initial ChangeSet
|
|
1213
|
-
expect(rootProperty.serialize({
|
|
1214
|
-
expect(rootProperty.serialize({
|
|
1224
|
+
expect(rootProperty.serialize({ dirtyOnly: false })).to.deep.equal(insertChangeSet1);
|
|
1225
|
+
expect(rootProperty.serialize({ dirtyOnly: true })).to.deep.equal(insertChangeSet1);
|
|
1215
1226
|
});
|
|
1216
|
-
it(
|
|
1227
|
+
it("should be possible to use the first modify ChangeSet from the spec", function () {
|
|
1217
1228
|
// Prepare the initial state
|
|
1218
|
-
var rootProperty = PropertyFactory.create(
|
|
1229
|
+
var rootProperty = PropertyFactory.create("NodeProperty");
|
|
1219
1230
|
rootProperty.applyChangeSet(insertChangeSet1);
|
|
1220
1231
|
// Clean dirtiness
|
|
1221
1232
|
rootProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
1222
1233
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
1223
1234
|
// Apply the modify changeSet
|
|
1224
1235
|
rootProperty.applyChangeSet(modifyChangeSet1);
|
|
1225
|
-
expect(rootProperty.resolvePath(
|
|
1226
|
-
expect(rootProperty.resolvePath(
|
|
1227
|
-
expect(rootProperty.resolvePath(
|
|
1236
|
+
expect(rootProperty.resolvePath("myPoint.position.x").value).to.equal(11);
|
|
1237
|
+
expect(rootProperty.resolvePath("myPoint.normal.x").value).to.equal(0.5);
|
|
1238
|
+
expect(rootProperty.resolvePath("myPoint.temperature").value).to.equal(31);
|
|
1228
1239
|
// Make sure the serialization gives the expected result
|
|
1229
|
-
expect(rootProperty.serialize({
|
|
1240
|
+
expect(rootProperty.serialize({ dirtyOnly: true })).to.deep.equal(modifyChangeSet1);
|
|
1230
1241
|
});
|
|
1231
|
-
it(
|
|
1242
|
+
it("should be possible to use the second modify ChangeSet from the spec", function () {
|
|
1232
1243
|
// Prepare the initial state
|
|
1233
|
-
var rootProperty = PropertyFactory.create(
|
|
1244
|
+
var rootProperty = PropertyFactory.create("NodeProperty");
|
|
1234
1245
|
rootProperty.applyChangeSet(insertChangeSet1);
|
|
1235
1246
|
// Clean dirtiness
|
|
1236
1247
|
rootProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
1237
1248
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
1238
1249
|
// Apply the modify changeSet
|
|
1239
1250
|
rootProperty.applyChangeSet(modifyChangeSet2);
|
|
1240
|
-
var point2 = rootProperty.resolvePath(
|
|
1251
|
+
var point2 = rootProperty.resolvePath("myPoint.neighbours").get("Point2");
|
|
1241
1252
|
expect(point2._properties.x.value).to.equal(1);
|
|
1242
1253
|
expect(point2._properties.y.value).to.equal(1);
|
|
1243
1254
|
expect(point2._properties.z.value).to.equal(1);
|
|
1244
1255
|
// Make sure the serialization gives the expected result
|
|
1245
|
-
expect(rootProperty.serialize({
|
|
1256
|
+
expect(rootProperty.serialize({ dirtyOnly: true })).to.deep.equal(modifyChangeSet2);
|
|
1246
1257
|
});
|
|
1247
|
-
it(
|
|
1258
|
+
it("should be possible to use the third modify ChangeSet from the spec", function () {
|
|
1248
1259
|
// Prepare the initial state
|
|
1249
|
-
var rootProperty = PropertyFactory.create(
|
|
1260
|
+
var rootProperty = PropertyFactory.create("NodeProperty");
|
|
1250
1261
|
rootProperty.applyChangeSet(insertChangeSet1);
|
|
1251
1262
|
rootProperty.applyChangeSet(modifyChangeSet2);
|
|
1252
1263
|
// Clean dirtiness
|
|
@@ -1254,14 +1265,14 @@ describe('NodeProperty', function () {
|
|
|
1254
1265
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
1255
1266
|
// Apply the modify changeSet
|
|
1256
1267
|
rootProperty.applyChangeSet(modifyChangeSet3);
|
|
1257
|
-
var point2 = rootProperty.resolvePath(
|
|
1268
|
+
var point2 = rootProperty.resolvePath("myPoint.neighbours").get("Point2");
|
|
1258
1269
|
expect(point2._properties.x.value).to.equal(2);
|
|
1259
1270
|
// Make sure the serialization gives the expected result
|
|
1260
|
-
expect(rootProperty.serialize({
|
|
1271
|
+
expect(rootProperty.serialize({ dirtyOnly: true })).to.deep.equal(modifyChangeSet3);
|
|
1261
1272
|
});
|
|
1262
|
-
it(
|
|
1273
|
+
it("should be possible to use the first remove ChangeSet from the spec", function () {
|
|
1263
1274
|
// Prepare the initial state
|
|
1264
|
-
var rootProperty = PropertyFactory.create(
|
|
1275
|
+
var rootProperty = PropertyFactory.create("NodeProperty");
|
|
1265
1276
|
rootProperty.applyChangeSet(removePreparationChangeSet1);
|
|
1266
1277
|
rootProperty.applyChangeSet(removePreparationChangeSet2);
|
|
1267
1278
|
// Clean dirtiness
|
|
@@ -1272,70 +1283,70 @@ describe('NodeProperty', function () {
|
|
|
1272
1283
|
rootProperty.applyChangeSet(removeChangeSet1);
|
|
1273
1284
|
expect(rootProperty.getDynamicIds().length).to.be.equal(0);
|
|
1274
1285
|
// Make sure the serialization gives the expected result
|
|
1275
|
-
expect(rootProperty.serialize({
|
|
1286
|
+
expect(rootProperty.serialize({ dirtyOnly: true })).to.deep.equal(removeChangeSet1);
|
|
1276
1287
|
});
|
|
1277
|
-
it(
|
|
1288
|
+
it("should be possible to use the first remove ChangeSet from the spec", function () {
|
|
1278
1289
|
// Prepare the initial state
|
|
1279
|
-
var rootProperty = PropertyFactory.create(
|
|
1290
|
+
var rootProperty = PropertyFactory.create("NodeProperty");
|
|
1280
1291
|
rootProperty.applyChangeSet(removePreparationChangeSet1);
|
|
1281
1292
|
rootProperty.applyChangeSet(removePreparationChangeSet2);
|
|
1282
1293
|
// Clean dirtiness
|
|
1283
1294
|
rootProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
1284
1295
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
1285
1296
|
// Apply the remove changeSet
|
|
1286
|
-
expect(rootProperty.resolvePath(
|
|
1297
|
+
expect(rootProperty.resolvePath("dasdm23").getDynamicIds().length).to.be.equal(1);
|
|
1287
1298
|
rootProperty.applyChangeSet(removeChangeSet2);
|
|
1288
1299
|
expect(rootProperty.getDynamicIds().length).to.be.equal(1);
|
|
1289
|
-
expect(rootProperty.resolvePath(
|
|
1300
|
+
expect(rootProperty.resolvePath("dasdm23").getDynamicIds().length).to.be.equal(0);
|
|
1290
1301
|
// Make sure the serialization gives the expected result
|
|
1291
|
-
expect(rootProperty.serialize({
|
|
1302
|
+
expect(rootProperty.serialize({ dirtyOnly: true })).to.deep.equal(removeChangeSet2);
|
|
1292
1303
|
});
|
|
1293
1304
|
});
|
|
1294
|
-
describe(
|
|
1295
|
-
it(
|
|
1296
|
-
var root = PropertyFactory.create(
|
|
1297
|
-
var newRoot = PropertyFactory.create(
|
|
1305
|
+
describe("Make sure struct changes and path updates are signaled correctly", function () {
|
|
1306
|
+
it("Should be possible to access dynamic nodes via propertis and paths", function () {
|
|
1307
|
+
var root = PropertyFactory.create("NodeProperty");
|
|
1308
|
+
var newRoot = PropertyFactory.create("NodeProperty");
|
|
1298
1309
|
// Create a hierarchy of nodes
|
|
1299
|
-
root.insert(
|
|
1300
|
-
root.insert(
|
|
1310
|
+
root.insert("child1", PropertyFactory.create("NodeProperty"));
|
|
1311
|
+
root.insert("child2", PropertyFactory.create("NodeProperty"));
|
|
1301
1312
|
expect(root._properties.child1.position).to.be.undefined;
|
|
1302
|
-
expect(root.resolvePath(
|
|
1313
|
+
expect(root.resolvePath("child1.position")).to.be.undefined;
|
|
1303
1314
|
// Crate a dynamic object via a NodeProperty
|
|
1304
|
-
var positionProperty = PropertyFactory.create(
|
|
1305
|
-
root._properties.child1.propertyNode.insert(
|
|
1306
|
-
root._properties.child1.position.propertyNode.insert(
|
|
1307
|
-
root._properties.child1.position.propertyNode.insert(
|
|
1308
|
-
root._properties.child1.position.propertyNode.insert(
|
|
1315
|
+
var positionProperty = PropertyFactory.create("NodeProperty");
|
|
1316
|
+
root._properties.child1.propertyNode.insert("position", positionProperty);
|
|
1317
|
+
root._properties.child1.position.propertyNode.insert("x", PropertyFactory.create("Float32"));
|
|
1318
|
+
root._properties.child1.position.propertyNode.insert("y", PropertyFactory.create("Float32"));
|
|
1319
|
+
root._properties.child1.position.propertyNode.insert("z", PropertyFactory.create("Float32"));
|
|
1309
1320
|
// Make sure paths resolve correctly
|
|
1310
1321
|
expect(root._properties.child1.position).not.to.be.undefined;
|
|
1311
1322
|
expect(root._properties.child1.position.propertyNode).to.be.an.instanceof(NodeProperty);
|
|
1312
|
-
expect(root.resolvePath(
|
|
1323
|
+
expect(root.resolvePath("child1.position")).to.be.instanceof(NodeProperty);
|
|
1313
1324
|
// assign values via the properties object (for NodeProperty)
|
|
1314
1325
|
root._properties.child1.position.x.value = 1;
|
|
1315
1326
|
root._properties.child1.position.y.value = 2;
|
|
1316
1327
|
root._properties.child1.position.z.value = 3;
|
|
1317
1328
|
// assign values via resolve path
|
|
1318
|
-
root.resolvePath(
|
|
1319
|
-
root.resolvePath(
|
|
1320
|
-
root.resolvePath(
|
|
1329
|
+
root.resolvePath("child1.position.x").value = 3;
|
|
1330
|
+
root.resolvePath("child1.position.y").value = 2;
|
|
1331
|
+
root.resolvePath("child1.position.z").value = 1;
|
|
1321
1332
|
// Check values
|
|
1322
1333
|
expect(root._properties.child1.position.x.value).to.equal(3);
|
|
1323
1334
|
expect(root._properties.child1.position.y.value).to.equal(2);
|
|
1324
1335
|
expect(root._properties.child1.position.z.value).to.equal(1);
|
|
1325
1336
|
// Crate a dynamic object via a template
|
|
1326
|
-
var vec3Property = PropertyFactory.create(
|
|
1327
|
-
root._properties.child1.propertyNode.insert(
|
|
1337
|
+
var vec3Property = PropertyFactory.create("autodesk.test:vector3-1.0.0");
|
|
1338
|
+
root._properties.child1.propertyNode.insert("vector", vec3Property);
|
|
1328
1339
|
// Make sure paths resolve correctly
|
|
1329
1340
|
expect(root._properties.child1.vector).not.to.be.undefined;
|
|
1330
1341
|
expect(root._properties.child1.vector.propertyNode).to.be.an.instanceof(BaseProperty);
|
|
1331
|
-
expect(root.resolvePath(
|
|
1342
|
+
expect(root.resolvePath("child1.vector")).to.be.instanceof(BaseProperty);
|
|
1332
1343
|
root._properties.child1.vector.x.value = 1;
|
|
1333
1344
|
root._properties.child1.vector.y.value = 2;
|
|
1334
1345
|
root._properties.child1.vector.z.value = 3;
|
|
1335
1346
|
// assign values via resolve path
|
|
1336
|
-
root.resolvePath(
|
|
1337
|
-
root.resolvePath(
|
|
1338
|
-
root.resolvePath(
|
|
1347
|
+
root.resolvePath("child1.vector.x").value = 3;
|
|
1348
|
+
root.resolvePath("child1.vector.y").value = 2;
|
|
1349
|
+
root.resolvePath("child1.vector.z").value = 1;
|
|
1339
1350
|
// Check values
|
|
1340
1351
|
expect(root._properties.child1.vector.x.value).to.equal(3);
|
|
1341
1352
|
expect(root._properties.child1.vector.y.value).to.equal(2);
|
|
@@ -1346,45 +1357,45 @@ describe('NodeProperty', function () {
|
|
|
1346
1357
|
expect(vec3Property.getRoot()).to.equal(root);
|
|
1347
1358
|
expect(vec3Property._properties.x.getRoot()).to.equal(root);
|
|
1348
1359
|
// Check paths
|
|
1349
|
-
expect(positionProperty.getAbsolutePath()).to.equal(
|
|
1350
|
-
expect(positionProperty._properties.x.getAbsolutePath()).to.equal(
|
|
1351
|
-
expect(vec3Property.getAbsolutePath()).to.equal(
|
|
1352
|
-
expect(vec3Property._properties.x.getAbsolutePath()).to.equal(
|
|
1360
|
+
expect(positionProperty.getAbsolutePath()).to.equal("/child1.position");
|
|
1361
|
+
expect(positionProperty._properties.x.getAbsolutePath()).to.equal("/child1.position.x");
|
|
1362
|
+
expect(vec3Property.getAbsolutePath()).to.equal("/child1.vector");
|
|
1363
|
+
expect(vec3Property._properties.x.getAbsolutePath()).to.equal("/child1.vector.x");
|
|
1353
1364
|
// Check deletion
|
|
1354
|
-
root._properties.child1.propertyNode.remove(
|
|
1355
|
-
root._properties.child1.propertyNode.remove(
|
|
1365
|
+
root._properties.child1.propertyNode.remove("position");
|
|
1366
|
+
root._properties.child1.propertyNode.remove("vector");
|
|
1356
1367
|
expect(root._properties.child1.position).to.be.undefined;
|
|
1357
|
-
expect(root.resolvePath(
|
|
1368
|
+
expect(root.resolvePath("child1.position")).to.be.undefined;
|
|
1358
1369
|
expect(root._properties.child1.vector).to.be.undefined;
|
|
1359
|
-
expect(root.resolvePath(
|
|
1370
|
+
expect(root.resolvePath("child1.vector")).to.be.undefined;
|
|
1360
1371
|
// Check roots
|
|
1361
1372
|
expect(positionProperty.getRoot()).to.equal(positionProperty);
|
|
1362
1373
|
expect(positionProperty._properties.x.getRoot()).to.equal(positionProperty);
|
|
1363
1374
|
expect(vec3Property.getRoot()).to.equal(vec3Property);
|
|
1364
1375
|
expect(vec3Property._properties.x.getRoot()).to.equal(vec3Property);
|
|
1365
1376
|
// Check paths
|
|
1366
|
-
expect(positionProperty.getAbsolutePath()).to.equal(
|
|
1367
|
-
expect(positionProperty._properties.x.getAbsolutePath()).to.equal(
|
|
1368
|
-
expect(vec3Property.getAbsolutePath()).to.equal(
|
|
1369
|
-
expect(vec3Property._properties.x.getAbsolutePath()).to.equal(
|
|
1377
|
+
expect(positionProperty.getAbsolutePath()).to.equal("/");
|
|
1378
|
+
expect(positionProperty._properties.x.getAbsolutePath()).to.equal("/x");
|
|
1379
|
+
expect(vec3Property.getAbsolutePath()).to.equal("/");
|
|
1380
|
+
expect(vec3Property._properties.x.getAbsolutePath()).to.equal("/x");
|
|
1370
1381
|
// Check addition to a new property root under a different key
|
|
1371
|
-
newRoot.insert(
|
|
1372
|
-
newRoot.insert(
|
|
1382
|
+
newRoot.insert("newPosition", positionProperty);
|
|
1383
|
+
newRoot.insert("newvector", vec3Property);
|
|
1373
1384
|
// Check roots
|
|
1374
1385
|
expect(positionProperty.getRoot()).to.equal(newRoot);
|
|
1375
1386
|
expect(positionProperty._properties.x.getRoot()).to.equal(newRoot);
|
|
1376
1387
|
expect(vec3Property.getRoot()).to.equal(newRoot);
|
|
1377
1388
|
expect(vec3Property._properties.x.getRoot()).to.equal(newRoot);
|
|
1378
1389
|
// Check paths
|
|
1379
|
-
expect(positionProperty.getAbsolutePath()).to.equal(
|
|
1380
|
-
expect(positionProperty._properties.x.getAbsolutePath()).to.equal(
|
|
1381
|
-
expect(vec3Property.getAbsolutePath()).to.equal(
|
|
1382
|
-
expect(vec3Property._properties.x.getAbsolutePath()).to.equal(
|
|
1390
|
+
expect(positionProperty.getAbsolutePath()).to.equal("/newPosition");
|
|
1391
|
+
expect(positionProperty._properties.x.getAbsolutePath()).to.equal("/newPosition.x");
|
|
1392
|
+
expect(vec3Property.getAbsolutePath()).to.equal("/newvector");
|
|
1393
|
+
expect(vec3Property._properties.x.getAbsolutePath()).to.equal("/newvector.x");
|
|
1383
1394
|
// Check keys with characters that require quotations
|
|
1384
|
-
newRoot.remove(
|
|
1385
|
-
newRoot.remove(
|
|
1395
|
+
newRoot.remove("newPosition");
|
|
1396
|
+
newRoot.remove("newvector");
|
|
1386
1397
|
newRoot.insert('new"Position', positionProperty);
|
|
1387
|
-
newRoot.insert(
|
|
1398
|
+
newRoot.insert("new.Vector", vec3Property);
|
|
1388
1399
|
// Check paths
|
|
1389
1400
|
expect(positionProperty.getAbsolutePath()).to.equal('/"new\\"Position"');
|
|
1390
1401
|
expect(positionProperty._properties.x.getAbsolutePath()).to.equal('/"new\\"Position".x');
|
|
@@ -1394,310 +1405,309 @@ describe('NodeProperty', function () {
|
|
|
1394
1405
|
expect(newRoot.resolvePath('"new.Vector".x')).to.equal(vec3Property._properties.x);
|
|
1395
1406
|
newRoot.remove('new"Position');
|
|
1396
1407
|
// Path resolution for named properties should return the correct path
|
|
1397
|
-
var namedProperty = PropertyFactory.create(
|
|
1398
|
-
var nodeProperty = PropertyFactory.create(
|
|
1408
|
+
var namedProperty = PropertyFactory.create("NamedProperty");
|
|
1409
|
+
var nodeProperty = PropertyFactory.create("NodeProperty");
|
|
1399
1410
|
nodeProperty.insert(namedProperty);
|
|
1400
|
-
expect(namedProperty.getAbsolutePath()).to.equal(
|
|
1411
|
+
expect(namedProperty.getAbsolutePath()).to.equal("/" + namedProperty.getGuid());
|
|
1401
1412
|
expect(nodeProperty.resolvePath(namedProperty.getGuid())).to.equal(namedProperty);
|
|
1402
1413
|
// Try multiple levels
|
|
1403
|
-
var leaf = PropertyFactory.create(
|
|
1404
|
-
expect(leaf.resolvePath(
|
|
1405
|
-
var map1 = PropertyFactory.create(
|
|
1406
|
-
map1.insert(
|
|
1407
|
-
expect(leaf.resolvePath(
|
|
1408
|
-
var map2 = PropertyFactory.create(
|
|
1409
|
-
map2.insert(
|
|
1410
|
-
expect(leaf.resolvePath(
|
|
1411
|
-
var map3 = PropertyFactory.create(
|
|
1412
|
-
map3.insert(
|
|
1413
|
-
expect(leaf.resolvePath(
|
|
1414
|
+
var leaf = PropertyFactory.create("NodeProperty");
|
|
1415
|
+
expect(leaf.resolvePath("/")).to.equal(leaf);
|
|
1416
|
+
var map1 = PropertyFactory.create("NodeProperty");
|
|
1417
|
+
map1.insert("entry", leaf);
|
|
1418
|
+
expect(leaf.resolvePath("/")).to.equal(map1);
|
|
1419
|
+
var map2 = PropertyFactory.create("NodeProperty");
|
|
1420
|
+
map2.insert("entry", map1);
|
|
1421
|
+
expect(leaf.resolvePath("/")).to.equal(map2);
|
|
1422
|
+
var map3 = PropertyFactory.create("NodeProperty");
|
|
1423
|
+
map3.insert("entry", map2);
|
|
1424
|
+
expect(leaf.resolvePath("/")).to.equal(map3);
|
|
1414
1425
|
});
|
|
1415
1426
|
});
|
|
1416
|
-
it(
|
|
1417
|
-
var property = PropertyFactory.create(
|
|
1418
|
-
var childProperty = property.get(
|
|
1419
|
-
childProperty.value =
|
|
1427
|
+
it("should correctly clean templates inheriting from NamedNodeProperty", function () {
|
|
1428
|
+
var property = PropertyFactory.create("autodesk.tests:MixedNamedNodeProperty-1.0.0");
|
|
1429
|
+
var childProperty = property.get("stringProperty");
|
|
1430
|
+
childProperty.value = "changed";
|
|
1420
1431
|
expect(childProperty.isDirty()).to.be.true;
|
|
1421
1432
|
property.cleanDirty();
|
|
1422
1433
|
expect(property.isDirty()).to.be.false;
|
|
1423
1434
|
expect(childProperty.isDirty()).to.be.false;
|
|
1424
1435
|
});
|
|
1425
|
-
describe(
|
|
1426
|
-
it(
|
|
1427
|
-
var node1 = PropertyFactory.create(
|
|
1428
|
-
var node2 = PropertyFactory.create(
|
|
1429
|
-
var node3 = PropertyFactory.create(
|
|
1430
|
-
node1.insert(
|
|
1431
|
-
node3.insert(
|
|
1432
|
-
node2._properties.stringProperty.value =
|
|
1433
|
-
expect(node1.resolvePath(
|
|
1434
|
-
expect(node3.resolvePath(
|
|
1436
|
+
describe("Make sure to have appropriate types for ids given to nodeProperty when inserting", function () {
|
|
1437
|
+
it("should be possible for the id passed to be a string", function (done) {
|
|
1438
|
+
var node1 = PropertyFactory.create("NodeProperty");
|
|
1439
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNamedNodeProperty-1.0.0");
|
|
1440
|
+
var node3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
1441
|
+
node1.insert("node", node3);
|
|
1442
|
+
node3.insert("node1", node2);
|
|
1443
|
+
node2._properties.stringProperty.value = "test";
|
|
1444
|
+
expect(node1.resolvePath("node.node1.stringProperty").value).to.equal("test");
|
|
1445
|
+
expect(node3.resolvePath("node1.stringProperty").value).to.equal("test");
|
|
1435
1446
|
done();
|
|
1436
1447
|
});
|
|
1437
|
-
it(
|
|
1438
|
-
var node1 = PropertyFactory.create(
|
|
1439
|
-
var node2 = PropertyFactory.create(
|
|
1440
|
-
var node3 = PropertyFactory.create(
|
|
1441
|
-
node1.insert(
|
|
1448
|
+
it("should be possible for the id passed to be a number", function (done) {
|
|
1449
|
+
var node1 = PropertyFactory.create("NodeProperty");
|
|
1450
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNamedNodeProperty-1.0.0");
|
|
1451
|
+
var node3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
1452
|
+
node1.insert("node", node3);
|
|
1442
1453
|
node3.insert(1122, node2);
|
|
1443
|
-
node2._properties.stringProperty.value =
|
|
1444
|
-
expect(node1.resolvePath(
|
|
1445
|
-
expect(node3.resolvePath(
|
|
1454
|
+
node2._properties.stringProperty.value = "test";
|
|
1455
|
+
expect(node1.resolvePath("node.1122.stringProperty").value).to.equal("test");
|
|
1456
|
+
expect(node3.resolvePath("1122.stringProperty").value).to.equal("test");
|
|
1446
1457
|
done();
|
|
1447
1458
|
});
|
|
1448
|
-
it(
|
|
1449
|
-
var node1 = PropertyFactory.create(
|
|
1450
|
-
var node2 = PropertyFactory.create(
|
|
1451
|
-
var node3 = PropertyFactory.create(
|
|
1452
|
-
node1.insert(
|
|
1459
|
+
it("should throw an error when the id passed is an object", function (done) {
|
|
1460
|
+
var node1 = PropertyFactory.create("NodeProperty");
|
|
1461
|
+
var node2 = PropertyFactory.create("autodesk.tests:MixedNamedNodeProperty-1.0.0");
|
|
1462
|
+
var node3 = PropertyFactory.create("autodesk.tests:MixedNodeTestProperty-1.0.0");
|
|
1463
|
+
node1.insert("node", node3);
|
|
1453
1464
|
try {
|
|
1454
|
-
node3.insert({ foo:
|
|
1455
|
-
node2._properties.stringProperty.value =
|
|
1465
|
+
node3.insert({ foo: "bar" }, node2);
|
|
1466
|
+
node2._properties.stringProperty.value = "test";
|
|
1456
1467
|
}
|
|
1457
1468
|
catch (e) {
|
|
1458
1469
|
done();
|
|
1459
1470
|
}
|
|
1460
1471
|
});
|
|
1461
1472
|
});
|
|
1462
|
-
describe(
|
|
1473
|
+
describe("_coveredByPaths", function () {
|
|
1463
1474
|
this.timeout(500);
|
|
1464
1475
|
let PathHelper, getPathCoverageSpy, paths, prop, propPath;
|
|
1465
1476
|
before(function () {
|
|
1466
|
-
PathHelper = require(
|
|
1477
|
+
PathHelper = require("@fluid-experimental/property-changeset").PathHelper;
|
|
1467
1478
|
});
|
|
1468
1479
|
beforeEach(function () {
|
|
1469
|
-
getPathCoverageSpy = sinon.spy(PathHelper,
|
|
1480
|
+
getPathCoverageSpy = sinon.spy(PathHelper, "getPathCoverage");
|
|
1470
1481
|
});
|
|
1471
1482
|
afterEach(function () {
|
|
1472
1483
|
PathHelper.getPathCoverage.restore();
|
|
1473
1484
|
});
|
|
1474
|
-
after(function () {
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
propPath = 'a.b';
|
|
1485
|
+
after(function () { });
|
|
1486
|
+
it("should succeed if property is included in a path 1", function () {
|
|
1487
|
+
paths = ["a.b"];
|
|
1488
|
+
prop = PropertyFactory.create("String");
|
|
1489
|
+
propPath = "a.b";
|
|
1480
1490
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1481
1491
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1482
1492
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1483
1493
|
});
|
|
1484
|
-
it(
|
|
1485
|
-
paths = [
|
|
1486
|
-
prop = PropertyFactory.create(
|
|
1487
|
-
propPath =
|
|
1494
|
+
it("should succeed if property is included in a path 2", function () {
|
|
1495
|
+
paths = ["a.b"];
|
|
1496
|
+
prop = PropertyFactory.create("Int32");
|
|
1497
|
+
propPath = "a.b.c";
|
|
1488
1498
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1489
1499
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1490
1500
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1491
1501
|
});
|
|
1492
|
-
it(
|
|
1493
|
-
paths = [
|
|
1494
|
-
prop = PropertyFactory.create(
|
|
1495
|
-
propPath =
|
|
1502
|
+
it("should succeed if property is a primitive collection included in a path", function () {
|
|
1503
|
+
paths = ["a.b"];
|
|
1504
|
+
prop = PropertyFactory.create("Int32", "array");
|
|
1505
|
+
propPath = "a.b.c.d";
|
|
1496
1506
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1497
1507
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1498
1508
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1499
1509
|
});
|
|
1500
|
-
it(
|
|
1501
|
-
paths = [
|
|
1502
|
-
prop = PropertyFactory.create(
|
|
1503
|
-
propPath =
|
|
1510
|
+
it("should fail if property is not included in any path 1", function () {
|
|
1511
|
+
paths = ["a.b"];
|
|
1512
|
+
prop = PropertyFactory.create("Bool");
|
|
1513
|
+
propPath = "b";
|
|
1504
1514
|
expect(prop._coveredByPaths(propPath, paths)).to.be.false;
|
|
1505
1515
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1506
1516
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1507
1517
|
});
|
|
1508
|
-
it(
|
|
1509
|
-
paths = [
|
|
1510
|
-
prop = PropertyFactory.create(
|
|
1511
|
-
propPath =
|
|
1518
|
+
it("should fail if property is not included in any path 2", function () {
|
|
1519
|
+
paths = ["a.b"];
|
|
1520
|
+
prop = PropertyFactory.create("Float32");
|
|
1521
|
+
propPath = "b.f.g";
|
|
1512
1522
|
expect(prop._coveredByPaths(propPath, paths)).to.be.false;
|
|
1513
1523
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1514
1524
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1515
1525
|
});
|
|
1516
|
-
it(
|
|
1517
|
-
paths = [
|
|
1518
|
-
prop = PropertyFactory.create(
|
|
1519
|
-
propPath =
|
|
1526
|
+
it("should fail if property is not included in any path but have common root 1", function () {
|
|
1527
|
+
paths = ["a.b"];
|
|
1528
|
+
prop = PropertyFactory.create("String", "map");
|
|
1529
|
+
propPath = "a.h";
|
|
1520
1530
|
expect(prop._coveredByPaths(propPath, paths)).to.be.false;
|
|
1521
1531
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1522
1532
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1523
1533
|
});
|
|
1524
|
-
it(
|
|
1525
|
-
paths = [
|
|
1526
|
-
prop = PropertyFactory.create(
|
|
1527
|
-
propPath =
|
|
1534
|
+
it("should fail if property is not included in any path but have common root 2", function () {
|
|
1535
|
+
paths = ["a.b"];
|
|
1536
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1537
|
+
propPath = "a.i.j";
|
|
1528
1538
|
expect(prop._coveredByPaths(propPath, paths)).to.be.false;
|
|
1529
1539
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1530
1540
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1531
1541
|
});
|
|
1532
|
-
it(
|
|
1533
|
-
paths = [
|
|
1534
|
-
prop = PropertyFactory.create(
|
|
1535
|
-
propPath =
|
|
1542
|
+
it("should succeed if path goes through a primitive property 1", function () {
|
|
1543
|
+
paths = ["a.b.c", "a.b.d", "z"];
|
|
1544
|
+
prop = PropertyFactory.create("String");
|
|
1545
|
+
propPath = "a.b";
|
|
1536
1546
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1537
1547
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1538
1548
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1539
1549
|
});
|
|
1540
|
-
it(
|
|
1541
|
-
paths = [
|
|
1542
|
-
prop = PropertyFactory.create(
|
|
1543
|
-
propPath =
|
|
1550
|
+
it("should succeed if path goes through a primitive property 2", function () {
|
|
1551
|
+
paths = ["a.b.c", "a.b.d", "z"];
|
|
1552
|
+
prop = PropertyFactory.create("Int32");
|
|
1553
|
+
propPath = "a.b";
|
|
1544
1554
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1545
1555
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1546
1556
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1547
1557
|
});
|
|
1548
|
-
it(
|
|
1549
|
-
paths = [
|
|
1550
|
-
prop = PropertyFactory.create(
|
|
1551
|
-
propPath =
|
|
1558
|
+
it("should succeed if path goes through a primitive collection property 1", function () {
|
|
1559
|
+
paths = ["a.b.c", "z", "a.b.d"];
|
|
1560
|
+
prop = PropertyFactory.create("Int32", "map");
|
|
1561
|
+
propPath = "a.b";
|
|
1552
1562
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1553
1563
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1554
1564
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1555
1565
|
});
|
|
1556
|
-
it(
|
|
1557
|
-
paths = [
|
|
1558
|
-
prop = PropertyFactory.create(
|
|
1559
|
-
propPath =
|
|
1566
|
+
it("should succeed if path goes through a primitive collection property 2", function () {
|
|
1567
|
+
paths = ["z", "a.b.c", "a.b.d"];
|
|
1568
|
+
prop = PropertyFactory.create("String", "array");
|
|
1569
|
+
propPath = "a.b";
|
|
1560
1570
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1561
1571
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1562
1572
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1563
1573
|
});
|
|
1564
|
-
it(
|
|
1565
|
-
paths = [
|
|
1566
|
-
prop = PropertyFactory.create(
|
|
1567
|
-
propPath =
|
|
1574
|
+
it("should succeed if path goes through a non-primitive collection property 1", function () {
|
|
1575
|
+
paths = ["a.b.c", "z", "a.b.d"];
|
|
1576
|
+
prop = PropertyFactory.create("NodeProperty", "map");
|
|
1577
|
+
propPath = "a.b";
|
|
1568
1578
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1569
1579
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1570
1580
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1571
1581
|
});
|
|
1572
|
-
it(
|
|
1573
|
-
paths = [
|
|
1574
|
-
prop = PropertyFactory.create(
|
|
1575
|
-
propPath =
|
|
1582
|
+
it("should succeed if path goes through a non-primitive collection property 2", function () {
|
|
1583
|
+
paths = ["z", "a.b.c", "a.b.d"];
|
|
1584
|
+
prop = PropertyFactory.create("NamedProperty", "set");
|
|
1585
|
+
propPath = "a.b";
|
|
1576
1586
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1577
1587
|
expect(getPathCoverageSpy.callCount).to.equal(1);
|
|
1578
1588
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1579
1589
|
});
|
|
1580
|
-
it(
|
|
1581
|
-
paths = [
|
|
1582
|
-
prop = PropertyFactory.create(
|
|
1583
|
-
prop.insert(
|
|
1584
|
-
prop.insert(
|
|
1585
|
-
propPath =
|
|
1590
|
+
it("should succeed if property is included in multiple paths 1", function () {
|
|
1591
|
+
paths = ["a.b.c", "a.b.d", "z"];
|
|
1592
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1593
|
+
prop.insert("c", PropertyFactory.create("String"));
|
|
1594
|
+
prop.insert("d", PropertyFactory.create("String"));
|
|
1595
|
+
propPath = "a.b";
|
|
1586
1596
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1587
1597
|
expect(getPathCoverageSpy.callCount).to.equal(3);
|
|
1588
1598
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1589
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1590
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1591
|
-
});
|
|
1592
|
-
it(
|
|
1593
|
-
paths = [
|
|
1594
|
-
prop = PropertyFactory.create(
|
|
1595
|
-
let c = PropertyFactory.create(
|
|
1596
|
-
prop.insert(
|
|
1597
|
-
c.insert(
|
|
1598
|
-
c.insert(
|
|
1599
|
-
let d = PropertyFactory.create(
|
|
1600
|
-
prop.insert(
|
|
1601
|
-
d.insert(
|
|
1602
|
-
d.insert(
|
|
1603
|
-
propPath =
|
|
1599
|
+
expect(getPathCoverageSpy.calledWith("a.b.c", ["a.b.c", "a.b.d"])).to.be.true;
|
|
1600
|
+
expect(getPathCoverageSpy.calledWith("a.b.d", ["a.b.c", "a.b.d"])).to.be.true;
|
|
1601
|
+
});
|
|
1602
|
+
it("should succeed if property is included in multiple paths 2", function () {
|
|
1603
|
+
paths = ["a.b.c", "z", "a.b.d"];
|
|
1604
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1605
|
+
let c = PropertyFactory.create("NodeProperty");
|
|
1606
|
+
prop.insert("c", c);
|
|
1607
|
+
c.insert("f", PropertyFactory.create("String"));
|
|
1608
|
+
c.insert("g", PropertyFactory.create("String"));
|
|
1609
|
+
let d = PropertyFactory.create("String", "map");
|
|
1610
|
+
prop.insert("d", d);
|
|
1611
|
+
d.insert("h", "h");
|
|
1612
|
+
d.insert("i", "i");
|
|
1613
|
+
propPath = "a.b";
|
|
1604
1614
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1605
1615
|
expect(getPathCoverageSpy.callCount).to.equal(3);
|
|
1606
1616
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1607
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1608
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1609
|
-
});
|
|
1610
|
-
it(
|
|
1611
|
-
paths = [
|
|
1612
|
-
prop = PropertyFactory.create(
|
|
1613
|
-
let c = PropertyFactory.create(
|
|
1614
|
-
prop.insert(
|
|
1615
|
-
c.insert(
|
|
1616
|
-
c.insert(
|
|
1617
|
-
let d = PropertyFactory.create(
|
|
1618
|
-
prop.insert(
|
|
1619
|
-
d.insert(
|
|
1620
|
-
d.insert(
|
|
1621
|
-
propPath =
|
|
1617
|
+
expect(getPathCoverageSpy.calledWith("a.b.c", ["a.b.c", "a.b.d"])).to.be.true;
|
|
1618
|
+
expect(getPathCoverageSpy.calledWith("a.b.d", ["a.b.c", "a.b.d"])).to.be.true;
|
|
1619
|
+
});
|
|
1620
|
+
it("should succeed if property is included in multiple paths 3", function () {
|
|
1621
|
+
paths = ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i", "a.z"];
|
|
1622
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1623
|
+
let c = PropertyFactory.create("NodeProperty");
|
|
1624
|
+
prop.insert("c", c);
|
|
1625
|
+
c.insert("f", PropertyFactory.create("String"));
|
|
1626
|
+
c.insert("g", PropertyFactory.create("String"));
|
|
1627
|
+
let d = PropertyFactory.create("NodeProperty");
|
|
1628
|
+
prop.insert("d", d);
|
|
1629
|
+
d.insert("h", PropertyFactory.create("String"));
|
|
1630
|
+
d.insert("i", PropertyFactory.create("String"));
|
|
1631
|
+
propPath = "a.b";
|
|
1622
1632
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1623
1633
|
expect(getPathCoverageSpy.callCount).to.equal(5);
|
|
1624
1634
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1625
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1626
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1627
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1628
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1629
|
-
});
|
|
1630
|
-
it(
|
|
1631
|
-
paths = [
|
|
1632
|
-
prop = PropertyFactory.create(
|
|
1633
|
-
let b = PropertyFactory.create(
|
|
1634
|
-
prop.insert(
|
|
1635
|
-
let c = PropertyFactory.create(
|
|
1636
|
-
b.insert(
|
|
1637
|
-
c.insert(
|
|
1638
|
-
c.insert(
|
|
1639
|
-
let d = PropertyFactory.create(
|
|
1640
|
-
b.insert(
|
|
1641
|
-
d.insert(
|
|
1642
|
-
d.insert(
|
|
1643
|
-
propPath =
|
|
1635
|
+
expect(getPathCoverageSpy.calledWith("a.b.c", ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1636
|
+
expect(getPathCoverageSpy.calledWith("a.b.d", ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1637
|
+
expect(getPathCoverageSpy.calledWith("a.b.d.h", ["a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1638
|
+
expect(getPathCoverageSpy.calledWith("a.b.d.i", ["a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1639
|
+
});
|
|
1640
|
+
it("should succeed if property is included in multiple paths 4", function () {
|
|
1641
|
+
paths = ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i", "a.z"];
|
|
1642
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1643
|
+
let b = PropertyFactory.create("NodeProperty");
|
|
1644
|
+
prop.insert("b", b);
|
|
1645
|
+
let c = PropertyFactory.create("NodeProperty");
|
|
1646
|
+
b.insert("c", c);
|
|
1647
|
+
c.insert("f", PropertyFactory.create("String"));
|
|
1648
|
+
c.insert("g", PropertyFactory.create("String"));
|
|
1649
|
+
let d = PropertyFactory.create("NodeProperty");
|
|
1650
|
+
b.insert("d", d);
|
|
1651
|
+
d.insert("h", PropertyFactory.create("String"));
|
|
1652
|
+
d.insert("i", PropertyFactory.create("String"));
|
|
1653
|
+
propPath = "a";
|
|
1644
1654
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1645
1655
|
expect(getPathCoverageSpy.callCount).to.equal(6);
|
|
1646
1656
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1647
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1648
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1649
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1650
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1651
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1652
|
-
});
|
|
1653
|
-
it(
|
|
1654
|
-
paths = [
|
|
1655
|
-
prop = PropertyFactory.create(
|
|
1656
|
-
prop.insert(
|
|
1657
|
-
prop.insert(
|
|
1658
|
-
propPath =
|
|
1657
|
+
expect(getPathCoverageSpy.calledWith("a.b", paths)).to.be.true;
|
|
1658
|
+
expect(getPathCoverageSpy.calledWith("a.b.c", ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1659
|
+
expect(getPathCoverageSpy.calledWith("a.b.d", ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1660
|
+
expect(getPathCoverageSpy.calledWith("a.b.d.h", ["a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1661
|
+
expect(getPathCoverageSpy.calledWith("a.b.d.i", ["a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1662
|
+
});
|
|
1663
|
+
it("should succeed if property is included in multiple paths through map 1", function () {
|
|
1664
|
+
paths = ["a.b.c", "a.b.d.z", "z"];
|
|
1665
|
+
prop = PropertyFactory.create("String", "map");
|
|
1666
|
+
prop.insert("c", "c");
|
|
1667
|
+
prop.insert("d", "d");
|
|
1668
|
+
propPath = "a.b";
|
|
1659
1669
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1660
1670
|
expect(getPathCoverageSpy.callCount).to.equal(3);
|
|
1661
1671
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1662
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1663
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1664
|
-
});
|
|
1665
|
-
it(
|
|
1666
|
-
paths = [
|
|
1667
|
-
prop = PropertyFactory.create(
|
|
1668
|
-
let c = PropertyFactory.create(
|
|
1669
|
-
let d = PropertyFactory.create(
|
|
1670
|
-
prop.insert(
|
|
1671
|
-
c.insert(
|
|
1672
|
-
c.insert(
|
|
1673
|
-
prop.insert(
|
|
1674
|
-
d.insert(
|
|
1675
|
-
d.insert(
|
|
1676
|
-
propPath =
|
|
1672
|
+
expect(getPathCoverageSpy.calledWith("a.b.c", ["a.b.c", "a.b.d.z"])).to.be.true;
|
|
1673
|
+
expect(getPathCoverageSpy.calledWith("a.b.d", ["a.b.c", "a.b.d.z"])).to.be.true;
|
|
1674
|
+
});
|
|
1675
|
+
it("should succeed if property is included in multiple paths through map 2", function () {
|
|
1676
|
+
paths = ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i", "a.z"];
|
|
1677
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1678
|
+
let c = PropertyFactory.create("NodeProperty");
|
|
1679
|
+
let d = PropertyFactory.create("String", "map");
|
|
1680
|
+
prop.insert("c", c);
|
|
1681
|
+
c.insert("f", PropertyFactory.create("String"));
|
|
1682
|
+
c.insert("g", PropertyFactory.create("String"));
|
|
1683
|
+
prop.insert("d", d);
|
|
1684
|
+
d.insert("h", "h");
|
|
1685
|
+
d.insert("i", "i");
|
|
1686
|
+
propPath = "a.b";
|
|
1677
1687
|
expect(prop._coveredByPaths(propPath, paths)).to.be.true;
|
|
1678
1688
|
expect(getPathCoverageSpy.callCount).to.equal(5);
|
|
1679
1689
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1680
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1681
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1682
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1683
|
-
expect(getPathCoverageSpy.calledWith(
|
|
1684
|
-
});
|
|
1685
|
-
it(
|
|
1686
|
-
paths = [
|
|
1687
|
-
prop = PropertyFactory.create(
|
|
1688
|
-
prop.insert(
|
|
1689
|
-
prop.insert(
|
|
1690
|
-
propPath =
|
|
1690
|
+
expect(getPathCoverageSpy.calledWith("a.b.c", ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1691
|
+
expect(getPathCoverageSpy.calledWith("a.b.d", ["a.b.c.f", "a.b.c", "a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1692
|
+
expect(getPathCoverageSpy.calledWith("a.b.d.h", ["a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1693
|
+
expect(getPathCoverageSpy.calledWith("a.b.d.i", ["a.b.d.h", "a.b.d.i"])).to.be.true;
|
|
1694
|
+
});
|
|
1695
|
+
it("should fail if property is not completely included in multiple paths 1", function () {
|
|
1696
|
+
paths = ["a.b.c", "a.b.d", "z"];
|
|
1697
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1698
|
+
prop.insert("c", PropertyFactory.create("String"));
|
|
1699
|
+
prop.insert("e", PropertyFactory.create("String"));
|
|
1700
|
+
propPath = "a.b";
|
|
1691
1701
|
expect(prop._coveredByPaths(propPath, paths)).to.be.false;
|
|
1692
1702
|
expect(getPathCoverageSpy.callCount).to.be.above(1);
|
|
1693
1703
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|
|
1694
1704
|
});
|
|
1695
|
-
it(
|
|
1696
|
-
paths = [
|
|
1697
|
-
prop = PropertyFactory.create(
|
|
1698
|
-
prop.insert(
|
|
1699
|
-
prop.insert(
|
|
1700
|
-
propPath =
|
|
1705
|
+
it("should fail if property is not completely included in multiple paths 2", function () {
|
|
1706
|
+
paths = ["z", "a.b.d", "a.b.c"];
|
|
1707
|
+
prop = PropertyFactory.create("NodeProperty");
|
|
1708
|
+
prop.insert("e", PropertyFactory.create("String"));
|
|
1709
|
+
prop.insert("c", PropertyFactory.create("String"));
|
|
1710
|
+
propPath = "a.b";
|
|
1701
1711
|
expect(prop._coveredByPaths(propPath, paths)).to.be.false;
|
|
1702
1712
|
expect(getPathCoverageSpy.callCount).to.be.above(1);
|
|
1703
1713
|
expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true;
|