@api-client/core 0.11.10 → 0.12.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/Testing.md +1 -1
- package/bin/plugins/events/EventPlugin.ts +61 -0
- package/bin/plugins/events/assert.ts +193 -0
- package/bin/plugins/events/types.ts +6 -0
- package/bin/test.ts +8 -1
- package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
- package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
- package/build/src/amf/AmfShapeGenerator.js +4 -1
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/AmfTypes.d.ts +2 -2
- package/build/src/amf/AmfTypes.d.ts.map +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/DataValueGenerator.d.ts +15 -15
- package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
- package/build/src/amf/DataValueGenerator.js +14 -14
- package/build/src/amf/DataValueGenerator.js.map +1 -1
- package/build/src/browser.d.ts +12 -9
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +11 -8
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/attach_exception.d.ts +11 -0
- package/build/src/exceptions/attach_exception.d.ts.map +1 -0
- package/build/src/exceptions/attach_exception.js +11 -0
- package/build/src/exceptions/attach_exception.js.map +1 -0
- package/build/src/exceptions/detach_exception.d.ts +11 -0
- package/build/src/exceptions/detach_exception.d.ts.map +1 -0
- package/build/src/exceptions/detach_exception.js +11 -0
- package/build/src/exceptions/detach_exception.js.map +1 -0
- package/build/src/exceptions/remove_model_exception.d.ts +8 -0
- package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_model_exception.js +8 -0
- package/build/src/exceptions/remove_model_exception.js.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.js +8 -0
- package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
- package/build/src/index.d.ts +12 -9
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +11 -8
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +8 -0
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +9 -0
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +2 -2
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.d.ts +601 -0
- package/build/src/modeling/DataDomain.d.ts.map +1 -0
- package/build/src/modeling/DataDomain.js +1142 -0
- package/build/src/modeling/DataDomain.js.map +1 -0
- package/build/src/modeling/DataFormat.d.ts +42 -41
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +30 -131
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +281 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
- package/build/src/modeling/DomainAssociation.js +440 -0
- package/build/src/modeling/DomainAssociation.js.map +1 -0
- package/build/src/modeling/DomainElement.d.ts +33 -0
- package/build/src/modeling/DomainElement.d.ts.map +1 -0
- package/build/src/modeling/DomainElement.js +32 -0
- package/build/src/modeling/DomainElement.js.map +1 -0
- package/build/src/modeling/DomainEntity.d.ts +383 -0
- package/build/src/modeling/DomainEntity.d.ts.map +1 -0
- package/build/src/modeling/DomainEntity.js +718 -0
- package/build/src/modeling/DomainEntity.js.map +1 -0
- package/build/src/modeling/DomainFile.d.ts +25 -0
- package/build/src/modeling/DomainFile.d.ts.map +1 -0
- package/build/src/modeling/DomainFile.js +86 -0
- package/build/src/modeling/DomainFile.js.map +1 -0
- package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +201 -132
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +226 -0
- package/build/src/modeling/DomainModel.d.ts.map +1 -0
- package/build/src/modeling/DomainModel.js +401 -0
- package/build/src/modeling/DomainModel.js.map +1 -0
- package/build/src/modeling/DomainNamespace.d.ts +268 -0
- package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
- package/build/src/modeling/DomainNamespace.js +512 -0
- package/build/src/modeling/DomainNamespace.js.map +1 -0
- package/build/src/modeling/DomainProperty.d.ts +281 -0
- package/build/src/modeling/DomainProperty.d.ts.map +1 -0
- package/build/src/modeling/DomainProperty.js +560 -0
- package/build/src/modeling/DomainProperty.js.map +1 -0
- package/build/src/modeling/DomainSerialization.d.ts +40 -0
- package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
- package/build/src/modeling/DomainSerialization.js +288 -0
- package/build/src/modeling/DomainSerialization.js.map +1 -0
- package/build/src/modeling/DomainVersioning.d.ts +17 -0
- package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
- package/build/src/modeling/DomainVersioning.js +124 -0
- package/build/src/modeling/DomainVersioning.js.map +1 -0
- package/build/src/modeling/GraphUtils.d.ts +8 -0
- package/build/src/modeling/GraphUtils.d.ts.map +1 -0
- package/build/src/modeling/GraphUtils.js +26 -0
- package/build/src/modeling/GraphUtils.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.js +492 -0
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
- package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
- package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +9 -6
- package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
- package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
- package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
- package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +19 -18
- package/build/src/modeling/legacy/DataEntity.js.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
- package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
- package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
- package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +7 -6
- package/build/src/modeling/legacy/DataModel.js.map +1 -0
- package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
- package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +7 -3
- package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
- package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
- package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
- package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +8 -5
- package/build/src/modeling/legacy/DataProperty.js.map +1 -0
- package/build/src/modeling/observed.d.ts +67 -0
- package/build/src/modeling/observed.d.ts.map +1 -0
- package/build/src/modeling/observed.js +230 -0
- package/build/src/modeling/observed.js.map +1 -0
- package/build/src/modeling/types.d.ts +165 -1
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/Thing.d.ts +26 -5
- package/build/src/models/Thing.d.ts.map +1 -1
- package/build/src/models/Thing.js +193 -91
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/kinds.d.ts +31 -6
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +31 -6
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/DataFile.d.ts +3 -1
- package/build/src/models/store/DataFile.d.ts.map +1 -1
- package/build/src/models/store/DataFile.js +2 -0
- package/build/src/models/store/DataFile.js.map +1 -1
- package/build/src/models/types.d.ts +12 -0
- package/build/src/models/types.d.ts.map +1 -0
- package/build/src/models/types.js +2 -0
- package/build/src/models/types.js.map +1 -0
- package/build/src/runtime/store/FilesSdk.d.ts +2 -2
- package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/data/models/example-generator-api.json +26 -26
- package/package.json +20 -6
- package/readme.md +1 -1
- package/src/amf/AmfShapeGenerator.ts +7 -4
- package/src/amf/AmfTypes.ts +2 -2
- package/src/amf/DataValueGenerator.ts +21 -21
- package/src/exceptions/attach_exception.ts +11 -0
- package/src/exceptions/detach_exception.ts +11 -0
- package/src/exceptions/remove_model_exception.ts +8 -0
- package/src/exceptions/remove_namespace_exception.ts +8 -0
- package/src/modeling/Bindings.ts +2 -2
- package/src/modeling/DataDomain.ts +1221 -0
- package/src/modeling/DataFormat.ts +54 -163
- package/src/modeling/DomainAssociation.ts +476 -0
- package/src/modeling/DomainElement.ts +50 -0
- package/src/modeling/DomainEntity.ts +769 -0
- package/src/modeling/DomainFile.ts +94 -0
- package/src/modeling/DomainImpactAnalysis.ts +218 -144
- package/src/modeling/DomainModel.ts +421 -0
- package/src/modeling/DomainNamespace.ts +537 -0
- package/src/modeling/DomainProperty.ts +548 -0
- package/src/modeling/DomainSerialization.ts +312 -0
- package/src/modeling/DomainVersioning.ts +144 -0
- package/src/modeling/GraphUtils.ts +28 -0
- package/src/modeling/amf/ShapeGenerator.ts +552 -0
- package/src/modeling/graph.md +115 -0
- package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +13 -8
- package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +28 -23
- package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +4 -3
- package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
- package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +10 -8
- package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +23 -5
- package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +15 -7
- package/src/modeling/observed.ts +267 -0
- package/src/modeling/types.ts +174 -1
- package/src/models/Thing.ts +70 -5
- package/src/models/kinds.ts +32 -6
- package/src/models/store/DataFile.ts +3 -1
- package/src/models/types.ts +11 -0
- package/src/runtime/store/FilesSdk.ts +2 -6
- package/tests/unit/amf/data_value_generator.spec.ts +15 -15
- package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
- package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
- package/tests/unit/modeling/data_domain.spec.ts +444 -0
- package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
- package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
- package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
- package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
- package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
- package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
- package/tests/unit/modeling/domain.property.spec.ts +822 -0
- package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
- package/tests/unit/modeling/domain_entity.spec.ts +730 -0
- package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
- package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
- package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
- package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
- package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
- package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
- package/tests/unit/modeling/domain_model.spec.ts +568 -0
- package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
- package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
- package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
- package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
- package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
- package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
- package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
- package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
- package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
- package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
- package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
- package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
- package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
- package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
- package/tests/unit/models/File/new.spec.ts +1 -1
- package/tests/unit/models/HttpProject.spec.ts +3 -3
- package/tsconfig.node.json +35 -0
- package/build/src/modeling/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/DataAssociation.js.map +0 -1
- package/build/src/modeling/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/DataEntity.js.map +0 -1
- package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/DataModel.d.ts.map +0 -1
- package/build/src/modeling/DataModel.js.map +0 -1
- package/build/src/modeling/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/DataNamespace.js.map +0 -1
- package/build/src/modeling/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/DataProperty.js.map +0 -1
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { DataDomain } from '../../../src/modeling/DataDomain.js'
|
|
3
|
+
import { DomainNamespace } from '../../../src/modeling/DomainNamespace.js'
|
|
4
|
+
|
|
5
|
+
test.group('DataDomain.addNamespace()', () => {
|
|
6
|
+
test('addNamespace adds a namespace to the graph', ({ assert }) => {
|
|
7
|
+
const dataDomain = new DataDomain()
|
|
8
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
9
|
+
assert.instanceOf(namespace, DomainNamespace)
|
|
10
|
+
assert.isTrue(dataDomain.graph.hasNode(namespace.key))
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('addNamespace adds a namespace to the graph with a parent', ({ assert }) => {
|
|
14
|
+
const dataDomain = new DataDomain()
|
|
15
|
+
const pNs = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
16
|
+
const cNs = dataDomain.addNamespace({ key: 'child-ns' }, pNs.key)
|
|
17
|
+
assert.instanceOf(cNs, DomainNamespace)
|
|
18
|
+
assert.isTrue(dataDomain.graph.hasNode(cNs.key))
|
|
19
|
+
assert.equal(dataDomain.graph.parent(cNs.key), pNs.key)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('addNamespace throws an error if parent namespace does not exist', ({ assert }) => {
|
|
23
|
+
const dataDomain = new DataDomain()
|
|
24
|
+
assert.throws(() => {
|
|
25
|
+
dataDomain.addNamespace({ key: 'child-ns' }, 'non-existent-parent')
|
|
26
|
+
}, 'Parent namespace non-existent-parent does not exist')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('addNamespace notifies change', async ({ assert }) => {
|
|
30
|
+
const dataDomain = new DataDomain()
|
|
31
|
+
dataDomain.addNamespace({ key: 'test-ns' })
|
|
32
|
+
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('addNamespace adds a namespace to the root of the graph', ({ assert }) => {
|
|
36
|
+
const dataDomain = new DataDomain()
|
|
37
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
38
|
+
assert.instanceOf(namespace, DomainNamespace)
|
|
39
|
+
assert.isTrue(dataDomain.graph.hasNode(namespace.key))
|
|
40
|
+
assert.isUndefined(dataDomain.graph.parent(namespace.key))
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('addNamespace adds a namespace to a parent namespace', ({ assert }) => {
|
|
44
|
+
const dataDomain = new DataDomain()
|
|
45
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
46
|
+
const childNamespace = dataDomain.addNamespace({ key: 'child-ns' }, parentNamespace.key)
|
|
47
|
+
assert.instanceOf(childNamespace, DomainNamespace)
|
|
48
|
+
assert.isTrue(dataDomain.graph.hasNode(childNamespace.key))
|
|
49
|
+
assert.equal(dataDomain.graph.parent(childNamespace.key), parentNamespace.key)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('addNamespace adds a namespace with default values', ({ assert }) => {
|
|
53
|
+
const dataDomain = new DataDomain()
|
|
54
|
+
const namespace = dataDomain.addNamespace({})
|
|
55
|
+
assert.instanceOf(namespace, DomainNamespace)
|
|
56
|
+
assert.isTrue(dataDomain.graph.hasNode(namespace.key))
|
|
57
|
+
assert.isUndefined(dataDomain.graph.parent(namespace.key))
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('addNamespace adds to the fields list', ({ assert }) => {
|
|
61
|
+
const dataDomain = new DataDomain()
|
|
62
|
+
const namespace = dataDomain.addNamespace({})
|
|
63
|
+
assert.lengthOf(dataDomain.fields, 1)
|
|
64
|
+
const [field] = dataDomain.fields
|
|
65
|
+
assert.equal(field.key, namespace.key)
|
|
66
|
+
assert.equal(field.type, 'namespace')
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test.group('DataDomain.removeNamespace()', () => {
|
|
71
|
+
test('removes a namespace from the graph', ({ assert }) => {
|
|
72
|
+
const root = new DataDomain()
|
|
73
|
+
const namespace = root.addNamespace({ key: 'test-ns' })
|
|
74
|
+
root.removeNamespace(namespace.key)
|
|
75
|
+
assert.isFalse(root.graph.hasNode(namespace.key))
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('removes a nested namespace from the graph', ({ assert }) => {
|
|
79
|
+
const root = new DataDomain()
|
|
80
|
+
const n1 = root.addNamespace({ key: 'parent-ns' })
|
|
81
|
+
const n2 = root.addNamespace({ key: 'child-ns' }, n1.key)
|
|
82
|
+
root.removeNamespace(n2.key)
|
|
83
|
+
assert.isFalse(root.graph.hasNode(n2.key))
|
|
84
|
+
assert.isTrue(root.graph.hasNode(n1.key))
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('removeNamespace throws an error if namespace does not exist', ({ assert }) => {
|
|
88
|
+
const root = new DataDomain()
|
|
89
|
+
assert.throws(() => {
|
|
90
|
+
root.removeNamespace('non-existent-ns')
|
|
91
|
+
}, 'Namespace non-existent-ns does not exist')
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('removeNamespace notifies change', async ({ assert }) => {
|
|
95
|
+
const root = new DataDomain()
|
|
96
|
+
const n1 = root.addNamespace({ key: 'test-ns' })
|
|
97
|
+
root.removeNamespace(n1.key)
|
|
98
|
+
await assert.dispatches(root, 'change', { timeout: 20 })
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('removeNamespace removes a namespace from the root of the graph', ({ assert }) => {
|
|
102
|
+
const root = new DataDomain()
|
|
103
|
+
const n1 = root.addNamespace({ key: 'test-ns' })
|
|
104
|
+
root.removeNamespace(n1.key)
|
|
105
|
+
assert.isFalse(root.graph.hasNode(n1.key))
|
|
106
|
+
assert.isUndefined(root.listGraphNamespaces().next().value)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('removeNamespace removes a namespace from a parent namespace', ({ assert }) => {
|
|
110
|
+
const root = new DataDomain()
|
|
111
|
+
const n1 = root.addNamespace({ key: 'parent-ns' })
|
|
112
|
+
const n2 = root.addNamespace({ key: 'child-ns' }, n1.key)
|
|
113
|
+
root.removeNamespace(n2.key)
|
|
114
|
+
assert.isFalse(root.graph.hasNode(n2.key))
|
|
115
|
+
assert.equal(root.graph.parent(n2.key), undefined)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test('removeNamespace removes a namespace with children', ({ assert }) => {
|
|
119
|
+
const dataDomain = new DataDomain()
|
|
120
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
121
|
+
const childNamespace = dataDomain.addNamespace({ key: 'child-ns' }, parentNamespace.key)
|
|
122
|
+
const grandChildNamespace = dataDomain.addNamespace({ key: 'grandchild-ns' }, childNamespace.key)
|
|
123
|
+
dataDomain.removeNamespace(parentNamespace.key)
|
|
124
|
+
assert.isFalse(dataDomain.graph.hasNode(parentNamespace.key))
|
|
125
|
+
assert.isFalse(dataDomain.graph.hasNode(childNamespace.key))
|
|
126
|
+
assert.isFalse(dataDomain.graph.hasNode(grandChildNamespace.key))
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('removeNamespace removes a namespace with models', ({ assert }) => {
|
|
130
|
+
const dataDomain = new DataDomain()
|
|
131
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
132
|
+
const model = dataDomain.addModel({ key: 'test-model' }, parentNamespace.key)
|
|
133
|
+
dataDomain.removeNamespace(parentNamespace.key)
|
|
134
|
+
assert.isFalse(dataDomain.graph.hasNode(parentNamespace.key))
|
|
135
|
+
assert.isFalse(dataDomain.graph.hasNode(model.key))
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test('removeNamespace removes the whole domain structure', ({ assert }) => {
|
|
139
|
+
const d1 = new DataDomain()
|
|
140
|
+
const ns1 = d1.addNamespace({ key: 'ns1' })
|
|
141
|
+
const ns2 = ns1.addNamespace({ key: 'ns2' })
|
|
142
|
+
const m1 = ns2.addModel({ key: 'model1' })
|
|
143
|
+
const e1 = m1.addEntity({ key: 'entity1' })
|
|
144
|
+
const e2 = m1.addEntity({ key: 'entity2' })
|
|
145
|
+
const p1 = e1.addProperty({ key: 'property1' })
|
|
146
|
+
const a1 = e1.addAssociation({ key: e2.key })
|
|
147
|
+
d1.removeNamespace(ns1.key)
|
|
148
|
+
assert.isFalse(d1.graph.hasNode(ns1.key))
|
|
149
|
+
assert.isFalse(d1.graph.hasNode(ns2.key))
|
|
150
|
+
assert.isFalse(d1.graph.hasNode(m1.key))
|
|
151
|
+
assert.isFalse(d1.graph.hasNode(e1.key))
|
|
152
|
+
assert.isFalse(d1.graph.hasNode(e2.key))
|
|
153
|
+
assert.isFalse(d1.graph.hasNode(p1.key))
|
|
154
|
+
assert.isFalse(d1.graph.hasNode(a1.key))
|
|
155
|
+
assert.deepEqual([...d1.graph.edges()], [])
|
|
156
|
+
assert.deepEqual([...d1.graph.nodes()], [])
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
test('removeNamespace throws an error if key is not a namespace', ({ assert }) => {
|
|
160
|
+
const dataDomain = new DataDomain()
|
|
161
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
162
|
+
assert.throws(() => {
|
|
163
|
+
dataDomain.removeNamespace(model.key)
|
|
164
|
+
}, `Namespace ${model.key} not found`)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
test('removeNamespace removes from fields', ({ assert }) => {
|
|
168
|
+
const root = new DataDomain()
|
|
169
|
+
const n1 = root.addNamespace()
|
|
170
|
+
root.removeNamespace(n1.key)
|
|
171
|
+
assert.deepEqual(root.fields, [])
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test.group('DataDomain.listNamespaces()', () => {
|
|
176
|
+
test('lists all namespaces in the data domain', ({ assert }) => {
|
|
177
|
+
const dataDomain = new DataDomain()
|
|
178
|
+
const namespace1 = dataDomain.addNamespace()
|
|
179
|
+
const namespace2 = dataDomain.addNamespace()
|
|
180
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
181
|
+
assert.lengthOf(namespaces, 2)
|
|
182
|
+
assert.deepInclude(namespaces, namespace1)
|
|
183
|
+
assert.deepInclude(namespaces, namespace2)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
test('returns an empty array if there are no namespaces', ({ assert }) => {
|
|
187
|
+
const dataDomain = new DataDomain()
|
|
188
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
189
|
+
assert.lengthOf(namespaces, 0)
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('returns only namespaces', ({ assert }) => {
|
|
193
|
+
const dataDomain = new DataDomain()
|
|
194
|
+
const namespace1 = dataDomain.addNamespace()
|
|
195
|
+
dataDomain.addModel()
|
|
196
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
197
|
+
assert.lengthOf(namespaces, 1)
|
|
198
|
+
assert.deepInclude(namespaces, namespace1)
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
test('namespaces in the list are of type DomainNamespace', ({ assert }) => {
|
|
202
|
+
const dataDomain = new DataDomain()
|
|
203
|
+
dataDomain.addNamespace()
|
|
204
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
205
|
+
assert.instanceOf(namespaces[0], DomainNamespace)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
test('lists namespaces in the order they were added', ({ assert }) => {
|
|
209
|
+
const dataDomain = new DataDomain()
|
|
210
|
+
const namespace1 = dataDomain.addNamespace()
|
|
211
|
+
const namespace2 = dataDomain.addNamespace()
|
|
212
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
213
|
+
assert.deepEqual(namespaces, [namespace1, namespace2])
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
test('lists namespaces when there are no namespaces', ({ assert }) => {
|
|
217
|
+
const dataDomain = new DataDomain()
|
|
218
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
219
|
+
assert.deepEqual(namespaces, [])
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
test('lists namespaces when there are other domain elements', ({ assert }) => {
|
|
223
|
+
const dataDomain = new DataDomain()
|
|
224
|
+
const namespace1 = dataDomain.addNamespace()
|
|
225
|
+
dataDomain.addModel()
|
|
226
|
+
const namespaces = [...dataDomain.listNamespaces()]
|
|
227
|
+
assert.deepEqual(namespaces, [namespace1])
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
test.group('DataDomain.hasNamespaces()', () => {
|
|
232
|
+
test('returns true if there are child namespaces', ({ assert }) => {
|
|
233
|
+
const dataDomain = new DataDomain()
|
|
234
|
+
dataDomain.addNamespace()
|
|
235
|
+
assert.isTrue(dataDomain.hasNamespaces())
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
test('returns false if there are no child namespaces', ({ assert }) => {
|
|
239
|
+
const dataDomain = new DataDomain()
|
|
240
|
+
assert.isFalse(dataDomain.hasNamespaces())
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
test('returns false if there are only models', ({ assert }) => {
|
|
244
|
+
const dataDomain = new DataDomain()
|
|
245
|
+
dataDomain.addModel()
|
|
246
|
+
assert.isFalse(dataDomain.hasNamespaces())
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
test('returns true if there are both models and namespaces', ({ assert }) => {
|
|
250
|
+
const dataDomain = new DataDomain()
|
|
251
|
+
dataDomain.addNamespace()
|
|
252
|
+
dataDomain.addModel()
|
|
253
|
+
assert.isTrue(dataDomain.hasNamespaces())
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
test('returns false if the data domain has no fields', ({ assert }) => {
|
|
257
|
+
const dataDomain = new DataDomain()
|
|
258
|
+
dataDomain.fields = []
|
|
259
|
+
assert.isFalse(dataDomain.hasNamespaces())
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
test.group('DataDomain.listGraphNamespaces()', () => {
|
|
264
|
+
test('lists all namespaces in the graph', ({ assert }) => {
|
|
265
|
+
const root = new DataDomain()
|
|
266
|
+
const n1 = root.addNamespace({ key: 'ns1' })
|
|
267
|
+
const n2 = root.addNamespace({ key: 'ns2' })
|
|
268
|
+
const namespaces = [...root.listGraphNamespaces()]
|
|
269
|
+
assert.lengthOf(namespaces, 2)
|
|
270
|
+
assert.deepInclude(namespaces, n1)
|
|
271
|
+
assert.deepInclude(namespaces, n2)
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
test('lists all namespaces in the graph with a parent', ({ assert }) => {
|
|
275
|
+
const root = new DataDomain()
|
|
276
|
+
const n1 = root.addNamespace({ key: 'parent-ns' })
|
|
277
|
+
const n2 = root.addNamespace({ key: 'ns1' }, n1.key)
|
|
278
|
+
root.addNamespace({ key: 'ns2' })
|
|
279
|
+
const namespaces = [...root.listGraphNamespaces(n1.key)]
|
|
280
|
+
assert.lengthOf(namespaces, 1)
|
|
281
|
+
assert.deepInclude(namespaces, n2)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
test('returns an empty array if there are no namespaces', ({ assert }) => {
|
|
285
|
+
const root = new DataDomain()
|
|
286
|
+
const namespaces = [...root.listGraphNamespaces()]
|
|
287
|
+
assert.lengthOf(namespaces, 0)
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
test('returns an empty array if the parent does not exist', ({ assert }) => {
|
|
291
|
+
const root = new DataDomain()
|
|
292
|
+
const namespaces = [...root.listGraphNamespaces('non-existent-parent')]
|
|
293
|
+
assert.lengthOf(namespaces, 0)
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
test('returns only namespaces', ({ assert }) => {
|
|
297
|
+
const root = new DataDomain()
|
|
298
|
+
const n1 = root.addNamespace({ key: 'ns1' })
|
|
299
|
+
root.addModel({ key: 'model1' })
|
|
300
|
+
const namespaces = [...root.listGraphNamespaces()]
|
|
301
|
+
assert.lengthOf(namespaces, 1)
|
|
302
|
+
assert.deepInclude(namespaces, n1)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
test('returns only namespaces for the given parent', ({ assert }) => {
|
|
306
|
+
const root = new DataDomain()
|
|
307
|
+
const n1 = root.addNamespace({ key: 'parent-ns' })
|
|
308
|
+
const n2 = root.addNamespace({ key: 'ns1' }, n1.key)
|
|
309
|
+
root.addNamespace({ key: 'ns2' })
|
|
310
|
+
root.addModel({ key: 'model1' }, n1.key)
|
|
311
|
+
root.addModel({ key: 'model2' })
|
|
312
|
+
const namespaces = [...root.listGraphNamespaces(n1.key)]
|
|
313
|
+
assert.lengthOf(namespaces, 1)
|
|
314
|
+
assert.deepInclude(namespaces, n2)
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
test('namespaces in the list are of type DomainNamespace', ({ assert }) => {
|
|
318
|
+
const dataDomain = new DataDomain()
|
|
319
|
+
dataDomain.addNamespace({ key: 'ns1' })
|
|
320
|
+
const namespaces = [...dataDomain.listGraphNamespaces()]
|
|
321
|
+
assert.instanceOf(namespaces[0], DomainNamespace)
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
test('lists namespaces from the root when no parent is provided', ({ assert }) => {
|
|
325
|
+
const root = new DataDomain()
|
|
326
|
+
const n1 = root.addNamespace({ key: 'ns1' })
|
|
327
|
+
const n2 = root.addNamespace({ key: 'ns2' })
|
|
328
|
+
const n3 = root.addNamespace({ key: 'parent-ns' })
|
|
329
|
+
root.addNamespace({ key: 'ns3' }, n3.key)
|
|
330
|
+
const namespaces = [...root.listGraphNamespaces()]
|
|
331
|
+
assert.lengthOf(namespaces, 3)
|
|
332
|
+
assert.deepInclude(namespaces, n1)
|
|
333
|
+
assert.deepInclude(namespaces, n2)
|
|
334
|
+
assert.deepInclude(namespaces, n3)
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
test('lists namespaces from a parent namespace when provided', ({ assert }) => {
|
|
338
|
+
const dataDomain = new DataDomain()
|
|
339
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
340
|
+
const namespace1 = dataDomain.addNamespace({ key: 'ns1' }, parentNamespace.key)
|
|
341
|
+
dataDomain.addNamespace({ key: 'ns2' })
|
|
342
|
+
|
|
343
|
+
const namespaces = [...dataDomain.listGraphNamespaces(parentNamespace.key)]
|
|
344
|
+
assert.lengthOf(namespaces, 1)
|
|
345
|
+
assert.deepInclude(namespaces, namespace1)
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
test('lists namespaces from a parent namespace when provided and the parent has no namespaces', ({ assert }) => {
|
|
349
|
+
const dataDomain = new DataDomain()
|
|
350
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
351
|
+
|
|
352
|
+
const namespaces = [...dataDomain.listGraphNamespaces(parentNamespace.key)]
|
|
353
|
+
assert.lengthOf(namespaces, 0)
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
test('lists namespaces from a parent namespace when provided and the parent is not a namespace', ({ assert }) => {
|
|
357
|
+
const dataDomain = new DataDomain()
|
|
358
|
+
const model = dataDomain.addModel({ key: 'model-1' })
|
|
359
|
+
|
|
360
|
+
const namespaces = [...dataDomain.listGraphNamespaces(model.key)]
|
|
361
|
+
assert.lengthOf(namespaces, 0)
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
test('lists namespaces from a parent namespace when provided and the parent is not in the graph', ({ assert }) => {
|
|
365
|
+
const dataDomain = new DataDomain()
|
|
366
|
+
|
|
367
|
+
const namespaces = [...dataDomain.listGraphNamespaces('non-existent-parent')]
|
|
368
|
+
assert.lengthOf(namespaces, 0)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
test('lists all children for the root, excluding foreign namespaces', ({ assert }) => {
|
|
372
|
+
const domain1 = new DataDomain()
|
|
373
|
+
const ns1 = domain1.addNamespace({ key: 'ns1' })
|
|
374
|
+
|
|
375
|
+
const domain2 = new DataDomain()
|
|
376
|
+
domain2.addNamespace({ key: 'ns2' })
|
|
377
|
+
domain2.info.version = '1.0.0'
|
|
378
|
+
domain1.registerForeignDomain(domain2)
|
|
379
|
+
|
|
380
|
+
const children = [...domain1.listGraphNamespaces()]
|
|
381
|
+
assert.lengthOf(children, 1)
|
|
382
|
+
assert.deepInclude(children, ns1)
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
test('lists all children for a namespace, excluding foreign namespaces', ({ assert }) => {
|
|
386
|
+
const domain1 = new DataDomain()
|
|
387
|
+
const ns1 = domain1.addNamespace({ key: 'ns1' })
|
|
388
|
+
const ns2 = ns1.addNamespace({ key: 'ns2' })
|
|
389
|
+
|
|
390
|
+
const domain2 = new DataDomain()
|
|
391
|
+
domain2.addNamespace({ key: 'ns3' })
|
|
392
|
+
domain2.info.version = '1.0.0'
|
|
393
|
+
domain1.registerForeignDomain(domain2)
|
|
394
|
+
|
|
395
|
+
const children = [...domain1.listGraphNamespaces(ns1.key)]
|
|
396
|
+
assert.lengthOf(children, 1)
|
|
397
|
+
assert.deepInclude(children, ns2)
|
|
398
|
+
})
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
test.group('DataDomain.findNamespace()', () => {
|
|
402
|
+
test('finds a namespace by its key', ({ assert }) => {
|
|
403
|
+
const dataDomain = new DataDomain()
|
|
404
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
405
|
+
const foundNamespace = dataDomain.findNamespace('test-ns')
|
|
406
|
+
assert.deepEqual(foundNamespace, namespace)
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
test('returns undefined if namespace does not exist', ({ assert }) => {
|
|
410
|
+
const dataDomain = new DataDomain()
|
|
411
|
+
const foundNamespace = dataDomain.findNamespace('non-existent-ns')
|
|
412
|
+
assert.isUndefined(foundNamespace)
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
test('returns undefined if key is not a namespace', ({ assert }) => {
|
|
416
|
+
const dataDomain = new DataDomain()
|
|
417
|
+
const model = dataDomain.addModel({ key: 'test-model' })
|
|
418
|
+
const foundNamespace = dataDomain.findNamespace(model.key)
|
|
419
|
+
assert.isUndefined(foundNamespace)
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
test('returns undefined if key is undefined', ({ assert }) => {
|
|
423
|
+
const dataDomain = new DataDomain()
|
|
424
|
+
// @ts-expect-error For testing purposes
|
|
425
|
+
const foundNamespace = dataDomain.findNamespace(undefined)
|
|
426
|
+
assert.isUndefined(foundNamespace)
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
test('returns undefined if key is null', ({ assert }) => {
|
|
430
|
+
const dataDomain = new DataDomain()
|
|
431
|
+
// @ts-expect-error For testing purposes
|
|
432
|
+
const foundNamespace = dataDomain.findNamespace(null)
|
|
433
|
+
assert.isUndefined(foundNamespace)
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
test('returns undefined if key is an empty string', ({ assert }) => {
|
|
437
|
+
const dataDomain = new DataDomain()
|
|
438
|
+
const foundNamespace = dataDomain.findNamespace('')
|
|
439
|
+
assert.isUndefined(foundNamespace)
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
test('returns undefined if key is a number', ({ assert }) => {
|
|
443
|
+
const dataDomain = new DataDomain()
|
|
444
|
+
// @ts-expect-error For testing purposes
|
|
445
|
+
const foundNamespace = dataDomain.findNamespace(123)
|
|
446
|
+
assert.isUndefined(foundNamespace)
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
test('returns undefined if key is a boolean', ({ assert }) => {
|
|
450
|
+
const dataDomain = new DataDomain()
|
|
451
|
+
// @ts-expect-error For testing purposes
|
|
452
|
+
const foundNamespace = dataDomain.findNamespace(true)
|
|
453
|
+
assert.isUndefined(foundNamespace)
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
test('returns undefined if key is an object', ({ assert }) => {
|
|
457
|
+
const dataDomain = new DataDomain()
|
|
458
|
+
// @ts-expect-error For testing purposes
|
|
459
|
+
const foundNamespace = dataDomain.findNamespace({})
|
|
460
|
+
assert.isUndefined(foundNamespace)
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
test('returns undefined if key is an array', ({ assert }) => {
|
|
464
|
+
const dataDomain = new DataDomain()
|
|
465
|
+
// @ts-expect-error For testing purposes
|
|
466
|
+
const foundNamespace = dataDomain.findNamespace([])
|
|
467
|
+
assert.isUndefined(foundNamespace)
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
test('returns undefined if key is a function', ({ assert }) => {
|
|
471
|
+
const dataDomain = new DataDomain()
|
|
472
|
+
// @ts-expect-error For testing purposes
|
|
473
|
+
const foundNamespace = dataDomain.findNamespace(() => {})
|
|
474
|
+
assert.isUndefined(foundNamespace)
|
|
475
|
+
})
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
test.group('DataDomain.moveNamespace()', () => {
|
|
479
|
+
test('moves a namespace from the root to a parent namespace', ({ assert }) => {
|
|
480
|
+
const dataDomain = new DataDomain()
|
|
481
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
482
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
483
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace.key)
|
|
484
|
+
assert.equal(dataDomain.graph.parent(namespace.key), parentNamespace.key)
|
|
485
|
+
const children = [...parentNamespace.listNamespaces()]
|
|
486
|
+
assert.deepEqual(children, [namespace])
|
|
487
|
+
})
|
|
488
|
+
|
|
489
|
+
test('moves a namespace from a parent namespace to the root', ({ assert }) => {
|
|
490
|
+
const dataDomain = new DataDomain()
|
|
491
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
492
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace.key)
|
|
493
|
+
dataDomain.moveNamespace(namespace.key)
|
|
494
|
+
assert.equal(dataDomain.graph.parent(namespace.key), undefined)
|
|
495
|
+
assert.deepEqual([...parentNamespace.listNamespaces()], [])
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
test('moves a namespace from one parent namespace to another', ({ assert }) => {
|
|
499
|
+
const dataDomain = new DataDomain()
|
|
500
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
501
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
502
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace1.key)
|
|
503
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace2.key)
|
|
504
|
+
assert.equal(dataDomain.graph.parent(namespace.key), parentNamespace2.key)
|
|
505
|
+
assert.deepEqual([...parentNamespace1.listNamespaces()], [])
|
|
506
|
+
assert.deepEqual([...parentNamespace2.listNamespaces()], [namespace])
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
test('throws an error if namespace does not exist', ({ assert }) => {
|
|
510
|
+
const dataDomain = new DataDomain()
|
|
511
|
+
assert.throws(() => {
|
|
512
|
+
dataDomain.moveNamespace('non-existent-ns', 'parent-ns')
|
|
513
|
+
}, 'Namespace non-existent-ns does not exist')
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
test('throws an error if parent namespace does not exist', ({ assert }) => {
|
|
517
|
+
const dataDomain = new DataDomain()
|
|
518
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
519
|
+
assert.throws(() => {
|
|
520
|
+
dataDomain.moveNamespace(namespace.key, 'non-existent-parent')
|
|
521
|
+
}, 'Parent namespace non-existent-parent does not exist')
|
|
522
|
+
})
|
|
523
|
+
|
|
524
|
+
test('throws an error if namespace is moved to itself', ({ assert }) => {
|
|
525
|
+
const dataDomain = new DataDomain()
|
|
526
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
527
|
+
assert.throws(() => {
|
|
528
|
+
dataDomain.moveNamespace(namespace.key, namespace.key)
|
|
529
|
+
}, 'Cannot move a namespace to itself')
|
|
530
|
+
})
|
|
531
|
+
|
|
532
|
+
test('throws an error if namespace is moved to its own child', ({ assert }) => {
|
|
533
|
+
const dataDomain = new DataDomain()
|
|
534
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
535
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace.key)
|
|
536
|
+
assert.throws(() => {
|
|
537
|
+
dataDomain.moveNamespace(parentNamespace.key, namespace.key)
|
|
538
|
+
}, 'Cannot move a namespace to its own child')
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
test('throws an error if namespace is moved to a foreign domain', ({ assert }) => {
|
|
542
|
+
const dataDomain1 = new DataDomain()
|
|
543
|
+
const dataDomain2 = new DataDomain()
|
|
544
|
+
|
|
545
|
+
const namespace = dataDomain1.addNamespace({ key: 'test-ns' })
|
|
546
|
+
const foreignNamespace = dataDomain2.addNamespace({ key: 'foreign-ns' })
|
|
547
|
+
|
|
548
|
+
dataDomain2.info.version = '1.0.0'
|
|
549
|
+
dataDomain1.registerForeignDomain(dataDomain2)
|
|
550
|
+
|
|
551
|
+
assert.throws(() => {
|
|
552
|
+
dataDomain1.moveNamespace(namespace.key, `${dataDomain2.key}:${foreignNamespace.key}`)
|
|
553
|
+
}, 'Cannot move a namespace to a foreign domain')
|
|
554
|
+
})
|
|
555
|
+
|
|
556
|
+
test('throws an error if namespace is moved from a foreign domain', ({ assert }) => {
|
|
557
|
+
const dataDomain1 = new DataDomain()
|
|
558
|
+
const dataDomain2 = new DataDomain()
|
|
559
|
+
|
|
560
|
+
const namespace = dataDomain1.addNamespace({ key: 'test-ns' })
|
|
561
|
+
const foreignNamespace = dataDomain2.addNamespace({ key: 'foreign-ns' })
|
|
562
|
+
|
|
563
|
+
dataDomain2.info.version = '1.0.0'
|
|
564
|
+
dataDomain1.registerForeignDomain(dataDomain2)
|
|
565
|
+
|
|
566
|
+
assert.throws(() => {
|
|
567
|
+
dataDomain1.moveNamespace(`${dataDomain2.key}:${foreignNamespace.key}`, namespace.key)
|
|
568
|
+
}, 'Cannot move a namespace from a foreign domain')
|
|
569
|
+
})
|
|
570
|
+
|
|
571
|
+
test('moveNamespace notifies change', async ({ assert }) => {
|
|
572
|
+
const dataDomain = new DataDomain()
|
|
573
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
574
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
575
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace.key)
|
|
576
|
+
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
test('moves a namespace from the root to a parent namespace - checks parent-child relationship', ({ assert }) => {
|
|
580
|
+
const dataDomain = new DataDomain()
|
|
581
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
582
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
583
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace.key)
|
|
584
|
+
assert.isTrue(dataDomain.graph.hasParent(namespace.key, parentNamespace.key))
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
test('moves a namespace from a parent namespace to the root - checks parent-child relationship', ({ assert }) => {
|
|
588
|
+
const dataDomain = new DataDomain()
|
|
589
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
590
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace.key)
|
|
591
|
+
dataDomain.moveNamespace(namespace.key)
|
|
592
|
+
assert.isFalse(dataDomain.graph.hasParent(namespace.key, parentNamespace.key))
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
test('moves a namespace from one parent namespace to another - checks parent-child relationship', ({ assert }) => {
|
|
596
|
+
const dataDomain = new DataDomain()
|
|
597
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
598
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
599
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace1.key)
|
|
600
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace2.key)
|
|
601
|
+
assert.isFalse(dataDomain.graph.hasParent(namespace.key, parentNamespace1.key))
|
|
602
|
+
assert.isTrue(dataDomain.graph.hasParent(namespace.key, parentNamespace2.key))
|
|
603
|
+
})
|
|
604
|
+
|
|
605
|
+
test('moves a namespace from the root to a parent namespace - checks items list', ({ assert }) => {
|
|
606
|
+
const dataDomain = new DataDomain()
|
|
607
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
608
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
609
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace.key)
|
|
610
|
+
const parentNs = dataDomain.findNamespace(parentNamespace.key)
|
|
611
|
+
assert.deepInclude([...parentNs!.listNamespaces()], namespace)
|
|
612
|
+
})
|
|
613
|
+
|
|
614
|
+
test('moves a namespace from a parent namespace to the root - checks items list', ({ assert }) => {
|
|
615
|
+
const dataDomain = new DataDomain()
|
|
616
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
617
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace.key)
|
|
618
|
+
dataDomain.moveNamespace(namespace.key)
|
|
619
|
+
assert.deepInclude([...dataDomain.listGraphNamespaces()], namespace)
|
|
620
|
+
})
|
|
621
|
+
|
|
622
|
+
test('moves a namespace from one parent namespace to another - checks items list', ({ assert }) => {
|
|
623
|
+
const dataDomain = new DataDomain()
|
|
624
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
625
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
626
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace1.key)
|
|
627
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace2.key)
|
|
628
|
+
const parentNs1 = dataDomain.findNamespace(parentNamespace1.key)
|
|
629
|
+
const parentNs2 = dataDomain.findNamespace(parentNamespace2.key)
|
|
630
|
+
assert.notDeepInclude([...parentNs1!.listNamespaces()], namespace)
|
|
631
|
+
assert.deepInclude([...parentNs2!.listNamespaces()], namespace)
|
|
632
|
+
})
|
|
633
|
+
|
|
634
|
+
test('moves a namespace from the root to a parent namespace - updates fields array', ({ assert }) => {
|
|
635
|
+
const dataDomain = new DataDomain()
|
|
636
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
637
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
638
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace.key)
|
|
639
|
+
assert.notDeepInclude(dataDomain.fields, { key: namespace.key, type: 'namespace' })
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
test('moves a namespace from a parent namespace to the root - updates fields array', ({ assert }) => {
|
|
643
|
+
const dataDomain = new DataDomain()
|
|
644
|
+
const parentNamespace = dataDomain.addNamespace({ key: 'parent-ns' })
|
|
645
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace.key)
|
|
646
|
+
dataDomain.moveNamespace(namespace.key)
|
|
647
|
+
assert.deepInclude(dataDomain.fields, { key: namespace.key, type: 'namespace' })
|
|
648
|
+
})
|
|
649
|
+
|
|
650
|
+
test('moves a namespace from one parent namespace to another - updates fields array', ({ assert }) => {
|
|
651
|
+
const dataDomain = new DataDomain()
|
|
652
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
653
|
+
const parentNamespace2 = dataDomain.addNamespace({ key: 'parent-ns2' })
|
|
654
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace1.key)
|
|
655
|
+
dataDomain.moveNamespace(namespace.key, parentNamespace2.key)
|
|
656
|
+
assert.notDeepInclude(dataDomain.fields, { key: namespace.key, type: 'namespace' })
|
|
657
|
+
})
|
|
658
|
+
|
|
659
|
+
test('moves a namespace from one parent namespace to another - updates fields array when moving to root', ({
|
|
660
|
+
assert,
|
|
661
|
+
}) => {
|
|
662
|
+
const dataDomain = new DataDomain()
|
|
663
|
+
const parentNamespace1 = dataDomain.addNamespace({ key: 'parent-ns1' })
|
|
664
|
+
const namespace = dataDomain.addNamespace({ key: 'test-ns' }, parentNamespace1.key)
|
|
665
|
+
dataDomain.moveNamespace(namespace.key)
|
|
666
|
+
assert.deepInclude(dataDomain.fields, { key: namespace.key, type: 'namespace' })
|
|
667
|
+
})
|
|
668
|
+
})
|