@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
|
@@ -5,68 +5,66 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @fileoverview In this file, we will test the map property object described in /src/properties/mapProperty.js
|
|
7
7
|
*/
|
|
8
|
-
describe(
|
|
8
|
+
describe("MapProperty", function () {
|
|
9
9
|
var PropertyFactory, BaseProperty, ChangeSet, generateGuid, PATH_TOKENS;
|
|
10
10
|
var changeSetWithTwoMapEntries, _, changeSetWithTwoMapEntries_full, removalChangeSet;
|
|
11
11
|
var myNode, mapNode1, mapNode2, map;
|
|
12
12
|
before(function () {
|
|
13
13
|
// Get all the objects we need in this test here.
|
|
14
|
-
PropertyFactory = require(
|
|
15
|
-
BaseProperty = require(
|
|
16
|
-
ChangeSet = require(
|
|
17
|
-
_ = require(
|
|
18
|
-
generateGuid = require(
|
|
19
|
-
PATH_TOKENS = require(
|
|
14
|
+
PropertyFactory = require("../..").PropertyFactory;
|
|
15
|
+
BaseProperty = require("../..").BaseProperty;
|
|
16
|
+
ChangeSet = require("@fluid-experimental/property-changeset").ChangeSet;
|
|
17
|
+
_ = require("lodash");
|
|
18
|
+
generateGuid = require("@fluid-experimental/property-common").GuidUtils.generateGUID;
|
|
19
|
+
PATH_TOKENS = require("../..").BaseProperty.PATH_TOKENS;
|
|
20
20
|
// Register a template with a set property for the tests
|
|
21
21
|
var TestPropertyTemplate = {
|
|
22
|
-
typeid:
|
|
23
|
-
inherits: [
|
|
22
|
+
typeid: "autodesk.tests:MapTestPropertyID-1.0.0",
|
|
23
|
+
inherits: ["NamedProperty"],
|
|
24
24
|
properties: [
|
|
25
|
-
{ id:
|
|
26
|
-
{ id:
|
|
27
|
-
{ id:
|
|
25
|
+
{ id: "stringProperty", typeid: "String" },
|
|
26
|
+
{ id: "stringProperty2", typeid: "String" },
|
|
27
|
+
{ id: "map", context: "map", typeid: "NamedProperty" },
|
|
28
28
|
],
|
|
29
29
|
};
|
|
30
30
|
var AnonymousTestPropertyTemplate = {
|
|
31
|
-
typeid:
|
|
32
|
-
properties: [
|
|
33
|
-
{ id: 'stringProperty', typeid: 'String' },
|
|
34
|
-
],
|
|
31
|
+
typeid: "autodesk.tests:AnonymousMapTestPropertyID-1.0.0",
|
|
32
|
+
properties: [{ id: "stringProperty", typeid: "String" }],
|
|
35
33
|
};
|
|
36
34
|
var PrimitiveMapPropertyTemplate = {
|
|
37
|
-
typeid:
|
|
38
|
-
properties: [
|
|
39
|
-
{ id: 'map', context: 'map', typeid: 'Int32' },
|
|
40
|
-
],
|
|
35
|
+
typeid: "autodesk.tests:PrimitiveMap-1.0.0",
|
|
36
|
+
properties: [{ id: "map", context: "map", typeid: "Int32" }],
|
|
41
37
|
};
|
|
42
38
|
var NonPrimitiveMapPropertyTemplate = {
|
|
43
|
-
typeid:
|
|
39
|
+
typeid: "autodesk.tests:NonPrimitiveMap-1.0.0",
|
|
44
40
|
properties: [
|
|
45
|
-
{ typeid:
|
|
41
|
+
{ typeid: "autodesk.tests:StringProperty-1.0.0", id: "map", context: "map" },
|
|
46
42
|
],
|
|
47
43
|
};
|
|
48
44
|
var StringPropertyTemplate = {
|
|
49
|
-
typeid:
|
|
50
|
-
properties: [
|
|
51
|
-
{ id: 'stringValue', typeid: 'String' },
|
|
52
|
-
],
|
|
45
|
+
typeid: "autodesk.tests:StringProperty-1.0.0",
|
|
46
|
+
properties: [{ id: "stringValue", typeid: "String" }],
|
|
53
47
|
};
|
|
54
48
|
var ComplexProperty = {
|
|
55
|
-
typeid:
|
|
49
|
+
typeid: "autodesk.tests:ComplexProperty-1.0.0",
|
|
56
50
|
properties: [
|
|
57
51
|
{
|
|
58
|
-
id:
|
|
59
|
-
|
|
60
|
-
],
|
|
52
|
+
id: "nested",
|
|
53
|
+
properties: [{ id: "data", typeid: "Int32" }],
|
|
61
54
|
},
|
|
62
55
|
],
|
|
63
56
|
};
|
|
64
57
|
var ComplexMap = {
|
|
65
|
-
typeid:
|
|
58
|
+
typeid: "autodesk.tests:ComplexMap-1.0.0",
|
|
66
59
|
properties: [
|
|
67
60
|
{
|
|
68
|
-
id:
|
|
69
|
-
|
|
61
|
+
id: "path",
|
|
62
|
+
properties: [
|
|
63
|
+
{
|
|
64
|
+
id: "map",
|
|
65
|
+
typeid: "autodesk.tests:ComplexProperty-1.0.0",
|
|
66
|
+
context: "map",
|
|
67
|
+
},
|
|
70
68
|
],
|
|
71
69
|
},
|
|
72
70
|
],
|
|
@@ -78,9 +76,9 @@ describe('MapProperty', function () {
|
|
|
78
76
|
PropertyFactory._reregister(StringPropertyTemplate);
|
|
79
77
|
PropertyFactory._reregister(ComplexMap);
|
|
80
78
|
PropertyFactory._reregister(ComplexProperty);
|
|
81
|
-
myNode = PropertyFactory.create(
|
|
82
|
-
mapNode1 = PropertyFactory.create(
|
|
83
|
-
mapNode2 = PropertyFactory.create(
|
|
79
|
+
myNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
80
|
+
mapNode1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
81
|
+
mapNode2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
84
82
|
map = myNode._properties.map;
|
|
85
83
|
});
|
|
86
84
|
// Helper functions for the test cases
|
|
@@ -90,9 +88,9 @@ describe('MapProperty', function () {
|
|
|
90
88
|
};
|
|
91
89
|
// Inserts a node with the given guid (a new one is generated when undefined)
|
|
92
90
|
var insertNodeInRootWithKeyAndGuid = function (key, guid, root) {
|
|
93
|
-
var node = PropertyFactory.create(
|
|
91
|
+
var node = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
94
92
|
if (key === undefined) {
|
|
95
|
-
key =
|
|
93
|
+
key = "node" + keyCounter++;
|
|
96
94
|
}
|
|
97
95
|
if (guid !== undefined) {
|
|
98
96
|
node._properties.guid.value = guid;
|
|
@@ -105,7 +103,7 @@ describe('MapProperty', function () {
|
|
|
105
103
|
};
|
|
106
104
|
// Returns a function that will insert a node with a constant GUID
|
|
107
105
|
var insertUniqueNodeInRoot = function () {
|
|
108
|
-
var key =
|
|
106
|
+
var key = "node" + keyCounter++;
|
|
109
107
|
return insertNodeInRootWithKeyAndGuid.bind(undefined, key, generateGuid());
|
|
110
108
|
};
|
|
111
109
|
// Inserts a new node as leaf
|
|
@@ -114,8 +112,8 @@ describe('MapProperty', function () {
|
|
|
114
112
|
while (leaf._properties.map.getAsArray().length > 0) {
|
|
115
113
|
leaf = leaf._properties.map.getAsArray()[0];
|
|
116
114
|
}
|
|
117
|
-
var node = PropertyFactory.create(
|
|
118
|
-
var key =
|
|
115
|
+
var node = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
116
|
+
var key = "node" + keyCounter++;
|
|
119
117
|
leaf._properties.map.insert(key, node);
|
|
120
118
|
};
|
|
121
119
|
// Removes the first node from the root
|
|
@@ -129,564 +127,581 @@ describe('MapProperty', function () {
|
|
|
129
127
|
while (leaf._properties.map.getAsArray().length > 0) {
|
|
130
128
|
leaf = leaf._properties.map.getAsArray()[0];
|
|
131
129
|
}
|
|
132
|
-
leaf._properties.stringProperty.value = leaf._properties.stringProperty.value +
|
|
130
|
+
leaf._properties.stringProperty.value = leaf._properties.stringProperty.value + "+";
|
|
133
131
|
};
|
|
134
|
-
describe(
|
|
132
|
+
describe("API methods", function () {
|
|
135
133
|
var myMap, stringProp1, stringProp2;
|
|
136
134
|
before(function () {
|
|
137
|
-
myMap = PropertyFactory.create(
|
|
138
|
-
stringProp1 = PropertyFactory.create(
|
|
139
|
-
stringProp2 = PropertyFactory.create(
|
|
140
|
-
});
|
|
141
|
-
it(
|
|
142
|
-
myMap.insert(
|
|
143
|
-
myMap.insert(
|
|
144
|
-
expect(myMap.getEntriesReadOnly()).to.deep.equal({
|
|
135
|
+
myMap = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0")._properties.map;
|
|
136
|
+
stringProp1 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0");
|
|
137
|
+
stringProp2 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0");
|
|
138
|
+
});
|
|
139
|
+
it(".clear should work", function () {
|
|
140
|
+
myMap.insert("one", stringProp1);
|
|
141
|
+
myMap.insert("two", stringProp2);
|
|
142
|
+
expect(myMap.getEntriesReadOnly()).to.deep.equal({
|
|
143
|
+
one: stringProp1,
|
|
144
|
+
two: stringProp2,
|
|
145
|
+
});
|
|
145
146
|
myMap.clear();
|
|
146
147
|
expect(myMap.getEntriesReadOnly()).to.be.empty;
|
|
147
148
|
});
|
|
148
|
-
it(
|
|
149
|
-
myMap.insert(
|
|
150
|
-
myMap.insert(
|
|
149
|
+
it(".getAsArray should return an array of map values", function () {
|
|
150
|
+
myMap.insert("one", stringProp1);
|
|
151
|
+
myMap.insert("two", stringProp2);
|
|
151
152
|
expect(myMap.getAsArray()).to.deep.equal([stringProp1, stringProp2]);
|
|
152
153
|
});
|
|
153
|
-
it(
|
|
154
|
-
expect(myMap.getFullTypeid()).to.equal(
|
|
154
|
+
it(".getFullTypeid should return a string of the typeid with or without collection", function () {
|
|
155
|
+
expect(myMap.getFullTypeid()).to.equal("map<autodesk.tests:StringProperty-1.0.0>");
|
|
155
156
|
// hideCollection: true
|
|
156
|
-
expect(myMap.getFullTypeid(true)).to.equal(
|
|
157
|
+
expect(myMap.getFullTypeid(true)).to.equal("autodesk.tests:StringProperty-1.0.0");
|
|
157
158
|
});
|
|
158
|
-
it(
|
|
159
|
-
expect(myMap.getTypeid()).to.equal(
|
|
159
|
+
it(".getTypeid should return a string of the typeid", function () {
|
|
160
|
+
expect(myMap.getTypeid()).to.equal("autodesk.tests:StringProperty-1.0.0");
|
|
160
161
|
});
|
|
161
|
-
it(
|
|
162
|
-
myMap.insert(
|
|
163
|
-
myMap.insert(
|
|
164
|
-
expect(myMap.getIds()).to.deep.equal([
|
|
162
|
+
it(".getIds should return an array of map keys", function () {
|
|
163
|
+
myMap.insert("one", stringProp1);
|
|
164
|
+
myMap.insert("two", stringProp2);
|
|
165
|
+
expect(myMap.getIds()).to.deep.equal(["one", "two"]);
|
|
165
166
|
});
|
|
166
|
-
it(
|
|
167
|
-
myMap.insert(
|
|
168
|
-
myMap.insert(
|
|
169
|
-
myMap.remove(
|
|
170
|
-
expect(myMap.getEntriesReadOnly()).to.deep.equal({
|
|
171
|
-
expect(myMap.remove(
|
|
167
|
+
it(".remove should remove an item from a map and return the removed item", function () {
|
|
168
|
+
myMap.insert("one", stringProp1);
|
|
169
|
+
myMap.insert("two", stringProp2);
|
|
170
|
+
myMap.remove("one");
|
|
171
|
+
expect(myMap.getEntriesReadOnly()).to.deep.equal({ two: stringProp2 });
|
|
172
|
+
expect(myMap.remove("two")).to.equal(stringProp2);
|
|
172
173
|
});
|
|
173
|
-
it(
|
|
174
|
-
expect(myMap.getContext()).to.equal(
|
|
174
|
+
it(".getContext should return map", function () {
|
|
175
|
+
expect(myMap.getContext()).to.equal("map");
|
|
175
176
|
});
|
|
176
|
-
it(
|
|
177
|
-
expect(myMap.getId()).to.equal(
|
|
177
|
+
it("getId should return the id", function () {
|
|
178
|
+
expect(myMap.getId()).to.equal("map");
|
|
178
179
|
});
|
|
179
180
|
afterEach(function () {
|
|
180
181
|
myMap.clear();
|
|
181
182
|
});
|
|
182
183
|
});
|
|
183
|
-
describe(
|
|
184
|
+
describe("get and resolvePath", function () {
|
|
184
185
|
var complexMap, complexProperty1, complexProperty2;
|
|
185
186
|
before(function () {
|
|
186
|
-
complexMap = PropertyFactory.create(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
complexMap.insert(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
expect(complexMap.
|
|
197
|
-
expect(complexMap.get(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
expect(complexMap.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
expect(complexMap.get(PATH_TOKENS.
|
|
209
|
-
|
|
210
|
-
|
|
187
|
+
complexMap = PropertyFactory.create("autodesk.tests:ComplexMap-1.0.0")._properties.path
|
|
188
|
+
.map;
|
|
189
|
+
complexProperty1 = PropertyFactory.create("autodesk.tests:ComplexProperty-1.0.0");
|
|
190
|
+
complexProperty2 = PropertyFactory.create("autodesk.tests:ComplexProperty-1.0.0");
|
|
191
|
+
complexProperty1.get("nested").get("data").setValue(123);
|
|
192
|
+
complexProperty2.get("nested").get("data").setValue(456);
|
|
193
|
+
complexMap.insert("one", complexProperty1);
|
|
194
|
+
complexMap.insert("two", complexProperty2);
|
|
195
|
+
});
|
|
196
|
+
it("should resolve a simple path", function () {
|
|
197
|
+
expect(complexMap.resolvePath("one.nested.data").getValue()).to.equal(123);
|
|
198
|
+
expect(complexMap.get("one").get("nested").get("data").getValue()).to.equal(123);
|
|
199
|
+
expect(complexMap.get(["one", "nested", "data"]).getValue()).to.equal(123);
|
|
200
|
+
});
|
|
201
|
+
it("should work with raise path tokens", function () {
|
|
202
|
+
expect(complexMap.resolvePath("../../path.map.one")).to.deep.equal(complexProperty1);
|
|
203
|
+
expect(complexMap
|
|
204
|
+
.get(PATH_TOKENS.UP)
|
|
205
|
+
.get(PATH_TOKENS.UP)
|
|
206
|
+
.get("path")
|
|
207
|
+
.get("map")
|
|
208
|
+
.get("two")).to.deep.equal(complexProperty2);
|
|
209
|
+
expect(complexMap.get([PATH_TOKENS.UP, "map", "two", PATH_TOKENS.UP, "two"])).to.deep.equal(complexProperty2);
|
|
210
|
+
});
|
|
211
|
+
it("should work with root tokens", function () {
|
|
212
|
+
expect(complexMap.resolvePath("/path.map.two")).to.deep.equal(complexProperty2);
|
|
213
|
+
expect(complexMap
|
|
214
|
+
.get(PATH_TOKENS.ROOT)
|
|
215
|
+
.get("path")
|
|
216
|
+
.get("map")
|
|
217
|
+
.get("two")
|
|
218
|
+
.get("nested")
|
|
219
|
+
.get("data")
|
|
220
|
+
.getValue()).to.equal(456);
|
|
221
|
+
expect(complexMap.get([PATH_TOKENS.ROOT, "path", "map", "one"])).to.deep.equal(complexProperty1);
|
|
211
222
|
});
|
|
212
223
|
});
|
|
213
|
-
describe(
|
|
214
|
-
it(
|
|
224
|
+
describe("Testing creation, assignment and serialization", function () {
|
|
225
|
+
it("should be empty at the beginning", function () {
|
|
215
226
|
expect(map.getEntriesReadOnly()).to.be.empty;
|
|
216
|
-
expect(map.serialize({
|
|
227
|
+
expect(map.serialize({ dirtyOnly: true })).to.be.empty;
|
|
217
228
|
});
|
|
218
|
-
it(
|
|
229
|
+
it("should be possible to insert into the map", function () {
|
|
219
230
|
// Test insertion of the first node
|
|
220
|
-
map.insert(
|
|
221
|
-
expect(map.has(
|
|
222
|
-
expect(map.has(
|
|
223
|
-
expect(map.get(
|
|
231
|
+
map.insert("node1", mapNode1);
|
|
232
|
+
expect(map.has("node1")).to.be.ok;
|
|
233
|
+
expect(map.has("node2")).to.be.not.ok;
|
|
234
|
+
expect(map.get("node2")).to.equal(undefined);
|
|
224
235
|
expect(mapNode1.getParent()).to.equal(map);
|
|
225
|
-
var CS = map.serialize({
|
|
236
|
+
var CS = map.serialize({ dirtyOnly: true });
|
|
226
237
|
expect(CS.insert &&
|
|
227
|
-
CS.insert[
|
|
228
|
-
_.keys(CS.insert[
|
|
229
|
-
_.keys(CS.insert[
|
|
238
|
+
CS.insert["autodesk.tests:MapTestPropertyID-1.0.0"] &&
|
|
239
|
+
_.keys(CS.insert["autodesk.tests:MapTestPropertyID-1.0.0"]).length === 1 &&
|
|
240
|
+
_.keys(CS.insert["autodesk.tests:MapTestPropertyID-1.0.0"])[0] === "node1").to.be.ok;
|
|
230
241
|
// Test insertion of the second node
|
|
231
|
-
map.insert(
|
|
232
|
-
expect(map.has(
|
|
233
|
-
expect(map.get(
|
|
234
|
-
changeSetWithTwoMapEntries = map.serialize({
|
|
242
|
+
map.insert("node2", mapNode2);
|
|
243
|
+
expect(map.has("node2")).to.be.ok;
|
|
244
|
+
expect(map.get("node2")).to.equal(mapNode2);
|
|
245
|
+
changeSetWithTwoMapEntries = map.serialize({ dirtyOnly: true });
|
|
235
246
|
expect(changeSetWithTwoMapEntries.insert &&
|
|
236
|
-
changeSetWithTwoMapEntries.insert[
|
|
237
|
-
_.keys(changeSetWithTwoMapEntries.insert[
|
|
238
|
-
_.includes(_.keys(changeSetWithTwoMapEntries.insert[
|
|
239
|
-
_.includes(_.keys(changeSetWithTwoMapEntries.insert[
|
|
240
|
-
changeSetWithTwoMapEntries_full = map.serialize({
|
|
247
|
+
changeSetWithTwoMapEntries.insert["autodesk.tests:MapTestPropertyID-1.0.0"] &&
|
|
248
|
+
_.keys(changeSetWithTwoMapEntries.insert["autodesk.tests:MapTestPropertyID-1.0.0"]).length === 2 &&
|
|
249
|
+
_.includes(_.keys(changeSetWithTwoMapEntries.insert["autodesk.tests:MapTestPropertyID-1.0.0"]), "node1") &&
|
|
250
|
+
_.includes(_.keys(changeSetWithTwoMapEntries.insert["autodesk.tests:MapTestPropertyID-1.0.0"]), "node2")).to.be.ok;
|
|
251
|
+
changeSetWithTwoMapEntries_full = map.serialize({ dirtyOnly: false });
|
|
241
252
|
expect(changeSetWithTwoMapEntries).to.deep.equal(changeSetWithTwoMapEntries_full);
|
|
242
253
|
});
|
|
243
|
-
it(
|
|
254
|
+
it("Should track dirtiness", function () {
|
|
244
255
|
map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY);
|
|
245
256
|
expect(map.serialize({
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
257
|
+
dirtyOnly: true,
|
|
258
|
+
includeRootTypeid: false,
|
|
259
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY,
|
|
249
260
|
})).to.be.empty;
|
|
250
261
|
expect(map.serialize({
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
262
|
+
dirtyOnly: true,
|
|
263
|
+
includeRootTypeid: false,
|
|
264
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE,
|
|
254
265
|
})).deep.equal(changeSetWithTwoMapEntries_full);
|
|
255
|
-
expect(map.serialize({
|
|
266
|
+
expect(map.serialize({ dirtyOnly: false })).deep.equal(changeSetWithTwoMapEntries_full);
|
|
256
267
|
});
|
|
257
|
-
it(
|
|
258
|
-
map.remove(
|
|
268
|
+
it("Should handle removals correctly", function () {
|
|
269
|
+
map.remove("node1");
|
|
259
270
|
expect(mapNode1.getParent()).to.be.undefined;
|
|
260
|
-
map.remove(
|
|
271
|
+
map.remove("node2");
|
|
261
272
|
expect(map.serialize({
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
273
|
+
dirtyOnly: true,
|
|
274
|
+
includeRootTypeid: false,
|
|
275
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE,
|
|
265
276
|
})).to.be.empty;
|
|
266
|
-
expect(map.serialize({
|
|
277
|
+
expect(map.serialize({ dirtyOnly: false })).to.be.empty;
|
|
267
278
|
removalChangeSet = map.serialize({
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
279
|
+
dirtyOnly: true,
|
|
280
|
+
includeRootTypeid: false,
|
|
281
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY,
|
|
271
282
|
});
|
|
272
|
-
expect(removalChangeSet).to.have.all.keys([
|
|
283
|
+
expect(removalChangeSet).to.have.all.keys(["remove"]);
|
|
273
284
|
expect(removalChangeSet.remove).to.have.length(2);
|
|
274
|
-
expect(removalChangeSet.remove).to.contain(
|
|
275
|
-
expect(removalChangeSet.remove).to.contain(
|
|
285
|
+
expect(removalChangeSet.remove).to.contain("node1");
|
|
286
|
+
expect(removalChangeSet.remove).to.contain("node2");
|
|
276
287
|
});
|
|
277
|
-
it(
|
|
288
|
+
it("Should support deserialization", function () {
|
|
278
289
|
// Deserialization should return an identical property
|
|
279
|
-
var deserializedNode = PropertyFactory.create(
|
|
290
|
+
var deserializedNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
280
291
|
var deserializedChanges1 = deserializedNode._properties.map.deserialize(changeSetWithTwoMapEntries);
|
|
281
|
-
var CS4 = deserializedNode._properties.map.serialize({
|
|
292
|
+
var CS4 = deserializedNode._properties.map.serialize({ dirtyOnly: false });
|
|
282
293
|
expect(CS4).to.deep.equal(changeSetWithTwoMapEntries);
|
|
283
294
|
expect(deserializedChanges1).to.deep.equal(changeSetWithTwoMapEntries);
|
|
284
|
-
expect(deserializedNode._properties.map.serialize({
|
|
285
|
-
expect(deserializedNode._properties.map.serialize({
|
|
286
|
-
expect(deserializedNode._properties.map.serialize({
|
|
295
|
+
expect(deserializedNode._properties.map.serialize({ dirtyOnly: true })).to.deep.equal(changeSetWithTwoMapEntries);
|
|
296
|
+
expect(deserializedNode._properties.map.serialize({ dirtyOnly: true })).to.deep.equal(changeSetWithTwoMapEntries);
|
|
297
|
+
expect(deserializedNode._properties.map.serialize({ dirtyOnly: true })).to.deep.equal(changeSetWithTwoMapEntries);
|
|
287
298
|
// Deserializing the same ChangeSet twice should return an empty ChangeSet
|
|
288
299
|
deserializedNode._properties.map.cleanDirty();
|
|
289
300
|
var deserializedChanges2 = deserializedNode._properties.map.deserialize(changeSetWithTwoMapEntries);
|
|
290
301
|
expect(deserializedChanges2).to.be.empty;
|
|
291
|
-
expect(deserializedNode._properties.map.serialize({
|
|
302
|
+
expect(deserializedNode._properties.map.serialize({ dirtyOnly: true })).to.be.empty;
|
|
292
303
|
// Deserialization of a modification should return the correct modification
|
|
293
|
-
var modifiedProperty = PropertyFactory.create(
|
|
304
|
+
var modifiedProperty = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
294
305
|
modifiedProperty._properties.map.deserialize(changeSetWithTwoMapEntries);
|
|
295
|
-
modifiedProperty._properties.map.get(
|
|
306
|
+
modifiedProperty._properties.map.get("node2")._properties.stringProperty.value =
|
|
307
|
+
"newValue";
|
|
296
308
|
deserializedNode._properties.map.cleanDirty();
|
|
297
|
-
var deserializedChanges3 = deserializedNode._properties.map.deserialize(modifiedProperty._properties.map.serialize({
|
|
309
|
+
var deserializedChanges3 = deserializedNode._properties.map.deserialize(modifiedProperty._properties.map.serialize({ dirtyOnly: false }));
|
|
298
310
|
var expectedChanges = {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
311
|
+
modify: {
|
|
312
|
+
"autodesk.tests:MapTestPropertyID-1.0.0": {
|
|
313
|
+
node2: {
|
|
314
|
+
String: {
|
|
315
|
+
stringProperty: "newValue",
|
|
304
316
|
},
|
|
305
317
|
},
|
|
306
318
|
},
|
|
307
319
|
},
|
|
308
320
|
};
|
|
309
321
|
expect(deserializedChanges3).to.deep.equal(expectedChanges);
|
|
310
|
-
expect(deserializedNode._properties.map.serialize({
|
|
322
|
+
expect(deserializedNode._properties.map.serialize({ dirtyOnly: true })).to.deep.equal(expectedChanges);
|
|
311
323
|
deserializedNode._properties.map.cleanDirty();
|
|
312
324
|
var deserializedChanges4 = deserializedNode._properties.map.deserialize({});
|
|
313
325
|
expect(deserializedChanges4).to.deep.equal(removalChangeSet);
|
|
314
|
-
expect(deserializedNode._properties.map.serialize({
|
|
326
|
+
expect(deserializedNode._properties.map.serialize({ dirtyOnly: true })).to.deep.equal(removalChangeSet);
|
|
315
327
|
});
|
|
316
|
-
it(
|
|
317
|
-
var testProp1 = PropertyFactory.create(
|
|
318
|
-
testProp1.set(
|
|
319
|
-
var changes = testProp1.deserialize(testProp1.serialize({
|
|
328
|
+
it("Should support deserialization of falsy primitive types", function () {
|
|
329
|
+
var testProp1 = PropertyFactory.create("map<Bool>");
|
|
330
|
+
testProp1.set("entry", false);
|
|
331
|
+
var changes = testProp1.deserialize(testProp1.serialize({ dirtyOnly: false }));
|
|
320
332
|
expect(changes).to.be.empty;
|
|
321
333
|
});
|
|
322
|
-
it(
|
|
323
|
-
var modifyNode1 = PropertyFactory.create(
|
|
324
|
-
var modifyNode2 = PropertyFactory.create(
|
|
334
|
+
it("Should track modifies", function () {
|
|
335
|
+
var modifyNode1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
336
|
+
var modifyNode2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
325
337
|
modifyNode1._properties.map.deserialize(changeSetWithTwoMapEntries);
|
|
326
338
|
modifyNode2._properties.map.deserialize(changeSetWithTwoMapEntries);
|
|
327
339
|
modifyNode1._properties.map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
328
340
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
329
|
-
var child1 = modifyNode1._properties.map.get(
|
|
330
|
-
child1._properties.stringProperty.value =
|
|
331
|
-
var modifyChangeSet = modifyNode1._properties.map.serialize({
|
|
341
|
+
var child1 = modifyNode1._properties.map.get("node1");
|
|
342
|
+
child1._properties.stringProperty.value = "modify test";
|
|
343
|
+
var modifyChangeSet = modifyNode1._properties.map.serialize({ dirtyOnly: true });
|
|
332
344
|
modifyNode2._properties.map.applyChangeSet(modifyChangeSet);
|
|
333
|
-
expect(modifyNode2._properties.map.serialize({
|
|
334
|
-
.to.deep.equal(modifyNode1._properties.map.serialize({ 'dirtyOnly': false }));
|
|
345
|
+
expect(modifyNode2._properties.map.serialize({ dirtyOnly: false })).to.deep.equal(modifyNode1._properties.map.serialize({ dirtyOnly: false }));
|
|
335
346
|
});
|
|
336
|
-
it(
|
|
337
|
-
var node1 = PropertyFactory.create(
|
|
338
|
-
var node2 = PropertyFactory.create(
|
|
339
|
-
var node3 = PropertyFactory.create(
|
|
347
|
+
it("Should support hierarchical properties", function () {
|
|
348
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
349
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
350
|
+
var node3 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
340
351
|
// Create a hierarchy of three nodes
|
|
341
|
-
node1._properties.map.insert(
|
|
342
|
-
node2._properties.map.insert(
|
|
343
|
-
node3._properties.stringProperty.value =
|
|
352
|
+
node1._properties.map.insert("node", node2);
|
|
353
|
+
node2._properties.map.insert("node", node3);
|
|
354
|
+
node3._properties.stringProperty.value = "test";
|
|
344
355
|
// Check that deserializing and serializing works with a hierarchy
|
|
345
|
-
var hierarchicalChangeSet = node1.serialize({
|
|
346
|
-
var deserializedNode = PropertyFactory.create(
|
|
356
|
+
var hierarchicalChangeSet = node1.serialize({ dirtyOnly: true });
|
|
357
|
+
var deserializedNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
347
358
|
deserializedNode.deserialize(hierarchicalChangeSet);
|
|
348
359
|
var child1 = deserializedNode._properties.map.getAsArray()[0];
|
|
349
360
|
expect(child1).to.not.equal(undefined);
|
|
350
361
|
var child2 = child1._properties.map.getAsArray()[0];
|
|
351
362
|
expect(child2).to.not.equal(undefined);
|
|
352
|
-
expect(child2._properties.stringProperty.value).to.equal(
|
|
363
|
+
expect(child2._properties.stringProperty.value).to.equal("test");
|
|
353
364
|
// Test that hierarchical modifies work
|
|
354
365
|
node1.cleanDirty();
|
|
355
|
-
node3._properties.stringProperty.value =
|
|
356
|
-
var hierarchicalModifyChangeSet = node1.serialize({
|
|
366
|
+
node3._properties.stringProperty.value = "test2";
|
|
367
|
+
var hierarchicalModifyChangeSet = node1.serialize({ dirtyOnly: true });
|
|
357
368
|
deserializedNode.applyChangeSet(hierarchicalModifyChangeSet);
|
|
358
369
|
child1 = deserializedNode._properties.map.getAsArray()[0];
|
|
359
370
|
expect(child1).to.not.equal(undefined);
|
|
360
371
|
child2 = child1._properties.map.getAsArray()[0];
|
|
361
372
|
expect(child2).to.not.equal(undefined);
|
|
362
|
-
expect(child2._properties.stringProperty.value).to.equal(
|
|
363
|
-
});
|
|
364
|
-
it(
|
|
365
|
-
var rootNode = PropertyFactory.create(
|
|
366
|
-
var rootNode2 = PropertyFactory.create(
|
|
367
|
-
var node1 = PropertyFactory.create(
|
|
368
|
-
var node2 = PropertyFactory.create(
|
|
369
|
-
rootNode._properties.map.insert(
|
|
370
|
-
rootNode._properties.map.insert(
|
|
371
|
-
var testChangeSet = rootNode.serialize({
|
|
372
|
-
expect(rootNode._properties.map.get(
|
|
373
|
-
expect(rootNode._properties.map.get(
|
|
373
|
+
expect(child2._properties.stringProperty.value).to.equal("test2");
|
|
374
|
+
});
|
|
375
|
+
it("should be possible to use anonymous properties", function () {
|
|
376
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
377
|
+
var rootNode2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
378
|
+
var node1 = PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0");
|
|
379
|
+
var node2 = PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0");
|
|
380
|
+
rootNode._properties.map.insert("node1", node1);
|
|
381
|
+
rootNode._properties.map.insert("node2", node2);
|
|
382
|
+
var testChangeSet = rootNode.serialize({ dirtyOnly: false });
|
|
383
|
+
expect(rootNode._properties.map.get("node1")).to.be.equal(node1);
|
|
384
|
+
expect(rootNode._properties.map.get("node2")).to.be.equal(node2);
|
|
374
385
|
rootNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
375
386
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
376
|
-
node1._properties.stringProperty.value =
|
|
377
|
-
node2._properties.stringProperty.value =
|
|
387
|
+
node1._properties.stringProperty.value = "1";
|
|
388
|
+
node2._properties.stringProperty.value = "2";
|
|
378
389
|
rootNode2.deserialize(testChangeSet);
|
|
379
|
-
rootNode2.applyChangeSet(rootNode.serialize({
|
|
380
|
-
expect(rootNode2.serialize({
|
|
381
|
-
});
|
|
382
|
-
it(
|
|
383
|
-
var rootNode = PropertyFactory.create(
|
|
384
|
-
var node1 = PropertyFactory.create(
|
|
385
|
-
var node2 = PropertyFactory.create(
|
|
386
|
-
rootNode._properties.map.insert(
|
|
390
|
+
rootNode2.applyChangeSet(rootNode.serialize({ dirtyOnly: true }));
|
|
391
|
+
expect(rootNode2.serialize({ dirtyOnly: false })).to.be.deep.equal(rootNode.serialize({ dirtyOnly: false }));
|
|
392
|
+
});
|
|
393
|
+
it("inserting the same key twice should throw an exception", function () {
|
|
394
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
395
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
396
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
397
|
+
rootNode._properties.map.insert("node1", node1);
|
|
387
398
|
expect(function () {
|
|
388
|
-
rootNode._properties.map.insert(
|
|
399
|
+
rootNode._properties.map.insert("node1", node2);
|
|
389
400
|
}).to.throw();
|
|
390
401
|
});
|
|
391
|
-
it(
|
|
392
|
-
var rootNode = PropertyFactory.create(
|
|
393
|
-
var node1 = PropertyFactory.create(
|
|
394
|
-
var node2 = PropertyFactory.create(
|
|
395
|
-
var node3 = PropertyFactory.create(
|
|
396
|
-
rootNode._properties.map.set(
|
|
397
|
-
rootNode._properties.map.set(
|
|
402
|
+
it("set should overwrite existing entry", function () {
|
|
403
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
404
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
405
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
406
|
+
var node3 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
407
|
+
rootNode._properties.map.set("node1", node1);
|
|
408
|
+
rootNode._properties.map.set("node1", node2);
|
|
398
409
|
// the set should overwrite the insert
|
|
399
|
-
expect(rootNode.serialize({
|
|
410
|
+
expect(rootNode.serialize({ dirtyOnly: true })["map<NamedProperty>"].map).to.have.all.keys("insert");
|
|
400
411
|
// Overwriting with the same property shouldn't dirty the node
|
|
401
412
|
rootNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
402
413
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
403
|
-
rootNode._properties.map.set(
|
|
404
|
-
expect(ChangeSet.isEmptyChangeSet(rootNode.serialize({
|
|
414
|
+
rootNode._properties.map.set("node1", node2);
|
|
415
|
+
expect(ChangeSet.isEmptyChangeSet(rootNode.serialize({ dirtyOnly: true }))).to.be.ok;
|
|
405
416
|
expect(rootNode.isDirty()).to.be.false;
|
|
406
417
|
// Overwriting with a different value should result in an remove and insert
|
|
407
|
-
rootNode._properties.map.set(
|
|
408
|
-
expect(rootNode.serialize({
|
|
409
|
-
rootNode._properties.map.set(
|
|
410
|
-
expect(rootNode.serialize({
|
|
411
|
-
expect(rootNode.serialize({
|
|
412
|
-
});
|
|
413
|
-
it(
|
|
414
|
-
var rootNode = PropertyFactory.create(
|
|
415
|
-
|
|
416
|
-
|
|
418
|
+
rootNode._properties.map.set("node1", node1);
|
|
419
|
+
expect(rootNode.serialize({ dirtyOnly: true })["map<NamedProperty>"].map).to.have.all.keys("insert", "remove");
|
|
420
|
+
rootNode._properties.map.set("node1", node3);
|
|
421
|
+
expect(rootNode.serialize({ dirtyOnly: true })["map<NamedProperty>"].map).to.have.all.keys("insert", "remove");
|
|
422
|
+
expect(rootNode.serialize({ dirtyOnly: true })["map<NamedProperty>"].map.remove).to.have.length(1);
|
|
423
|
+
});
|
|
424
|
+
it("set should throw if the value inserted is not a property", function () {
|
|
425
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0")
|
|
426
|
+
._properties.map;
|
|
427
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
428
|
+
rootNode.insert("node", node1);
|
|
417
429
|
var incorrectFn = function () {
|
|
418
|
-
rootNode.set(
|
|
430
|
+
rootNode.set("node", 8);
|
|
419
431
|
};
|
|
420
432
|
expect(incorrectFn).to.throw();
|
|
421
433
|
});
|
|
422
|
-
it(
|
|
423
|
-
var rootNode = PropertyFactory.create(
|
|
424
|
-
|
|
434
|
+
it("insert should work when inserting a primitive value", function () {
|
|
435
|
+
var rootNode = PropertyFactory.create("autodesk.tests:PrimitiveMap-1.0.0")._properties
|
|
436
|
+
.map;
|
|
437
|
+
rootNode.insert("node0", 1);
|
|
425
438
|
var correctFn = function () {
|
|
426
|
-
rootNode.insert(
|
|
439
|
+
rootNode.insert("node1", 4);
|
|
427
440
|
};
|
|
428
441
|
expect(correctFn).to.not.throw();
|
|
429
442
|
});
|
|
430
|
-
it(
|
|
431
|
-
var rootNode = PropertyFactory.create(
|
|
432
|
-
var node = PropertyFactory.create(
|
|
443
|
+
it("inserting the same node twice should be a bug", function () {
|
|
444
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
445
|
+
var node = PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0");
|
|
433
446
|
// Try to insert the same node object under two keys
|
|
434
|
-
rootNode._properties.map.insert(
|
|
447
|
+
rootNode._properties.map.insert("node", node);
|
|
435
448
|
expect(function () {
|
|
436
|
-
rootNode._properties.map.insert(
|
|
449
|
+
rootNode._properties.map.insert("node2", node);
|
|
437
450
|
}).to.throw();
|
|
438
451
|
// After removing it, adding it under a new key should be possible
|
|
439
|
-
rootNode._properties.map.remove(
|
|
440
|
-
rootNode._properties.map.insert(
|
|
452
|
+
rootNode._properties.map.remove("node");
|
|
453
|
+
rootNode._properties.map.insert("node2", node);
|
|
441
454
|
});
|
|
442
|
-
it(
|
|
443
|
-
var node = PropertyFactory.create(
|
|
455
|
+
it("setValues should work for primitive maps", function () {
|
|
456
|
+
var node = PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0");
|
|
444
457
|
node.setValues({
|
|
445
|
-
|
|
458
|
+
stringProperty: "newString!!",
|
|
446
459
|
});
|
|
447
|
-
expect(node.get(
|
|
460
|
+
expect(node.get("stringProperty").getValue()).to.equal("newString!!");
|
|
448
461
|
});
|
|
449
|
-
it(
|
|
462
|
+
it("setValues should replace values for primitive types ", function () {
|
|
450
463
|
var PrimitiveInt32MapTemplate = {
|
|
451
|
-
typeid:
|
|
452
|
-
properties: [
|
|
453
|
-
{ typeid: 'Int32', id: 'map', context: 'map' },
|
|
454
|
-
],
|
|
464
|
+
typeid: "autodesk.tests:PrimitiveInt32Map-1.0.0",
|
|
465
|
+
properties: [{ typeid: "Int32", id: "map", context: "map" }],
|
|
455
466
|
};
|
|
456
467
|
PropertyFactory.register(PrimitiveInt32MapTemplate);
|
|
457
|
-
var node = PropertyFactory.create(
|
|
458
|
-
node.get(
|
|
459
|
-
node.get(
|
|
460
|
-
expect(node.get(
|
|
461
|
-
expect(node.get(
|
|
468
|
+
var node = PropertyFactory.create("autodesk.tests:PrimitiveInt32Map-1.0.0");
|
|
469
|
+
node.get("map").insert("firstKey", 111);
|
|
470
|
+
node.get("map").insert("secondKey", 222);
|
|
471
|
+
expect(node.get("map").getEntriesReadOnly().firstKey).to.equal(111);
|
|
472
|
+
expect(node.get("map").getEntriesReadOnly().secondKey).to.equal(222);
|
|
462
473
|
node.setValues({
|
|
463
|
-
|
|
464
|
-
|
|
474
|
+
map: {
|
|
475
|
+
firstKey: 333,
|
|
465
476
|
},
|
|
466
477
|
});
|
|
467
|
-
expect(node.get(
|
|
468
|
-
expect(node.get(
|
|
478
|
+
expect(node.get("map").getEntriesReadOnly().firstKey).to.equal(333);
|
|
479
|
+
expect(node.get("map").getEntriesReadOnly().secondKey).to.equal(222);
|
|
469
480
|
});
|
|
470
|
-
it(
|
|
471
|
-
var rootNode = PropertyFactory.create(
|
|
472
|
-
var node = PropertyFactory.create(
|
|
473
|
-
rootNode._properties.map.insert(
|
|
481
|
+
it("getValues should work for primitive maps", function () {
|
|
482
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
483
|
+
var node = PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0");
|
|
484
|
+
rootNode._properties.map.insert("node", node);
|
|
474
485
|
rootNode._properties.map.setValues({
|
|
475
|
-
|
|
476
|
-
|
|
486
|
+
node: {
|
|
487
|
+
stringProperty: "newString!!",
|
|
477
488
|
},
|
|
478
489
|
});
|
|
479
490
|
var expectedResult = {
|
|
480
491
|
node: {
|
|
481
|
-
|
|
492
|
+
stringProperty: "newString!!",
|
|
482
493
|
},
|
|
483
494
|
};
|
|
484
495
|
expect(rootNode._properties.map.getValues()).to.deep.equal(expectedResult);
|
|
485
496
|
});
|
|
486
|
-
it(
|
|
487
|
-
var mapProp = PropertyFactory.create(
|
|
488
|
-
var string1 = PropertyFactory.create(
|
|
489
|
-
var string2 = PropertyFactory.create(
|
|
490
|
-
mapProp.get(
|
|
491
|
-
mapProp.get(
|
|
497
|
+
it("setValues should work for custom maps", function () {
|
|
498
|
+
var mapProp = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0");
|
|
499
|
+
var string1 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0");
|
|
500
|
+
var string2 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0");
|
|
501
|
+
mapProp.get("map").insert("firstString", string1);
|
|
502
|
+
mapProp.get("map").insert("secondString", string2);
|
|
492
503
|
mapProp.setValues({
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
504
|
+
map: {
|
|
505
|
+
firstString: {
|
|
506
|
+
stringValue: "test1",
|
|
496
507
|
},
|
|
497
|
-
|
|
498
|
-
|
|
508
|
+
secondString: {
|
|
509
|
+
stringValue: "test2",
|
|
499
510
|
},
|
|
500
511
|
},
|
|
501
512
|
});
|
|
502
|
-
expect(mapProp.get([
|
|
503
|
-
expect(mapProp.get([
|
|
504
|
-
mapProp.get(
|
|
505
|
-
expect(mapProp.get([
|
|
506
|
-
expect(mapProp.get([
|
|
507
|
-
});
|
|
508
|
-
it(
|
|
509
|
-
var mapProp = PropertyFactory.create(
|
|
513
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1");
|
|
514
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2");
|
|
515
|
+
mapProp.get("map").setValues({ firstString: { stringValue: "test1_updated" } });
|
|
516
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1_updated");
|
|
517
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2");
|
|
518
|
+
});
|
|
519
|
+
it("setValues should update values for existing keys and create new ones for non-existing keys", function () {
|
|
520
|
+
var mapProp = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0");
|
|
510
521
|
mapProp.setValues({
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
522
|
+
map: {
|
|
523
|
+
firstString: {
|
|
524
|
+
stringValue: "test1",
|
|
514
525
|
},
|
|
515
|
-
|
|
516
|
-
|
|
526
|
+
secondString: {
|
|
527
|
+
stringValue: "test2",
|
|
517
528
|
},
|
|
518
529
|
},
|
|
519
530
|
});
|
|
520
|
-
expect(mapProp.get([
|
|
521
|
-
expect(mapProp.get([
|
|
531
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1");
|
|
532
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2");
|
|
522
533
|
mapProp.setValues({
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
534
|
+
map: {
|
|
535
|
+
secondString: {
|
|
536
|
+
stringValue: "test2-upd",
|
|
526
537
|
},
|
|
527
|
-
|
|
528
|
-
|
|
538
|
+
thirdString: {
|
|
539
|
+
stringValue: "test3",
|
|
529
540
|
},
|
|
530
541
|
},
|
|
531
542
|
});
|
|
532
|
-
expect(mapProp.get([
|
|
533
|
-
expect(mapProp.get([
|
|
534
|
-
expect(mapProp.get([
|
|
543
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1");
|
|
544
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2-upd");
|
|
545
|
+
expect(mapProp.get(["map", "thirdString", "stringValue"]).getValue()).to.equal("test3");
|
|
535
546
|
mapProp.setValues({
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
547
|
+
map: {
|
|
548
|
+
fourthString: {
|
|
549
|
+
stringValue: "test4",
|
|
539
550
|
},
|
|
540
|
-
|
|
541
|
-
|
|
551
|
+
thirdString: {
|
|
552
|
+
stringValue: "test3-upd",
|
|
542
553
|
},
|
|
543
554
|
},
|
|
544
555
|
});
|
|
545
|
-
expect(mapProp.get([
|
|
546
|
-
expect(mapProp.get([
|
|
547
|
-
expect(mapProp.get([
|
|
548
|
-
expect(mapProp.get([
|
|
549
|
-
});
|
|
550
|
-
it(
|
|
551
|
-
var mapProp = PropertyFactory.create(
|
|
552
|
-
var string1 = PropertyFactory.create(
|
|
553
|
-
var string2 = PropertyFactory.create(
|
|
554
|
-
mapProp._properties.map.insert(
|
|
555
|
-
mapProp._properties.map.insert(
|
|
556
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1");
|
|
557
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2-upd");
|
|
558
|
+
expect(mapProp.get(["map", "thirdString", "stringValue"]).getValue()).to.equal("test3-upd");
|
|
559
|
+
expect(mapProp.get(["map", "fourthString", "stringValue"]).getValue()).to.equal("test4");
|
|
560
|
+
});
|
|
561
|
+
it("getValues should work for custom maps", function () {
|
|
562
|
+
var mapProp = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0");
|
|
563
|
+
var string1 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0");
|
|
564
|
+
var string2 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0");
|
|
565
|
+
mapProp._properties.map.insert("firstString", string1);
|
|
566
|
+
mapProp._properties.map.insert("secondString", string2);
|
|
556
567
|
mapProp.setValues({
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
568
|
+
map: {
|
|
569
|
+
firstString: {
|
|
570
|
+
stringValue: "test1",
|
|
560
571
|
},
|
|
561
|
-
|
|
562
|
-
|
|
572
|
+
secondString: {
|
|
573
|
+
stringValue: "test2",
|
|
563
574
|
},
|
|
564
575
|
},
|
|
565
576
|
});
|
|
566
577
|
var expectedResult = {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
578
|
+
map: {
|
|
579
|
+
firstString: {
|
|
580
|
+
stringValue: "test1",
|
|
570
581
|
},
|
|
571
|
-
|
|
572
|
-
|
|
582
|
+
secondString: {
|
|
583
|
+
stringValue: "test2",
|
|
573
584
|
},
|
|
574
585
|
},
|
|
575
586
|
};
|
|
576
587
|
expect(mapProp.getValues()).to.deep.equal(expectedResult);
|
|
577
588
|
});
|
|
578
|
-
it(
|
|
579
|
-
var mapProp = PropertyFactory.create(
|
|
580
|
-
var string1 = PropertyFactory.create(
|
|
581
|
-
|
|
589
|
+
it("setValues should create new items from typed properties if key does not exist", function () {
|
|
590
|
+
var mapProp = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0");
|
|
591
|
+
var string1 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0", null, {
|
|
592
|
+
stringValue: "test1",
|
|
593
|
+
});
|
|
594
|
+
var string2 = PropertyFactory.create("autodesk.tests:StringProperty-1.0.0", null, {
|
|
595
|
+
stringValue: "test2",
|
|
596
|
+
});
|
|
582
597
|
mapProp.setValues({
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
598
|
+
map: {
|
|
599
|
+
firstString: string1,
|
|
600
|
+
secondString: string2,
|
|
586
601
|
},
|
|
587
602
|
});
|
|
588
|
-
expect(mapProp.get([
|
|
589
|
-
expect(mapProp.get([
|
|
603
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1");
|
|
604
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2");
|
|
590
605
|
});
|
|
591
|
-
it(
|
|
592
|
-
var mapProp = PropertyFactory.create(
|
|
606
|
+
it("setValues should create new items from untyped inputs if key does not exist", function () {
|
|
607
|
+
var mapProp = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0");
|
|
593
608
|
mapProp.setValues({
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
609
|
+
map: {
|
|
610
|
+
firstString: {
|
|
611
|
+
stringValue: "test1",
|
|
597
612
|
},
|
|
598
|
-
|
|
599
|
-
|
|
613
|
+
secondString: {
|
|
614
|
+
stringValue: "test2",
|
|
600
615
|
},
|
|
601
616
|
},
|
|
602
617
|
});
|
|
603
|
-
expect(mapProp.get([
|
|
604
|
-
expect(mapProp.get([
|
|
618
|
+
expect(mapProp.get(["map", "firstString", "stringValue"]).getValue()).to.equal("test1");
|
|
619
|
+
expect(mapProp.get(["map", "secondString", "stringValue"]).getValue()).to.equal("test2");
|
|
605
620
|
});
|
|
606
|
-
it(
|
|
607
|
-
var rootNode = PropertyFactory.create(
|
|
608
|
-
var mapProp = PropertyFactory.create(
|
|
621
|
+
it("getRelativePath should work", function () {
|
|
622
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
623
|
+
var mapProp = PropertyFactory.create("autodesk.tests:NonPrimitiveMap-1.0.0");
|
|
609
624
|
mapProp.setValues({
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
625
|
+
map: {
|
|
626
|
+
firstString: {
|
|
627
|
+
stringValue: "test1",
|
|
613
628
|
},
|
|
614
|
-
|
|
615
|
-
|
|
629
|
+
secondString: {
|
|
630
|
+
stringValue: "test2",
|
|
616
631
|
},
|
|
617
632
|
},
|
|
618
633
|
});
|
|
619
|
-
rootNode._properties.map.insert(
|
|
620
|
-
expect(mapProp.get([
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
.to.equal(
|
|
624
|
-
expect(mapProp
|
|
625
|
-
.
|
|
626
|
-
.to.equal(
|
|
627
|
-
});
|
|
628
|
-
it(
|
|
629
|
-
var rootNode = PropertyFactory.create(
|
|
630
|
-
var node = PropertyFactory.create(
|
|
631
|
-
rootNode._properties.map.insert(
|
|
634
|
+
rootNode._properties.map.insert("nestedMap", mapProp);
|
|
635
|
+
expect(mapProp.get(["map", "firstString"]).getRelativePath(rootNode)).to.equal("map[nestedMap].map[firstString]");
|
|
636
|
+
expect(mapProp
|
|
637
|
+
.get(["map", "firstString"])
|
|
638
|
+
.getRelativePath(mapProp.get(["map", "secondString", "stringValue"]))).to.equal("../../[firstString]");
|
|
639
|
+
expect(mapProp
|
|
640
|
+
.get(["map", "firstString", "stringValue"])
|
|
641
|
+
.getRelativePath(mapProp.get(["map", "secondString", "stringValue"]))).to.equal("../../[firstString].stringValue");
|
|
642
|
+
});
|
|
643
|
+
it("path creation and resolution should work for entries of the map", function () {
|
|
644
|
+
var rootNode = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
645
|
+
var node = PropertyFactory.create("autodesk.tests:AnonymousMapTestPropertyID-1.0.0");
|
|
646
|
+
rootNode._properties.map.insert("node", node);
|
|
632
647
|
// Test whether the returned paths are correct
|
|
633
|
-
expect(node.getAbsolutePath()).to.equal(
|
|
634
|
-
expect(node.getRelativePath(node)).to.equal(
|
|
635
|
-
expect(node.getRelativePath(rootNode.resolvePath(
|
|
636
|
-
expect(node.getRelativePath(rootNode)).to.equal(
|
|
637
|
-
expect(rootNode.getRelativePath(node)).to.equal(
|
|
638
|
-
expect(rootNode.resolvePath(
|
|
639
|
-
expect(rootNode.resolvePath(
|
|
648
|
+
expect(node.getAbsolutePath()).to.equal("/map[node]");
|
|
649
|
+
expect(node.getRelativePath(node)).to.equal("");
|
|
650
|
+
expect(node.getRelativePath(rootNode.resolvePath("map"))).to.equal("[node]");
|
|
651
|
+
expect(node.getRelativePath(rootNode)).to.equal("map[node]");
|
|
652
|
+
expect(rootNode.getRelativePath(node)).to.equal("../../");
|
|
653
|
+
expect(rootNode.resolvePath("map[node]")).to.equal(node);
|
|
654
|
+
expect(rootNode.resolvePath("map").resolvePath("[node]")).to.equal(node);
|
|
640
655
|
// Test whether they are updated correctly
|
|
641
|
-
rootNode._properties.map.remove(
|
|
656
|
+
rootNode._properties.map.remove("node", node);
|
|
642
657
|
// After removal the old paths should be undefined
|
|
643
|
-
expect(rootNode.resolvePath(
|
|
644
|
-
expect(rootNode.resolvePath(
|
|
658
|
+
expect(rootNode.resolvePath("map[node]")).to.be.undefined;
|
|
659
|
+
expect(rootNode.resolvePath("map").resolvePath("[node]")).to.be.undefined;
|
|
645
660
|
// And the node should have an empty absolute path
|
|
646
|
-
expect(node.getAbsolutePath()).to.equal(
|
|
661
|
+
expect(node.getAbsolutePath()).to.equal("/");
|
|
647
662
|
// Now we try reinserting it under a different id (one containing a quotable character)
|
|
648
663
|
rootNode._properties.map.insert('node"2', node);
|
|
649
664
|
// Make sure the paths have been updated correctly
|
|
650
665
|
expect(node.getAbsolutePath()).to.equal('/map["node\\"2"]');
|
|
651
|
-
expect(node.getRelativePath(node)).to.equal(
|
|
652
|
-
expect(node.getRelativePath(rootNode.resolvePath(
|
|
666
|
+
expect(node.getRelativePath(node)).to.equal("");
|
|
667
|
+
expect(node.getRelativePath(rootNode.resolvePath("map"))).to.equal('["node\\"2"]');
|
|
653
668
|
// And the path resolution works with the new name
|
|
654
669
|
expect(rootNode.resolvePath('map["node\\"2"]')).to.equal(node);
|
|
655
|
-
expect(rootNode.resolvePath(
|
|
670
|
+
expect(rootNode.resolvePath("map").resolvePath('["node\\"2"]')).to.equal(node);
|
|
656
671
|
// Try an empty string as key
|
|
657
672
|
rootNode._properties.map.remove('node"2', node);
|
|
658
|
-
rootNode._properties.map.insert(
|
|
673
|
+
rootNode._properties.map.insert("", node);
|
|
659
674
|
// Make sure the paths have been updated correctly
|
|
660
675
|
expect(node.getAbsolutePath()).to.equal('/map[""]');
|
|
661
676
|
// And the path resolution works with the new name
|
|
662
677
|
expect(rootNode.resolvePath('map[""]')).to.equal(node);
|
|
663
|
-
expect(rootNode.resolvePath(
|
|
678
|
+
expect(rootNode.resolvePath("map").resolvePath('[""]')).to.equal(node);
|
|
664
679
|
// Try multiple levels
|
|
665
|
-
var leaf = PropertyFactory.create(
|
|
666
|
-
expect(leaf.resolvePath(
|
|
667
|
-
var map1 = PropertyFactory.create(
|
|
668
|
-
map1.insert(
|
|
669
|
-
expect(leaf.resolvePath(
|
|
670
|
-
var map2 = PropertyFactory.create(undefined,
|
|
671
|
-
map2.insert(
|
|
672
|
-
expect(leaf.resolvePath(
|
|
673
|
-
var map3 = PropertyFactory.create(undefined,
|
|
674
|
-
map3.insert(
|
|
675
|
-
expect(leaf.resolvePath(
|
|
680
|
+
var leaf = PropertyFactory.create("NodeProperty");
|
|
681
|
+
expect(leaf.resolvePath("/")).to.equal(leaf);
|
|
682
|
+
var map1 = PropertyFactory.create("NodeProperty", "map");
|
|
683
|
+
map1.insert("entry", leaf);
|
|
684
|
+
expect(leaf.resolvePath("/")).to.equal(map1);
|
|
685
|
+
var map2 = PropertyFactory.create(undefined, "map");
|
|
686
|
+
map2.insert("entry", map1);
|
|
687
|
+
expect(leaf.resolvePath("/")).to.equal(map2);
|
|
688
|
+
var map3 = PropertyFactory.create(undefined, "map");
|
|
689
|
+
map3.insert("entry", map2);
|
|
690
|
+
expect(leaf.resolvePath("/")).to.equal(map3);
|
|
676
691
|
// Pretty printing
|
|
677
|
-
var expectedPrettyStr =
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
var prettyStr =
|
|
692
|
+
var expectedPrettyStr = "undefined (Map of BaseProperty):\n" +
|
|
693
|
+
" entry (Map of BaseProperty):\n" +
|
|
694
|
+
" entry (Map of NodeProperty):\n" +
|
|
695
|
+
" entry (NodeProperty):\n";
|
|
696
|
+
var prettyStr = "";
|
|
682
697
|
map3.prettyPrint(function (str) {
|
|
683
|
-
prettyStr += str +
|
|
698
|
+
prettyStr += str + "\n";
|
|
684
699
|
});
|
|
685
700
|
expect(prettyStr).to.equal(expectedPrettyStr);
|
|
686
701
|
map3.prettyPrint();
|
|
687
702
|
});
|
|
688
703
|
});
|
|
689
|
-
describe(
|
|
704
|
+
describe("squashing", function () {
|
|
690
705
|
//
|
|
691
706
|
// Helper function which takes a sequence of callbacks that are successfully executed
|
|
692
707
|
// and the changes applied by the callbacks are separately tracked and squashed in a
|
|
@@ -697,19 +712,19 @@ describe('MapProperty', function () {
|
|
|
697
712
|
//
|
|
698
713
|
var testChangeSetSquashing = function (in_options) {
|
|
699
714
|
resetKeyCounter();
|
|
700
|
-
var testProperty = PropertyFactory.create(
|
|
715
|
+
var testProperty = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
701
716
|
var callbacks = in_options.callbacks;
|
|
702
717
|
if (in_options.pre) {
|
|
703
718
|
in_options.pre(testProperty);
|
|
704
719
|
}
|
|
705
|
-
var initialChangeset = new ChangeSet(testProperty.serialize({
|
|
720
|
+
var initialChangeset = new ChangeSet(testProperty.serialize({ dirtyOnly: false }));
|
|
706
721
|
initialChangeset.setIsNormalized(true);
|
|
707
722
|
var squashedChangeset = new ChangeSet();
|
|
708
723
|
testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
709
724
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
710
725
|
for (var i = 0; i < callbacks.length; i++) {
|
|
711
726
|
callbacks[i](testProperty);
|
|
712
|
-
var changes = testProperty.serialize({
|
|
727
|
+
var changes = testProperty.serialize({ dirtyOnly: true });
|
|
713
728
|
testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
714
729
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
715
730
|
squashedChangeset.applyChangeSet(changes);
|
|
@@ -718,100 +733,126 @@ describe('MapProperty', function () {
|
|
|
718
733
|
in_options.post(squashedChangeset.getSerializedChangeSet());
|
|
719
734
|
}
|
|
720
735
|
initialChangeset.applyChangeSet(squashedChangeset.getSerializedChangeSet());
|
|
721
|
-
expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({
|
|
736
|
+
expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ dirtyOnly: false }));
|
|
722
737
|
};
|
|
723
|
-
it(
|
|
724
|
-
testChangeSetSquashing({
|
|
738
|
+
it("should work for multiple independent inserts", function () {
|
|
739
|
+
testChangeSetSquashing({
|
|
740
|
+
callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot],
|
|
741
|
+
});
|
|
725
742
|
});
|
|
726
|
-
it(
|
|
727
|
-
testChangeSetSquashing({
|
|
743
|
+
it("should work for multiple hierarchical inserts", function () {
|
|
744
|
+
testChangeSetSquashing({
|
|
745
|
+
callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf],
|
|
746
|
+
});
|
|
728
747
|
});
|
|
729
|
-
it(
|
|
748
|
+
it("should work for inserts followed by removes", function () {
|
|
730
749
|
testChangeSetSquashing({
|
|
731
|
-
callbacks: [
|
|
750
|
+
callbacks: [
|
|
751
|
+
insertNodeInRoot,
|
|
752
|
+
insertNodeInRoot,
|
|
753
|
+
removeFirstNodeInRoot,
|
|
754
|
+
removeFirstNodeInRoot,
|
|
755
|
+
],
|
|
732
756
|
post: function (changeset) {
|
|
733
757
|
expect(changeset).to.be.empty;
|
|
734
758
|
},
|
|
735
759
|
});
|
|
736
760
|
});
|
|
737
|
-
it(
|
|
761
|
+
it("should work for a tree removal", function () {
|
|
738
762
|
testChangeSetSquashing({
|
|
739
|
-
callbacks: [
|
|
763
|
+
callbacks: [
|
|
764
|
+
insertNodeAsLeaf,
|
|
765
|
+
insertNodeAsLeaf,
|
|
766
|
+
insertNodeAsLeaf,
|
|
767
|
+
removeFirstNodeInRoot,
|
|
768
|
+
],
|
|
740
769
|
post: function (changeset) {
|
|
741
770
|
expect(changeset).to.be.empty;
|
|
742
771
|
},
|
|
743
772
|
});
|
|
744
773
|
});
|
|
745
|
-
it(
|
|
774
|
+
it("should work for modifies in a tree", function () {
|
|
746
775
|
testChangeSetSquashing({
|
|
747
|
-
callbacks: [
|
|
776
|
+
callbacks: [
|
|
777
|
+
insertNodeAsLeaf,
|
|
778
|
+
insertNodeAsLeaf,
|
|
779
|
+
insertNodeAsLeaf,
|
|
780
|
+
modifyLeaf,
|
|
781
|
+
modifyLeaf,
|
|
782
|
+
],
|
|
748
783
|
});
|
|
749
784
|
});
|
|
750
|
-
it(
|
|
785
|
+
it("an insert, modify and a remove should give an empty changeset", function () {
|
|
751
786
|
testChangeSetSquashing({
|
|
752
|
-
callbacks: [
|
|
787
|
+
callbacks: [
|
|
788
|
+
insertNodeAsLeaf,
|
|
789
|
+
insertNodeAsLeaf,
|
|
790
|
+
modifyLeaf,
|
|
791
|
+
modifyLeaf,
|
|
792
|
+
removeFirstNodeInRoot,
|
|
793
|
+
],
|
|
753
794
|
post: function (changeset) {
|
|
754
795
|
expect(changeset).to.be.empty;
|
|
755
796
|
},
|
|
756
797
|
});
|
|
757
798
|
});
|
|
758
|
-
it(
|
|
799
|
+
it("work for modifies after an already existing insert", function () {
|
|
759
800
|
testChangeSetSquashing({
|
|
760
801
|
pre: insertNodeInRoot,
|
|
761
802
|
callbacks: [modifyLeaf, modifyLeaf],
|
|
762
803
|
});
|
|
763
804
|
});
|
|
764
|
-
it(
|
|
805
|
+
it("of modify and remove after an already existing insert should work", function () {
|
|
765
806
|
testChangeSetSquashing({
|
|
766
807
|
pre: insertNodeInRoot,
|
|
767
808
|
callbacks: [modifyLeaf, removeFirstNodeInRoot],
|
|
768
809
|
post: function (changeset) {
|
|
769
|
-
expect(changeset[
|
|
810
|
+
expect(changeset["map<NamedProperty>"].map).to.have.all.keys("remove");
|
|
770
811
|
},
|
|
771
812
|
});
|
|
772
813
|
});
|
|
773
|
-
it(
|
|
814
|
+
it("of a replace operation should be possible", function () {
|
|
774
815
|
// Create two nodes with the same GUID
|
|
775
|
-
var node1 = PropertyFactory.create(
|
|
776
|
-
var node2 = PropertyFactory.create(
|
|
816
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
817
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
777
818
|
node2._properties.guid.value = node1._properties.guid.value;
|
|
778
|
-
node2._properties.stringProperty.value =
|
|
819
|
+
node2._properties.stringProperty.value = "testString2";
|
|
779
820
|
testChangeSetSquashing({
|
|
780
821
|
pre: function (root) {
|
|
781
|
-
root._properties.map.insert(
|
|
822
|
+
root._properties.map.insert("node1", node1);
|
|
782
823
|
},
|
|
783
824
|
callbacks: [
|
|
784
825
|
removeFirstNodeInRoot,
|
|
785
826
|
function (root) {
|
|
786
|
-
root._properties.map.insert(
|
|
827
|
+
root._properties.map.insert("node2", node2);
|
|
787
828
|
},
|
|
788
829
|
],
|
|
789
830
|
post: function (changeset) {
|
|
790
|
-
expect(changeset[
|
|
831
|
+
expect(changeset["map<NamedProperty>"].map).to.have.all.keys("remove", "insert");
|
|
791
832
|
},
|
|
792
833
|
});
|
|
793
834
|
});
|
|
794
|
-
it(
|
|
795
|
-
var node = PropertyFactory.create(
|
|
796
|
-
var testMap = PropertyFactory.create(
|
|
797
|
-
testMap.set(
|
|
798
|
-
node.insert(
|
|
799
|
-
var CS1 = node.serialize({
|
|
835
|
+
it("should work for nested collections", function () {
|
|
836
|
+
var node = PropertyFactory.create("NodeProperty");
|
|
837
|
+
var testMap = PropertyFactory.create("map<Bool>");
|
|
838
|
+
testMap.set("test", true);
|
|
839
|
+
node.insert("map", testMap);
|
|
840
|
+
var CS1 = node.serialize({ dirtyOnly: false });
|
|
800
841
|
node.cleanDirty();
|
|
801
|
-
testMap.set(
|
|
802
|
-
var CS2 = node.serialize({
|
|
842
|
+
testMap.set("test", false);
|
|
843
|
+
var CS2 = node.serialize({ dirtyOnly: true });
|
|
803
844
|
var CS = new ChangeSet(CS1);
|
|
804
845
|
CS.applyChangeSet(new ChangeSet(CS2));
|
|
805
|
-
expect(CS.getSerializedChangeSet().insert[
|
|
806
|
-
expect(CS.getSerializedChangeSet().insert[
|
|
846
|
+
expect(CS.getSerializedChangeSet().insert["map<Bool>"].map).to.have.all.keys("insert");
|
|
847
|
+
expect(CS.getSerializedChangeSet().insert["map<Bool>"].map.insert["test"]).to.equal(false);
|
|
807
848
|
});
|
|
808
|
-
it(
|
|
849
|
+
it("should work for a remove in a primitive map that contains another item", function () {
|
|
809
850
|
var cs1 = {
|
|
810
851
|
modify: {
|
|
811
|
-
|
|
852
|
+
"map<String>": {
|
|
812
853
|
testMap: {
|
|
813
854
|
insert: {
|
|
814
|
-
test1:
|
|
855
|
+
test1: "Hello",
|
|
815
856
|
},
|
|
816
857
|
},
|
|
817
858
|
},
|
|
@@ -819,10 +860,10 @@ describe('MapProperty', function () {
|
|
|
819
860
|
};
|
|
820
861
|
var cs2 = {
|
|
821
862
|
modify: {
|
|
822
|
-
|
|
863
|
+
"map<String>": {
|
|
823
864
|
testMap: {
|
|
824
865
|
remove: {
|
|
825
|
-
test2:
|
|
866
|
+
test2: "Goodbye",
|
|
826
867
|
},
|
|
827
868
|
},
|
|
828
869
|
},
|
|
@@ -833,53 +874,53 @@ describe('MapProperty', function () {
|
|
|
833
874
|
combined.applyChangeSet(cs2);
|
|
834
875
|
expect(combined.getSerializedChangeSet()).to.eql({
|
|
835
876
|
modify: {
|
|
836
|
-
|
|
877
|
+
"map<String>": {
|
|
837
878
|
testMap: {
|
|
838
879
|
insert: {
|
|
839
|
-
test1:
|
|
880
|
+
test1: "Hello",
|
|
840
881
|
},
|
|
841
882
|
remove: {
|
|
842
|
-
test2:
|
|
883
|
+
test2: "Goodbye",
|
|
843
884
|
},
|
|
844
885
|
},
|
|
845
886
|
},
|
|
846
887
|
},
|
|
847
888
|
});
|
|
848
889
|
});
|
|
849
|
-
it(
|
|
890
|
+
it("should work for maps in arrays", function () {
|
|
850
891
|
testChangeSetSquashing({
|
|
851
892
|
callbacks: [
|
|
852
893
|
function (root) {
|
|
853
|
-
var arrayNode = PropertyFactory.create(
|
|
854
|
-
arrayNode.push(PropertyFactory.create(
|
|
855
|
-
var boolMap = PropertyFactory.create(
|
|
856
|
-
boolMap.set(
|
|
857
|
-
arrayNode.get(0).insert(
|
|
858
|
-
root._properties.map.insert(
|
|
894
|
+
var arrayNode = PropertyFactory.create("array<NodeProperty>");
|
|
895
|
+
arrayNode.push(PropertyFactory.create("NodeProperty"));
|
|
896
|
+
var boolMap = PropertyFactory.create("map<Bool>");
|
|
897
|
+
boolMap.set("test", false);
|
|
898
|
+
arrayNode.get(0).insert("boolMap", boolMap);
|
|
899
|
+
root._properties.map.insert("array", arrayNode);
|
|
859
900
|
},
|
|
860
901
|
function (root) {
|
|
861
|
-
root.resolvePath(
|
|
862
|
-
}
|
|
902
|
+
root.resolvePath("map[array][0].boolMap").set("test", true);
|
|
903
|
+
},
|
|
863
904
|
],
|
|
864
905
|
post: function (changeset) {
|
|
865
|
-
expect(changeset[
|
|
866
|
-
.insert[
|
|
906
|
+
expect(changeset["map<NamedProperty>"].map.insert["array<NodeProperty>"].array
|
|
907
|
+
.insert["0"][1]["0"].insert["map<Bool>"].boolMap).to.have.all.keys("insert");
|
|
867
908
|
},
|
|
868
909
|
});
|
|
869
910
|
});
|
|
870
911
|
});
|
|
871
|
-
describe(
|
|
912
|
+
describe("Rebasing", function () {
|
|
872
913
|
var testRebasing = function (in_options) {
|
|
873
914
|
// Prepare the initial state
|
|
874
|
-
var baseProperty1 = PropertyFactory.create(
|
|
915
|
+
var baseProperty1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
875
916
|
if (in_options.prepare) {
|
|
876
917
|
in_options.prepare(baseProperty1);
|
|
877
918
|
}
|
|
878
919
|
// Create two copies of this state
|
|
879
|
-
var baseProperty2 = PropertyFactory.create(
|
|
880
|
-
baseProperty2.deserialize(baseProperty1.serialize({
|
|
881
|
-
var baseProperty3 = PropertyFactory.create(
|
|
882
|
-
baseProperty3.deserialize(baseProperty1.serialize({
|
|
920
|
+
var baseProperty2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
921
|
+
baseProperty2.deserialize(baseProperty1.serialize({ dirtyOnly: false }));
|
|
922
|
+
var baseProperty3 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
923
|
+
baseProperty3.deserialize(baseProperty1.serialize({ dirtyOnly: false }));
|
|
883
924
|
// Make sure the states are clear
|
|
884
925
|
baseProperty1.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
885
926
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
@@ -887,7 +928,7 @@ describe('MapProperty', function () {
|
|
|
887
928
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
888
929
|
baseProperty3.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
889
930
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
890
|
-
var initialChangeSet = baseProperty1.serialize({
|
|
931
|
+
var initialChangeSet = baseProperty1.serialize({ dirtyOnly: false });
|
|
891
932
|
// Apply the operations to the two properties in parallel
|
|
892
933
|
if (in_options.op1) {
|
|
893
934
|
in_options.op1(baseProperty1);
|
|
@@ -896,8 +937,8 @@ describe('MapProperty', function () {
|
|
|
896
937
|
in_options.op2(baseProperty2);
|
|
897
938
|
}
|
|
898
939
|
// Get the ChangeSets
|
|
899
|
-
var changeSet1 = new ChangeSet(baseProperty1.serialize({
|
|
900
|
-
var changeSet2 = baseProperty2.serialize({
|
|
940
|
+
var changeSet1 = new ChangeSet(baseProperty1.serialize({ dirtyOnly: true }));
|
|
941
|
+
var changeSet2 = baseProperty2.serialize({ dirtyOnly: true });
|
|
901
942
|
// Perform the actual rebase
|
|
902
943
|
var conflicts = [];
|
|
903
944
|
changeSet1._rebaseChangeSet(changeSet2, conflicts);
|
|
@@ -912,59 +953,59 @@ describe('MapProperty', function () {
|
|
|
912
953
|
if (in_options.op2) {
|
|
913
954
|
in_options.op2(baseProperty3);
|
|
914
955
|
}
|
|
915
|
-
var finalChangeSet = baseProperty3.serialize({
|
|
956
|
+
var finalChangeSet = baseProperty3.serialize({ dirtyOnly: false });
|
|
916
957
|
expect(finalChangeSet).to.be.deep.equal(combinedChangeSet.getSerializedChangeSet());
|
|
917
958
|
}
|
|
918
959
|
if (in_options.checkResult) {
|
|
919
960
|
in_options.checkResult(conflicts, changeSet2, combinedChangeSet);
|
|
920
961
|
}
|
|
921
962
|
};
|
|
922
|
-
it(
|
|
963
|
+
it("with a NOP should be possible", function () {
|
|
923
964
|
testRebasing({
|
|
924
965
|
op2: insertUniqueNodeInRoot(),
|
|
925
966
|
compareToSequential: true,
|
|
926
967
|
});
|
|
927
968
|
});
|
|
928
|
-
it(
|
|
969
|
+
it("with independent inserts should be possible", function () {
|
|
929
970
|
testRebasing({
|
|
930
971
|
op1: insertUniqueNodeInRoot(),
|
|
931
972
|
op2: insertUniqueNodeInRoot(),
|
|
932
973
|
compareToSequential: true,
|
|
933
974
|
});
|
|
934
975
|
});
|
|
935
|
-
it(
|
|
936
|
-
var node1 = PropertyFactory.create(
|
|
937
|
-
var node2 = PropertyFactory.create(
|
|
976
|
+
it("with independent removes should be possible", function () {
|
|
977
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
978
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
938
979
|
testRebasing({
|
|
939
980
|
prepare: function (root) {
|
|
940
|
-
root._properties.map.insert(
|
|
941
|
-
root._properties.map.insert(
|
|
981
|
+
root._properties.map.insert("node1", node1);
|
|
982
|
+
root._properties.map.insert("node2", node2);
|
|
942
983
|
},
|
|
943
984
|
op1: function (root) {
|
|
944
|
-
root._properties.map.remove(
|
|
985
|
+
root._properties.map.remove("node1");
|
|
945
986
|
},
|
|
946
987
|
op2: function (root) {
|
|
947
|
-
root._properties.map.remove(
|
|
988
|
+
root._properties.map.remove("node2");
|
|
948
989
|
},
|
|
949
990
|
compareToSequential: true,
|
|
950
991
|
});
|
|
951
992
|
});
|
|
952
|
-
it(
|
|
953
|
-
var node1 = PropertyFactory.create(
|
|
993
|
+
it("with a modify and a remove should possible", function () {
|
|
994
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
954
995
|
testRebasing({
|
|
955
996
|
prepare: function (root) {
|
|
956
|
-
root._properties.map.insert(
|
|
997
|
+
root._properties.map.insert("node1", node1);
|
|
957
998
|
},
|
|
958
999
|
op1: modifyLeaf,
|
|
959
1000
|
op2: removeFirstNodeInRoot,
|
|
960
1001
|
compareToSequential: true,
|
|
961
1002
|
});
|
|
962
1003
|
});
|
|
963
|
-
it(
|
|
964
|
-
var node1 = PropertyFactory.create(
|
|
1004
|
+
it("with a remove and a modify should possible", function () {
|
|
1005
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
965
1006
|
testRebasing({
|
|
966
1007
|
prepare: function (root) {
|
|
967
|
-
root._properties.map.insert(
|
|
1008
|
+
root._properties.map.insert("node1", node1);
|
|
968
1009
|
},
|
|
969
1010
|
op1: removeFirstNodeInRoot,
|
|
970
1011
|
op2: modifyLeaf,
|
|
@@ -972,13 +1013,13 @@ describe('MapProperty', function () {
|
|
|
972
1013
|
checkResult: function (conflicts, changeSet) {
|
|
973
1014
|
expect(conflicts).to.have.length(1);
|
|
974
1015
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE);
|
|
975
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1016
|
+
expect(conflicts[0].path).to.be.equal("map[node1]");
|
|
976
1017
|
expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok;
|
|
977
1018
|
},
|
|
978
1019
|
});
|
|
979
1020
|
});
|
|
980
|
-
it(
|
|
981
|
-
var node1 = PropertyFactory.create(
|
|
1021
|
+
it("reported conflicts should be escaped", function () {
|
|
1022
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
982
1023
|
testRebasing({
|
|
983
1024
|
prepare: function (root) {
|
|
984
1025
|
root._properties.map.insert('"node"', node1);
|
|
@@ -994,17 +1035,17 @@ describe('MapProperty', function () {
|
|
|
994
1035
|
},
|
|
995
1036
|
});
|
|
996
1037
|
});
|
|
997
|
-
it(
|
|
998
|
-
var node1 = PropertyFactory.create(
|
|
1038
|
+
it("with two compatible removes should be possible", function () {
|
|
1039
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
999
1040
|
testRebasing({
|
|
1000
1041
|
prepare: function (root) {
|
|
1001
|
-
root._properties.map.insert(
|
|
1042
|
+
root._properties.map.insert("node1", node1);
|
|
1002
1043
|
},
|
|
1003
1044
|
op1: function (root) {
|
|
1004
|
-
root._properties.map.remove(
|
|
1045
|
+
root._properties.map.remove("node1");
|
|
1005
1046
|
},
|
|
1006
1047
|
op2: function (root) {
|
|
1007
|
-
root._properties.map.remove(
|
|
1048
|
+
root._properties.map.remove("node1");
|
|
1008
1049
|
},
|
|
1009
1050
|
compareToSequential: false,
|
|
1010
1051
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -1012,17 +1053,17 @@ describe('MapProperty', function () {
|
|
|
1012
1053
|
},
|
|
1013
1054
|
});
|
|
1014
1055
|
});
|
|
1015
|
-
it(
|
|
1016
|
-
var node1 = PropertyFactory.create(
|
|
1056
|
+
it("with two indendent recursive modifies should be possible", function () {
|
|
1057
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1017
1058
|
testRebasing({
|
|
1018
1059
|
prepare: function (root) {
|
|
1019
|
-
root._properties.map.insert(
|
|
1060
|
+
root._properties.map.insert("node1", node1);
|
|
1020
1061
|
},
|
|
1021
1062
|
op1: function (root) {
|
|
1022
|
-
root._properties.map.getAsArray()[0]._properties.stringProperty.value =
|
|
1063
|
+
root._properties.map.getAsArray()[0]._properties.stringProperty.value = "a";
|
|
1023
1064
|
},
|
|
1024
1065
|
op2: function (root) {
|
|
1025
|
-
root._properties.map.getAsArray()[0]._properties.stringProperty2.value =
|
|
1066
|
+
root._properties.map.getAsArray()[0]._properties.stringProperty2.value = "a";
|
|
1026
1067
|
},
|
|
1027
1068
|
compareToSequential: true,
|
|
1028
1069
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -1030,129 +1071,128 @@ describe('MapProperty', function () {
|
|
|
1030
1071
|
},
|
|
1031
1072
|
});
|
|
1032
1073
|
});
|
|
1033
|
-
it(
|
|
1034
|
-
var node1 = PropertyFactory.create(
|
|
1074
|
+
it("with two conflicting recursive modifies should be possible and report a conflict", function () {
|
|
1075
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1035
1076
|
testRebasing({
|
|
1036
1077
|
prepare: function (root) {
|
|
1037
|
-
root._properties.map.insert(
|
|
1078
|
+
root._properties.map.insert("node1", node1);
|
|
1038
1079
|
},
|
|
1039
1080
|
op1: function (root) {
|
|
1040
|
-
root._properties.map.getAsArray()[0]._properties.stringProperty.value =
|
|
1081
|
+
root._properties.map.getAsArray()[0]._properties.stringProperty.value = "a";
|
|
1041
1082
|
},
|
|
1042
1083
|
op2: function (root) {
|
|
1043
|
-
root._properties.map.getAsArray()[0]._properties.stringProperty.value =
|
|
1084
|
+
root._properties.map.getAsArray()[0]._properties.stringProperty.value = "a";
|
|
1044
1085
|
},
|
|
1045
1086
|
compareToSequential: true,
|
|
1046
1087
|
checkResult: function (conflicts, changeSet) {
|
|
1047
1088
|
expect(conflicts).to.have.length(1);
|
|
1048
1089
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
1049
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1090
|
+
expect(conflicts[0].path).to.be.equal("map[node1].stringProperty");
|
|
1050
1091
|
},
|
|
1051
1092
|
});
|
|
1052
1093
|
});
|
|
1053
|
-
it(
|
|
1054
|
-
var node1 = PropertyFactory.create(
|
|
1094
|
+
it("with modify followed by remove+insert should work", function () {
|
|
1095
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1055
1096
|
testRebasing({
|
|
1056
1097
|
prepare: function (root) {
|
|
1057
|
-
root._properties.map.insert(
|
|
1098
|
+
root._properties.map.insert("node1", node1);
|
|
1058
1099
|
},
|
|
1059
1100
|
op1: modifyLeaf,
|
|
1060
1101
|
op2: function (root) {
|
|
1061
|
-
root._properties.map.remove(
|
|
1062
|
-
var node2 = PropertyFactory.create(
|
|
1102
|
+
root._properties.map.remove("node1");
|
|
1103
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1063
1104
|
node2._properties.guid.value = node1._properties.guid.value;
|
|
1064
|
-
root._properties.map.insert(
|
|
1105
|
+
root._properties.map.insert("node1", node2);
|
|
1065
1106
|
},
|
|
1066
1107
|
compareToSequential: true,
|
|
1067
1108
|
checkResult: function (conflicts, changeSet) {
|
|
1068
1109
|
expect(conflicts).to.have.length(1);
|
|
1069
1110
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY);
|
|
1070
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1071
|
-
expect(changeSet[
|
|
1111
|
+
expect(conflicts[0].path).to.be.equal("map[node1]");
|
|
1112
|
+
expect(changeSet["map<NamedProperty>"].map).to.have.all.keys("remove", "insert");
|
|
1072
1113
|
},
|
|
1073
1114
|
});
|
|
1074
1115
|
});
|
|
1075
|
-
it(
|
|
1076
|
-
var node1 = PropertyFactory.create(
|
|
1116
|
+
it("with remove+insert followed by modify should report conflict", function () {
|
|
1117
|
+
var node1 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1077
1118
|
testRebasing({
|
|
1078
1119
|
prepare: function (root) {
|
|
1079
|
-
root._properties.map.insert(
|
|
1120
|
+
root._properties.map.insert("node1", node1);
|
|
1080
1121
|
},
|
|
1081
1122
|
op1: function (root) {
|
|
1082
|
-
root._properties.map.remove(
|
|
1083
|
-
var node2 = PropertyFactory.create(
|
|
1123
|
+
root._properties.map.remove("node1");
|
|
1124
|
+
var node2 = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1084
1125
|
node2._properties.guid.value = node1._properties.guid.value;
|
|
1085
|
-
root._properties.map.insert(
|
|
1126
|
+
root._properties.map.insert("node1", node2);
|
|
1086
1127
|
},
|
|
1087
1128
|
op2: modifyLeaf,
|
|
1088
1129
|
compareToSequential: false,
|
|
1089
1130
|
checkResult: function (conflicts, changeSet) {
|
|
1090
1131
|
expect(conflicts).to.have.length(1);
|
|
1091
1132
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFICATION_AFTER_REMOVE_INSERT);
|
|
1092
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1133
|
+
expect(conflicts[0].path).to.be.equal("map[node1]");
|
|
1093
1134
|
},
|
|
1094
1135
|
});
|
|
1095
1136
|
});
|
|
1096
|
-
it(
|
|
1137
|
+
it("with remove+insert followed by remove+insert should report conflict", function () {
|
|
1097
1138
|
testRebasing({
|
|
1098
1139
|
prepare: function (root) {
|
|
1099
|
-
root._properties.map.insert(
|
|
1140
|
+
root._properties.map.insert("node", PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0"));
|
|
1100
1141
|
},
|
|
1101
1142
|
op1: function (root) {
|
|
1102
|
-
root._properties.map.set(
|
|
1143
|
+
root._properties.map.set("node", PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0"));
|
|
1103
1144
|
},
|
|
1104
1145
|
op2: function (root) {
|
|
1105
|
-
root._properties.map.set(
|
|
1146
|
+
root._properties.map.set("node", PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0"));
|
|
1106
1147
|
},
|
|
1107
1148
|
compareToSequential: false,
|
|
1108
1149
|
checkResult: function (conflicts, changeSet) {
|
|
1109
1150
|
expect(conflicts).to.have.length(1);
|
|
1110
1151
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
1111
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1152
|
+
expect(conflicts[0].path).to.be.equal("map[node]");
|
|
1112
1153
|
},
|
|
1113
1154
|
});
|
|
1114
1155
|
});
|
|
1115
|
-
it(
|
|
1156
|
+
it("with conflicting inserts should report conflict", function () {
|
|
1116
1157
|
testRebasing({
|
|
1117
|
-
prepare: function (root) {
|
|
1118
|
-
},
|
|
1158
|
+
prepare: function (root) { },
|
|
1119
1159
|
op1: function (root) {
|
|
1120
|
-
var node = PropertyFactory.create(
|
|
1121
|
-
root._properties.map.insert(
|
|
1160
|
+
var node = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1161
|
+
root._properties.map.insert("node", node);
|
|
1122
1162
|
},
|
|
1123
1163
|
op2: function (root) {
|
|
1124
|
-
var node = PropertyFactory.create(
|
|
1125
|
-
root._properties.map.insert(
|
|
1164
|
+
var node = PropertyFactory.create("autodesk.tests:MapTestPropertyID-1.0.0");
|
|
1165
|
+
root._properties.map.insert("node", node);
|
|
1126
1166
|
},
|
|
1127
1167
|
compareToSequential: false,
|
|
1128
1168
|
checkResult: function (conflicts, changeSet) {
|
|
1129
1169
|
expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok;
|
|
1130
1170
|
expect(conflicts).to.have.length(1);
|
|
1131
1171
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY);
|
|
1132
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1172
|
+
expect(conflicts[0].path).to.be.equal("map[node]");
|
|
1133
1173
|
},
|
|
1134
1174
|
});
|
|
1135
1175
|
});
|
|
1136
|
-
it(
|
|
1176
|
+
it("should report conflicts for nested collections", function () {
|
|
1137
1177
|
testRebasing({
|
|
1138
1178
|
prepare: function (root) {
|
|
1139
|
-
var node = PropertyFactory.create(
|
|
1140
|
-
var testMap = PropertyFactory.create(
|
|
1141
|
-
testMap.set(
|
|
1142
|
-
node.insert(
|
|
1143
|
-
root._properties.map.insert(
|
|
1179
|
+
var node = PropertyFactory.create("NodeProperty");
|
|
1180
|
+
var testMap = PropertyFactory.create("map<Bool>");
|
|
1181
|
+
testMap.set("test", false);
|
|
1182
|
+
node.insert("boolMap", testMap);
|
|
1183
|
+
root._properties.map.insert("node", node);
|
|
1144
1184
|
},
|
|
1145
1185
|
op1: function (root) {
|
|
1146
|
-
root._properties.map.get(
|
|
1186
|
+
root._properties.map.get("node")._properties.boolMap.set("test", true);
|
|
1147
1187
|
},
|
|
1148
1188
|
op2: function (root) {
|
|
1149
|
-
root._properties.map.get(
|
|
1189
|
+
root._properties.map.get("node")._properties.boolMap.set("test", true);
|
|
1150
1190
|
},
|
|
1151
1191
|
compareToSequential: false,
|
|
1152
1192
|
checkResult: function (conflicts, changeSet) {
|
|
1153
1193
|
expect(conflicts).to.have.length(1);
|
|
1154
1194
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
1155
|
-
expect(conflicts[0].path).to.be.equal(
|
|
1195
|
+
expect(conflicts[0].path).to.be.equal("map[node].boolMap[test]");
|
|
1156
1196
|
},
|
|
1157
1197
|
});
|
|
1158
1198
|
});
|