@contrail/flexplm 1.3.0 → 1.3.1-alpha.3e8dbdd
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/lib/cli/commands/compile.d.ts +1 -0
- package/lib/cli/commands/compile.js +71 -0
- package/lib/cli/commands/compile.spec.d.ts +1 -0
- package/lib/cli/commands/compile.spec.js +80 -0
- package/lib/cli/commands/create.d.ts +1 -0
- package/lib/cli/commands/create.js +75 -0
- package/lib/cli/commands/create.spec.d.ts +1 -0
- package/lib/cli/commands/create.spec.js +78 -0
- package/lib/cli/commands/upload.d.ts +10 -0
- package/lib/cli/commands/upload.js +226 -0
- package/lib/cli/commands/upload.spec.d.ts +1 -0
- package/lib/cli/commands/upload.spec.js +88 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +64 -0
- package/lib/cli/index.spec.d.ts +1 -0
- package/lib/cli/index.spec.js +79 -0
- package/lib/cli/template/mapping-template.ts.template +62 -0
- package/lib/entity-processor/base-entity-processor.d.ts +89 -42
- package/lib/entity-processor/base-entity-processor.js +438 -385
- package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
- package/lib/entity-processor/base-entity-processor.spec.js +398 -397
- package/lib/flexplm-request.d.ts +3 -3
- package/lib/flexplm-request.js +34 -34
- package/lib/flexplm-utils.d.ts +5 -5
- package/lib/flexplm-utils.js +33 -33
- package/lib/flexplm-utils.spec.d.ts +1 -1
- package/lib/flexplm-utils.spec.js +26 -26
- package/lib/index.d.ts +23 -22
- package/lib/index.js +39 -38
- package/lib/interfaces/interfaces.d.ts +105 -105
- package/lib/interfaces/interfaces.js +2 -2
- package/lib/interfaces/item-family-changes.d.ts +20 -20
- package/lib/interfaces/item-family-changes.js +56 -56
- package/lib/interfaces/mapping-file.d.ts +460 -0
- package/lib/interfaces/mapping-file.js +2 -0
- package/lib/interfaces/publish-change-data.d.ts +19 -19
- package/lib/interfaces/publish-change-data.js +32 -32
- package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
- package/lib/publish/base-process-publish-assortment-callback.js +38 -38
- package/lib/publish/base-process-publish-assortment.d.ts +118 -93
- package/lib/publish/base-process-publish-assortment.js +998 -944
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
- package/lib/publish/base-process-publish-assortment.spec.js +1688 -1670
- package/lib/publish/mockData.d.ts +1389 -1389
- package/lib/publish/mockData.js +4524 -4519
- package/lib/transform/identifier-conversion-spec-mockData.js +472 -444
- package/lib/transform/identifier-conversion.d.ts +51 -15
- package/lib/transform/identifier-conversion.js +248 -212
- package/lib/transform/identifier-conversion.spec.d.ts +1 -1
- package/lib/transform/identifier-conversion.spec.js +343 -339
- package/lib/util/config-defaults.d.ts +8 -8
- package/lib/util/config-defaults.js +88 -85
- package/lib/util/config-defaults.spec.d.ts +1 -1
- package/lib/util/config-defaults.spec.js +302 -293
- package/lib/util/data-converter-spec-mockData.js +219 -205
- package/lib/util/data-converter.d.ts +136 -39
- package/lib/util/data-converter.js +718 -592
- package/lib/util/data-converter.spec.d.ts +1 -1
- package/lib/util/data-converter.spec.js +906 -904
- package/lib/util/error-response-object.d.ts +9 -4
- package/lib/util/error-response-object.js +54 -47
- package/lib/util/error-response-object.spec.d.ts +1 -1
- package/lib/util/error-response-object.spec.js +99 -99
- package/lib/util/event-short-message-status.d.ts +19 -19
- package/lib/util/event-short-message-status.js +24 -23
- package/lib/util/federation.d.ts +15 -15
- package/lib/util/federation.js +157 -149
- package/lib/util/flexplm-connect.d.ts +29 -22
- package/lib/util/flexplm-connect.js +190 -176
- package/lib/util/flexplm-connect.spec.d.ts +1 -1
- package/lib/util/flexplm-connect.spec.js +88 -88
- package/lib/util/logger-config.d.ts +1 -1
- package/lib/util/logger-config.js +27 -26
- package/lib/util/map-util-spec-mockData.js +219 -205
- package/lib/util/map-utils.d.ts +33 -6
- package/lib/util/map-utils.js +42 -15
- package/lib/util/map-utils.spec.d.ts +1 -1
- package/lib/util/map-utils.spec.js +89 -89
- package/lib/util/mockData.d.ts +80 -80
- package/lib/util/mockData.js +103 -103
- package/lib/util/thumbnail-util.d.ts +55 -34
- package/lib/util/thumbnail-util.js +242 -215
- package/lib/util/thumbnail-util.spec.d.ts +1 -1
- package/lib/util/thumbnail-util.spec.js +440 -434
- package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
- package/lib/util/type-conversion-utils.d.ts +163 -23
- package/lib/util/type-conversion-utils.js +408 -265
- package/lib/util/type-conversion-utils.spec.d.ts +1 -1
- package/lib/util/type-conversion-utils.spec.js +868 -868
- package/lib/util/type-defaults.d.ts +74 -16
- package/lib/util/type-defaults.js +279 -221
- package/lib/util/type-defaults.spec.d.ts +1 -1
- package/lib/util/type-defaults.spec.js +516 -516
- package/lib/util/type-utils.d.ts +34 -13
- package/lib/util/type-utils.js +137 -114
- package/lib/util/type-utils.spec.d.ts +1 -1
- package/lib/util/type-utils.spec.js +192 -190
- package/package.json +21 -6
- package/scripts/copy-template.js +10 -0
- package/.claude/settings.local.json +0 -8
- package/.github/pull_request_template.md +0 -31
- package/.github/workflows/flexplm-lib.yml +0 -27
- package/.github/workflows/publish-to-npm.yml +0 -124
- package/CHANGELOG.md +0 -32
- package/publish.bat +0 -5
- package/publish.sh +0 -5
- package/src/entity-processor/base-entity-processor.spec.ts +0 -460
- package/src/entity-processor/base-entity-processor.ts +0 -515
- package/src/flexplm-request.ts +0 -28
- package/src/flexplm-utils.spec.ts +0 -27
- package/src/flexplm-utils.ts +0 -29
- package/src/index.ts +0 -22
- package/src/interfaces/interfaces.ts +0 -122
- package/src/interfaces/item-family-changes.ts +0 -67
- package/src/interfaces/publish-change-data.ts +0 -43
- package/src/publish/base-process-publish-assortment-callback.ts +0 -50
- package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
- package/src/publish/base-process-publish-assortment.ts +0 -1134
- package/src/publish/mockData.ts +0 -4561
- package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
- package/src/transform/identifier-conversion.spec.ts +0 -354
- package/src/transform/identifier-conversion.ts +0 -282
- package/src/util/config-defaults.spec.ts +0 -350
- package/src/util/config-defaults.ts +0 -93
- package/src/util/data-converter-spec-mockData.ts +0 -231
- package/src/util/data-converter.spec.ts +0 -1041
- package/src/util/data-converter.ts +0 -762
- package/src/util/error-response-object.spec.ts +0 -116
- package/src/util/error-response-object.ts +0 -50
- package/src/util/event-short-message-status.ts +0 -22
- package/src/util/federation.ts +0 -172
- package/src/util/flexplm-connect.spec.ts +0 -132
- package/src/util/flexplm-connect.ts +0 -208
- package/src/util/logger-config.ts +0 -20
- package/src/util/map-util-spec-mockData.ts +0 -231
- package/src/util/map-utils.spec.ts +0 -103
- package/src/util/map-utils.ts +0 -41
- package/src/util/mockData.ts +0 -101
- package/src/util/thumbnail-util.spec.ts +0 -508
- package/src/util/thumbnail-util.ts +0 -272
- package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
- package/src/util/type-conversion-utils.spec.ts +0 -968
- package/src/util/type-conversion-utils.ts +0 -460
- package/src/util/type-defaults.spec.ts +0 -669
- package/src/util/type-defaults.ts +0 -281
- package/src/util/type-utils.spec.ts +0 -227
- package/src/util/type-utils.ts +0 -144
- package/tsconfig.json +0 -29
- package/tslint.json +0 -57
|
@@ -1,868 +1,868 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const transform_data_1 = require("@contrail/transform-data");
|
|
4
|
-
const sdk_1 = require("@contrail/sdk");
|
|
5
|
-
const type_conversion_utils_1 = require("./type-conversion-utils");
|
|
6
|
-
const type_defaults_1 = require("./type-defaults");
|
|
7
|
-
const maps = require('./type-conversion-utils-spec-mockData');
|
|
8
|
-
const mapping = maps['mapping'];
|
|
9
|
-
const TRANSFORM_MAP_FILE = 'test-transformMapping';
|
|
10
|
-
describe('conversion-utils', () => {
|
|
11
|
-
describe('getObjectClass', () => {
|
|
12
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
13
|
-
it('flexPLMObjectClass', async () => {
|
|
14
|
-
const objectClass = 'ObjectClass';
|
|
15
|
-
const entity = {
|
|
16
|
-
flexPLMObjectClass: objectClass
|
|
17
|
-
};
|
|
18
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
19
|
-
expect(results).toEqual(objectClass);
|
|
20
|
-
});
|
|
21
|
-
it('uses mapping-catName', async () => {
|
|
22
|
-
const expectedClass = 'LCSLast';
|
|
23
|
-
const entity = {
|
|
24
|
-
entityType: 'custom-entity',
|
|
25
|
-
typePath: 'custom-entity:catName'
|
|
26
|
-
};
|
|
27
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
28
|
-
.mockImplementation(async () => {
|
|
29
|
-
return mapping;
|
|
30
|
-
});
|
|
31
|
-
try {
|
|
32
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
33
|
-
expect(results).toEqual(expectedClass);
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
spy.mockRestore();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
it('uses default-noMap', async () => {
|
|
40
|
-
const expectedClass = 'LCSColor';
|
|
41
|
-
const entity = {
|
|
42
|
-
entityType: 'color',
|
|
43
|
-
typePath: 'color:noMap'
|
|
44
|
-
};
|
|
45
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
46
|
-
.mockImplementation(async () => {
|
|
47
|
-
return mapping;
|
|
48
|
-
});
|
|
49
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultObjectClass')
|
|
50
|
-
.mockImplementation(() => expectedClass);
|
|
51
|
-
try {
|
|
52
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
53
|
-
expect(results).toEqual(expectedClass);
|
|
54
|
-
expect(spyIdentifiers).toBeCalledTimes(2);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
spy.mockRestore();
|
|
58
|
-
spyIdentifiers.mockRestore();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('getObjectTypePath', () => {
|
|
63
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
64
|
-
it('flexPLMTypePath', async () => {
|
|
65
|
-
const typePath = 'Product';
|
|
66
|
-
const entity = {
|
|
67
|
-
flexPLMTypePath: typePath
|
|
68
|
-
};
|
|
69
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
70
|
-
expect(results).toEqual(typePath);
|
|
71
|
-
});
|
|
72
|
-
it('uses mapping-catName', async () => {
|
|
73
|
-
const expectedTypePath = 'Last\\catName';
|
|
74
|
-
const entity = {
|
|
75
|
-
entityType: 'custom-entity',
|
|
76
|
-
typePath: 'custom-entity:catName'
|
|
77
|
-
};
|
|
78
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
79
|
-
.mockImplementation(async () => {
|
|
80
|
-
return mapping;
|
|
81
|
-
});
|
|
82
|
-
try {
|
|
83
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
84
|
-
expect(results).toEqual(expectedTypePath);
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
spy.mockRestore();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
it('uses default-noMap', async () => {
|
|
91
|
-
const expectedTypePath = 'Color';
|
|
92
|
-
const entity = {
|
|
93
|
-
entityType: 'color',
|
|
94
|
-
typePath: 'color:noMap'
|
|
95
|
-
};
|
|
96
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
97
|
-
.mockImplementation(async () => {
|
|
98
|
-
return mapping;
|
|
99
|
-
});
|
|
100
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultObjectTypePath')
|
|
101
|
-
.mockImplementation(() => expectedTypePath);
|
|
102
|
-
try {
|
|
103
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
104
|
-
expect(results).toEqual(expectedTypePath);
|
|
105
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
spy.mockRestore();
|
|
109
|
-
spyIdentifiers.mockRestore();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
describe('getIdentifierProperties', () => {
|
|
114
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
115
|
-
it('flexPLMIdentifierProperties', async () => {
|
|
116
|
-
const properties = ['optionName'];
|
|
117
|
-
const entity = {
|
|
118
|
-
flexPLMIdentifierProperties: properties
|
|
119
|
-
};
|
|
120
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
121
|
-
expect(results).toHaveLength(1);
|
|
122
|
-
expect(results).toEqual(properties);
|
|
123
|
-
});
|
|
124
|
-
it('uses mapping-catName', async () => {
|
|
125
|
-
const properties = ['catName', 'catNumber'];
|
|
126
|
-
const entity = {
|
|
127
|
-
entityType: 'custom-entity',
|
|
128
|
-
typePath: 'custom-entity:catName'
|
|
129
|
-
};
|
|
130
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
131
|
-
.mockImplementation(async () => {
|
|
132
|
-
return mapping;
|
|
133
|
-
});
|
|
134
|
-
try {
|
|
135
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
136
|
-
expect(results).toHaveLength(2);
|
|
137
|
-
expect(results).toEqual(properties);
|
|
138
|
-
}
|
|
139
|
-
finally {
|
|
140
|
-
spy.mockRestore();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
it('uses default-noMap', async () => {
|
|
144
|
-
const properties = ['itemNumber'];
|
|
145
|
-
const entity = {
|
|
146
|
-
entityType: 'item',
|
|
147
|
-
typePath: 'item',
|
|
148
|
-
roles: ['family']
|
|
149
|
-
};
|
|
150
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
151
|
-
.mockImplementation(async () => {
|
|
152
|
-
return mapping;
|
|
153
|
-
});
|
|
154
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultIdentifierProperties')
|
|
155
|
-
.mockImplementation(() => properties);
|
|
156
|
-
try {
|
|
157
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
158
|
-
expect(results).toEqual(properties);
|
|
159
|
-
expect(results).toHaveLength(1);
|
|
160
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
161
|
-
}
|
|
162
|
-
finally {
|
|
163
|
-
spy.mockRestore();
|
|
164
|
-
spyIdentifiers.mockRestore();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
describe('getInformationalProperties', () => {
|
|
169
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
170
|
-
it('flexPLMIdentifierProperties', async () => {
|
|
171
|
-
const properties = ['optionName'];
|
|
172
|
-
const entity = {
|
|
173
|
-
flexPLMInformationalProperties: properties
|
|
174
|
-
};
|
|
175
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
176
|
-
expect(results).toHaveLength(1);
|
|
177
|
-
expect(results).toEqual(properties);
|
|
178
|
-
});
|
|
179
|
-
it('uses mapping-catName', async () => {
|
|
180
|
-
const properties = ['longName'];
|
|
181
|
-
const entity = {
|
|
182
|
-
entityType: 'custom-entity',
|
|
183
|
-
typePath: 'custom-entity:catName'
|
|
184
|
-
};
|
|
185
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
186
|
-
.mockImplementation(async () => {
|
|
187
|
-
return mapping;
|
|
188
|
-
});
|
|
189
|
-
try {
|
|
190
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
191
|
-
expect(results).toHaveLength(1);
|
|
192
|
-
expect(results).toEqual(properties);
|
|
193
|
-
}
|
|
194
|
-
finally {
|
|
195
|
-
spy.mockRestore();
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
it('uses default-noMap', async () => {
|
|
199
|
-
const properties = ['optionName', 'description'];
|
|
200
|
-
const entity = {
|
|
201
|
-
entityType: 'item',
|
|
202
|
-
typePath: 'item',
|
|
203
|
-
roles: ['color']
|
|
204
|
-
};
|
|
205
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
206
|
-
.mockImplementation(async () => {
|
|
207
|
-
return mapping;
|
|
208
|
-
});
|
|
209
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultInformationalProperties')
|
|
210
|
-
.mockImplementation(() => properties);
|
|
211
|
-
try {
|
|
212
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
213
|
-
expect(results).toEqual(properties);
|
|
214
|
-
expect(results).toHaveLength(2);
|
|
215
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
216
|
-
}
|
|
217
|
-
finally {
|
|
218
|
-
spy.mockRestore();
|
|
219
|
-
spyIdentifiers.mockRestore();
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
describe('getMapKey', () => {
|
|
224
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
225
|
-
it('custom-entity:pack', async () => {
|
|
226
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
227
|
-
.mockImplementation(async () => {
|
|
228
|
-
return mapping;
|
|
229
|
-
});
|
|
230
|
-
const entity = {
|
|
231
|
-
typePath: 'custom-entity:pack',
|
|
232
|
-
entityType: 'custom-entity'
|
|
233
|
-
};
|
|
234
|
-
const expectedMapKey = 'packaging';
|
|
235
|
-
try {
|
|
236
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
237
|
-
expect(results).toEqual(expectedMapKey);
|
|
238
|
-
}
|
|
239
|
-
finally {
|
|
240
|
-
spy.mockRestore();
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
it('custom-entity:prefix', async () => {
|
|
244
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
245
|
-
.mockImplementation(async () => {
|
|
246
|
-
return mapping;
|
|
247
|
-
});
|
|
248
|
-
const entity = {
|
|
249
|
-
typePath: 'custom-entity:prefix',
|
|
250
|
-
entityType: 'custom-entity'
|
|
251
|
-
};
|
|
252
|
-
const expectedMapKey = 'prefix';
|
|
253
|
-
try {
|
|
254
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
255
|
-
expect(results).toEqual(expectedMapKey);
|
|
256
|
-
}
|
|
257
|
-
finally {
|
|
258
|
-
spy.mockRestore();
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
it('color - no mapping exists', async () => {
|
|
262
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
263
|
-
.mockImplementation(async () => {
|
|
264
|
-
return mapping;
|
|
265
|
-
});
|
|
266
|
-
const entity = {
|
|
267
|
-
typePath: 'color',
|
|
268
|
-
entityType: 'color'
|
|
269
|
-
};
|
|
270
|
-
const expectedMapKey = 'LCSColor';
|
|
271
|
-
try {
|
|
272
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
273
|
-
expect(results).toEqual(expectedMapKey);
|
|
274
|
-
}
|
|
275
|
-
finally {
|
|
276
|
-
spy.mockRestore();
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
describe('getEntityClassFromObject', () => {
|
|
281
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
282
|
-
it('vibeIQEntityClass', async () => {
|
|
283
|
-
const objectClass = 'ObjectClass';
|
|
284
|
-
const object = {
|
|
285
|
-
vibeIQEntityClass: objectClass
|
|
286
|
-
};
|
|
287
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
288
|
-
expect(results).toEqual(objectClass);
|
|
289
|
-
});
|
|
290
|
-
it('uses mapping-catName', async () => {
|
|
291
|
-
const expectedClass = 'custom-entity';
|
|
292
|
-
const object = {
|
|
293
|
-
flexPLMObjectClass: 'LCSLast',
|
|
294
|
-
flexPLMTypePath: 'Last\\catName'
|
|
295
|
-
};
|
|
296
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
297
|
-
.mockImplementation(async () => {
|
|
298
|
-
return mapping;
|
|
299
|
-
});
|
|
300
|
-
try {
|
|
301
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
302
|
-
expect(results).toEqual(expectedClass);
|
|
303
|
-
}
|
|
304
|
-
finally {
|
|
305
|
-
spy.mockRestore();
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
it('uses default-noMap', async () => {
|
|
309
|
-
const expectedClass = 'color';
|
|
310
|
-
const entity = {
|
|
311
|
-
flexPLMObjectClass: 'LCSColor',
|
|
312
|
-
flexPLMTypePath: 'Color'
|
|
313
|
-
};
|
|
314
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
315
|
-
.mockImplementation(async () => {
|
|
316
|
-
return mapping;
|
|
317
|
-
});
|
|
318
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
|
|
319
|
-
.mockImplementation(() => expectedClass);
|
|
320
|
-
try {
|
|
321
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
322
|
-
expect(results).toEqual(expectedClass);
|
|
323
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
324
|
-
}
|
|
325
|
-
finally {
|
|
326
|
-
spy.mockRestore();
|
|
327
|
-
spyIdentifiers.mockRestore();
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
describe('getEntityTypePathFromOjbect', () => {
|
|
332
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
333
|
-
it('vibeIQTypePath', async () => {
|
|
334
|
-
const typePath = 'item';
|
|
335
|
-
const entity = {
|
|
336
|
-
vibeIQTypePath: typePath
|
|
337
|
-
};
|
|
338
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
339
|
-
expect(results).toEqual(typePath);
|
|
340
|
-
});
|
|
341
|
-
it('uses mapping-catName', async () => {
|
|
342
|
-
const expectedTypePath = 'custom-entity:catName';
|
|
343
|
-
const entity = {
|
|
344
|
-
flexPLMObjectClass: 'LCSLast',
|
|
345
|
-
flexPLMTypePath: 'Last\\catName'
|
|
346
|
-
};
|
|
347
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
348
|
-
.mockImplementation(async () => {
|
|
349
|
-
return mapping;
|
|
350
|
-
});
|
|
351
|
-
try {
|
|
352
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
353
|
-
expect(results).toEqual(expectedTypePath);
|
|
354
|
-
}
|
|
355
|
-
finally {
|
|
356
|
-
spy.mockRestore();
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
it('uses default-noMap', async () => {
|
|
360
|
-
const expectedTypePath = 'color';
|
|
361
|
-
const entity = {
|
|
362
|
-
flexPLMObjectClass: 'LCSColor',
|
|
363
|
-
flexPLMTypePath: 'Color'
|
|
364
|
-
};
|
|
365
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
366
|
-
.mockImplementation(async () => {
|
|
367
|
-
return mapping;
|
|
368
|
-
});
|
|
369
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityTypePath')
|
|
370
|
-
.mockImplementation(() => expectedTypePath);
|
|
371
|
-
try {
|
|
372
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
373
|
-
expect(results).toEqual(expectedTypePath);
|
|
374
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
375
|
-
}
|
|
376
|
-
finally {
|
|
377
|
-
spy.mockRestore();
|
|
378
|
-
spyIdentifiers.mockRestore();
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
describe('getIdentifierPropertiesFromObject', () => {
|
|
383
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
384
|
-
it('flexPLMIdentifierProperties', async () => {
|
|
385
|
-
const properties = ['optionName'];
|
|
386
|
-
const object = {
|
|
387
|
-
vibeIQIdentifierProperties: properties
|
|
388
|
-
};
|
|
389
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
390
|
-
expect(results).toHaveLength(1);
|
|
391
|
-
expect(results).toEqual(properties);
|
|
392
|
-
});
|
|
393
|
-
it('uses mapping-catName', async () => {
|
|
394
|
-
const properties = ['catName', 'catNumber'];
|
|
395
|
-
const object = {
|
|
396
|
-
flexPLMObjectClass: 'LCSLast',
|
|
397
|
-
flexPLMTypePath: 'Last\\catName'
|
|
398
|
-
};
|
|
399
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
400
|
-
.mockImplementation(async () => {
|
|
401
|
-
return mapping;
|
|
402
|
-
});
|
|
403
|
-
try {
|
|
404
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
405
|
-
expect(results).toHaveLength(2);
|
|
406
|
-
expect(results).toEqual(properties);
|
|
407
|
-
}
|
|
408
|
-
finally {
|
|
409
|
-
spy.mockRestore();
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
it('uses default-noMap', async () => {
|
|
413
|
-
const properties = ['itemNumber'];
|
|
414
|
-
const object = {
|
|
415
|
-
flexPLMObjectClass: 'LCSProduct',
|
|
416
|
-
flexPLMTypePath: 'Product'
|
|
417
|
-
};
|
|
418
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
419
|
-
.mockImplementation(async () => {
|
|
420
|
-
return mapping;
|
|
421
|
-
});
|
|
422
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultIdentifierPropertiesFromObject')
|
|
423
|
-
.mockImplementation(() => properties);
|
|
424
|
-
try {
|
|
425
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
426
|
-
expect(results).toEqual(properties);
|
|
427
|
-
expect(results).toHaveLength(1);
|
|
428
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
429
|
-
}
|
|
430
|
-
finally {
|
|
431
|
-
spy.mockRestore();
|
|
432
|
-
spyIdentifiers.mockRestore();
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
describe('getInformationalPropertiesFromObject', () => {
|
|
437
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
438
|
-
it('vibeIQInformationalProperties', async () => {
|
|
439
|
-
const properties = ['optionName'];
|
|
440
|
-
const object = {
|
|
441
|
-
vibeIQInformationalProperties: properties
|
|
442
|
-
};
|
|
443
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
444
|
-
expect(results).toHaveLength(1);
|
|
445
|
-
expect(results).toEqual(properties);
|
|
446
|
-
});
|
|
447
|
-
it('uses mapping-catName', async () => {
|
|
448
|
-
const properties = ['longName'];
|
|
449
|
-
const object = {
|
|
450
|
-
flexPLMObjectClass: 'LCSLast',
|
|
451
|
-
flexPLMTypePath: 'Last\\catName'
|
|
452
|
-
};
|
|
453
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
454
|
-
.mockImplementation(async () => {
|
|
455
|
-
return mapping;
|
|
456
|
-
});
|
|
457
|
-
try {
|
|
458
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
459
|
-
expect(results).toHaveLength(1);
|
|
460
|
-
expect(results).toEqual(properties);
|
|
461
|
-
}
|
|
462
|
-
finally {
|
|
463
|
-
spy.mockRestore();
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
it('uses default-noMap', async () => {
|
|
467
|
-
const properties = ['optionName', 'description'];
|
|
468
|
-
const object = {
|
|
469
|
-
flexPLMObjectClass: 'LCSSKU',
|
|
470
|
-
typePath: 'Product'
|
|
471
|
-
};
|
|
472
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
473
|
-
.mockImplementation(async () => {
|
|
474
|
-
return mapping;
|
|
475
|
-
});
|
|
476
|
-
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultInformationalPropertiesFromObject')
|
|
477
|
-
.mockImplementation(() => properties);
|
|
478
|
-
try {
|
|
479
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
480
|
-
expect(results).toEqual(properties);
|
|
481
|
-
expect(results).toHaveLength(2);
|
|
482
|
-
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
483
|
-
}
|
|
484
|
-
finally {
|
|
485
|
-
spy.mockRestore();
|
|
486
|
-
spyIdentifiers.mockRestore();
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
describe('getMapKeyFromObject', () => {
|
|
491
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
492
|
-
it('Revisable Entity\\packaging', async () => {
|
|
493
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
494
|
-
.mockImplementation(async () => {
|
|
495
|
-
return mapping;
|
|
496
|
-
});
|
|
497
|
-
const object = {
|
|
498
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
499
|
-
flexPLMTypePath: 'Revisable Entity\\packaging'
|
|
500
|
-
};
|
|
501
|
-
const expectedMapKey = 'packaging';
|
|
502
|
-
try {
|
|
503
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
504
|
-
expect(results).toEqual(expectedMapKey);
|
|
505
|
-
}
|
|
506
|
-
finally {
|
|
507
|
-
spy.mockRestore();
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
it('Revisable Entity\\prefix', async () => {
|
|
511
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
512
|
-
.mockImplementation(async () => {
|
|
513
|
-
return mapping;
|
|
514
|
-
});
|
|
515
|
-
const object = {
|
|
516
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
517
|
-
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
518
|
-
};
|
|
519
|
-
const expectedMapKey = 'prefix';
|
|
520
|
-
try {
|
|
521
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
522
|
-
expect(results).toEqual(expectedMapKey);
|
|
523
|
-
}
|
|
524
|
-
finally {
|
|
525
|
-
spy.mockRestore();
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
it('color - no mapping exists', async () => {
|
|
529
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
530
|
-
.mockImplementation(async () => {
|
|
531
|
-
return mapping;
|
|
532
|
-
});
|
|
533
|
-
const object = {
|
|
534
|
-
flexPLMObjectClass: 'LCSColor',
|
|
535
|
-
flexPLMTypePath: 'Color'
|
|
536
|
-
};
|
|
537
|
-
const expectedMapKey = 'LCSColor';
|
|
538
|
-
try {
|
|
539
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
540
|
-
expect(results).toEqual(expectedMapKey);
|
|
541
|
-
}
|
|
542
|
-
finally {
|
|
543
|
-
spy.mockRestore();
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
describe('isInboundCreatableFromObject', () => {
|
|
548
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
549
|
-
it('Revisable Entity\\packaging', async () => {
|
|
550
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
551
|
-
.mockImplementation(async () => {
|
|
552
|
-
return mapping;
|
|
553
|
-
});
|
|
554
|
-
const object = {
|
|
555
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
556
|
-
flexPLMTypePath: 'Revisable Entity\\packaging'
|
|
557
|
-
};
|
|
558
|
-
try {
|
|
559
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
560
|
-
expect(results).toBeFalsy();
|
|
561
|
-
}
|
|
562
|
-
finally {
|
|
563
|
-
spy.mockRestore();
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
it('Revisable Entity\\prefix', async () => {
|
|
567
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
568
|
-
.mockImplementation(async () => {
|
|
569
|
-
return mapping;
|
|
570
|
-
});
|
|
571
|
-
const object = {
|
|
572
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
573
|
-
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
574
|
-
};
|
|
575
|
-
try {
|
|
576
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
577
|
-
expect(results).toBeTruthy();
|
|
578
|
-
}
|
|
579
|
-
finally {
|
|
580
|
-
spy.mockRestore();
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
it('should pass context to isInboundCreatable function', async () => {
|
|
584
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
585
|
-
.mockImplementation(async () => {
|
|
586
|
-
return mapping;
|
|
587
|
-
});
|
|
588
|
-
const object = {
|
|
589
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
590
|
-
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
591
|
-
};
|
|
592
|
-
const context = { skipPrefix: true };
|
|
593
|
-
try {
|
|
594
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, context);
|
|
595
|
-
expect(results).toBeFalsy();
|
|
596
|
-
}
|
|
597
|
-
finally {
|
|
598
|
-
spy.mockRestore();
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
it('should work without context parameter', async () => {
|
|
602
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
603
|
-
.mockImplementation(async () => {
|
|
604
|
-
return mapping;
|
|
605
|
-
});
|
|
606
|
-
const object = {
|
|
607
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
608
|
-
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
609
|
-
};
|
|
610
|
-
try {
|
|
611
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
612
|
-
expect(results).toBeTruthy();
|
|
613
|
-
}
|
|
614
|
-
finally {
|
|
615
|
-
spy.mockRestore();
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
});
|
|
619
|
-
describe('isOutboundCreatableFromEntity', () => {
|
|
620
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
621
|
-
it('should return false for custom-entity:pack', async () => {
|
|
622
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
623
|
-
.mockImplementation(async () => {
|
|
624
|
-
return mapping;
|
|
625
|
-
});
|
|
626
|
-
const entity = {
|
|
627
|
-
entityType: 'custom-entity',
|
|
628
|
-
typePath: 'custom-entity:pack'
|
|
629
|
-
};
|
|
630
|
-
try {
|
|
631
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
632
|
-
expect(results).toBeFalsy();
|
|
633
|
-
}
|
|
634
|
-
finally {
|
|
635
|
-
spy.mockRestore();
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
it('should return true for custom-entity:prefix', async () => {
|
|
639
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
640
|
-
.mockImplementation(async () => {
|
|
641
|
-
return mapping;
|
|
642
|
-
});
|
|
643
|
-
const entity = {
|
|
644
|
-
entityType: 'custom-entity',
|
|
645
|
-
typePath: 'custom-entity:prefix'
|
|
646
|
-
};
|
|
647
|
-
try {
|
|
648
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
649
|
-
expect(results).toBeTruthy();
|
|
650
|
-
}
|
|
651
|
-
finally {
|
|
652
|
-
spy.mockRestore();
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
it('should pass context to isOutboundCreatable function', async () => {
|
|
656
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
657
|
-
.mockImplementation(async () => {
|
|
658
|
-
return mapping;
|
|
659
|
-
});
|
|
660
|
-
const entity = {
|
|
661
|
-
entityType: 'custom-entity',
|
|
662
|
-
typePath: 'custom-entity:prefix'
|
|
663
|
-
};
|
|
664
|
-
const context = { skipPrefix: true };
|
|
665
|
-
try {
|
|
666
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
|
|
667
|
-
expect(results).toBeFalsy();
|
|
668
|
-
}
|
|
669
|
-
finally {
|
|
670
|
-
spy.mockRestore();
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
it('should work without context parameter', async () => {
|
|
674
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
675
|
-
.mockImplementation(async () => {
|
|
676
|
-
return mapping;
|
|
677
|
-
});
|
|
678
|
-
const entity = {
|
|
679
|
-
entityType: 'custom-entity',
|
|
680
|
-
typePath: 'custom-entity:prefix'
|
|
681
|
-
};
|
|
682
|
-
try {
|
|
683
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
684
|
-
expect(results).toBeTruthy();
|
|
685
|
-
}
|
|
686
|
-
finally {
|
|
687
|
-
spy.mockRestore();
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
it('should default to true when no mapping exists', async () => {
|
|
691
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
692
|
-
.mockImplementation(async () => {
|
|
693
|
-
return mapping;
|
|
694
|
-
});
|
|
695
|
-
const entity = {
|
|
696
|
-
entityType: 'custom-entity',
|
|
697
|
-
typePath: 'custom-entity:catName'
|
|
698
|
-
};
|
|
699
|
-
try {
|
|
700
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
701
|
-
expect(results).toBeTruthy();
|
|
702
|
-
}
|
|
703
|
-
finally {
|
|
704
|
-
spy.mockRestore();
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
describe('syncInboundImages', () => {
|
|
709
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
710
|
-
it('should return true for Revisable Entity\\packaging (mapping entry true)', async () => {
|
|
711
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
712
|
-
.mockImplementation(async () => {
|
|
713
|
-
return mapping;
|
|
714
|
-
});
|
|
715
|
-
const obj = {
|
|
716
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
717
|
-
flexPLMTypePath: 'Revisable Entity\\packaging'
|
|
718
|
-
};
|
|
719
|
-
try {
|
|
720
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
|
|
721
|
-
expect(results).toBeTruthy();
|
|
722
|
-
}
|
|
723
|
-
finally {
|
|
724
|
-
spy.mockRestore();
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
it('should return true for Revisable Entity\\prefix (mapping entry true)', async () => {
|
|
728
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
729
|
-
.mockImplementation(async () => {
|
|
730
|
-
return mapping;
|
|
731
|
-
});
|
|
732
|
-
const obj = {
|
|
733
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
734
|
-
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
735
|
-
};
|
|
736
|
-
try {
|
|
737
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
|
|
738
|
-
expect(results).toBeTruthy();
|
|
739
|
-
}
|
|
740
|
-
finally {
|
|
741
|
-
spy.mockRestore();
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
it('should pass context to syncInboundImages function', async () => {
|
|
745
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
746
|
-
.mockImplementation(async () => {
|
|
747
|
-
return mapping;
|
|
748
|
-
});
|
|
749
|
-
const obj = {
|
|
750
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
751
|
-
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
752
|
-
};
|
|
753
|
-
const context = { skipImages: true };
|
|
754
|
-
try {
|
|
755
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj, context);
|
|
756
|
-
expect(results).toBeFalsy();
|
|
757
|
-
}
|
|
758
|
-
finally {
|
|
759
|
-
spy.mockRestore();
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
it('should default to false when no mapping exists', async () => {
|
|
763
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
764
|
-
.mockImplementation(async () => {
|
|
765
|
-
return mapping;
|
|
766
|
-
});
|
|
767
|
-
const obj = {
|
|
768
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
769
|
-
flexPLMTypePath: 'Revisable Entity\\catName'
|
|
770
|
-
};
|
|
771
|
-
try {
|
|
772
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
|
|
773
|
-
expect(results).toBeFalsy();
|
|
774
|
-
}
|
|
775
|
-
finally {
|
|
776
|
-
spy.mockRestore();
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
it('should default to false when no fileId', async () => {
|
|
780
|
-
const obj = {
|
|
781
|
-
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
782
|
-
flexPLMTypePath: 'Revisable Entity\\pack'
|
|
783
|
-
};
|
|
784
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages('', mapFileUtil, obj);
|
|
785
|
-
expect(results).toBeFalsy();
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
describe('syncOutboundImages', () => {
|
|
789
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
790
|
-
it('should return false for custom-entity:pack (mapping entry false)', async () => {
|
|
791
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
792
|
-
.mockImplementation(async () => {
|
|
793
|
-
return mapping;
|
|
794
|
-
});
|
|
795
|
-
const entity = {
|
|
796
|
-
entityType: 'custom-entity',
|
|
797
|
-
typePath: 'custom-entity:pack'
|
|
798
|
-
};
|
|
799
|
-
try {
|
|
800
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
801
|
-
expect(results).toBeFalsy();
|
|
802
|
-
}
|
|
803
|
-
finally {
|
|
804
|
-
spy.mockRestore();
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
it('should return true for custom-entity:prefix (mapping entry true)', async () => {
|
|
808
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
809
|
-
.mockImplementation(async () => {
|
|
810
|
-
return mapping;
|
|
811
|
-
});
|
|
812
|
-
const entity = {
|
|
813
|
-
entityType: 'custom-entity',
|
|
814
|
-
typePath: 'custom-entity:prefix'
|
|
815
|
-
};
|
|
816
|
-
try {
|
|
817
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
818
|
-
expect(results).toBeTruthy();
|
|
819
|
-
}
|
|
820
|
-
finally {
|
|
821
|
-
spy.mockRestore();
|
|
822
|
-
}
|
|
823
|
-
});
|
|
824
|
-
it('should pass context to syncOutboundImages function', async () => {
|
|
825
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
826
|
-
.mockImplementation(async () => {
|
|
827
|
-
return mapping;
|
|
828
|
-
});
|
|
829
|
-
const entity = {
|
|
830
|
-
entityType: 'custom-entity',
|
|
831
|
-
typePath: 'custom-entity:prefix'
|
|
832
|
-
};
|
|
833
|
-
const context = { skipImages: true };
|
|
834
|
-
try {
|
|
835
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
|
|
836
|
-
expect(results).toBeFalsy();
|
|
837
|
-
}
|
|
838
|
-
finally {
|
|
839
|
-
spy.mockRestore();
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
it('should default to true when no mapping exists', async () => {
|
|
843
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
844
|
-
.mockImplementation(async () => {
|
|
845
|
-
return mapping;
|
|
846
|
-
});
|
|
847
|
-
const entity = {
|
|
848
|
-
entityType: 'custom-entity',
|
|
849
|
-
typePath: 'custom-entity:catName'
|
|
850
|
-
};
|
|
851
|
-
try {
|
|
852
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
853
|
-
expect(results).toBeTruthy();
|
|
854
|
-
}
|
|
855
|
-
finally {
|
|
856
|
-
spy.mockRestore();
|
|
857
|
-
}
|
|
858
|
-
});
|
|
859
|
-
it('should default to true when no fileId', async () => {
|
|
860
|
-
const entity = {
|
|
861
|
-
entityType: 'custom-entity',
|
|
862
|
-
typePath: 'custom-entity:pack'
|
|
863
|
-
};
|
|
864
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages('', mapFileUtil, entity);
|
|
865
|
-
expect(results).toBeTruthy();
|
|
866
|
-
});
|
|
867
|
-
});
|
|
868
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const transform_data_1 = require("@contrail/transform-data");
|
|
4
|
+
const sdk_1 = require("@contrail/sdk");
|
|
5
|
+
const type_conversion_utils_1 = require("./type-conversion-utils");
|
|
6
|
+
const type_defaults_1 = require("./type-defaults");
|
|
7
|
+
const maps = require('./type-conversion-utils-spec-mockData');
|
|
8
|
+
const mapping = maps['mapping'];
|
|
9
|
+
const TRANSFORM_MAP_FILE = 'test-transformMapping';
|
|
10
|
+
describe('conversion-utils', () => {
|
|
11
|
+
describe('getObjectClass', () => {
|
|
12
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
13
|
+
it('flexPLMObjectClass', async () => {
|
|
14
|
+
const objectClass = 'ObjectClass';
|
|
15
|
+
const entity = {
|
|
16
|
+
flexPLMObjectClass: objectClass
|
|
17
|
+
};
|
|
18
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
19
|
+
expect(results).toEqual(objectClass);
|
|
20
|
+
});
|
|
21
|
+
it('uses mapping-catName', async () => {
|
|
22
|
+
const expectedClass = 'LCSLast';
|
|
23
|
+
const entity = {
|
|
24
|
+
entityType: 'custom-entity',
|
|
25
|
+
typePath: 'custom-entity:catName'
|
|
26
|
+
};
|
|
27
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
28
|
+
.mockImplementation(async () => {
|
|
29
|
+
return mapping;
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
33
|
+
expect(results).toEqual(expectedClass);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
spy.mockRestore();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
it('uses default-noMap', async () => {
|
|
40
|
+
const expectedClass = 'LCSColor';
|
|
41
|
+
const entity = {
|
|
42
|
+
entityType: 'color',
|
|
43
|
+
typePath: 'color:noMap'
|
|
44
|
+
};
|
|
45
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
46
|
+
.mockImplementation(async () => {
|
|
47
|
+
return mapping;
|
|
48
|
+
});
|
|
49
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultObjectClass')
|
|
50
|
+
.mockImplementation(() => expectedClass);
|
|
51
|
+
try {
|
|
52
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
53
|
+
expect(results).toEqual(expectedClass);
|
|
54
|
+
expect(spyIdentifiers).toBeCalledTimes(2);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
spy.mockRestore();
|
|
58
|
+
spyIdentifiers.mockRestore();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('getObjectTypePath', () => {
|
|
63
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
64
|
+
it('flexPLMTypePath', async () => {
|
|
65
|
+
const typePath = 'Product';
|
|
66
|
+
const entity = {
|
|
67
|
+
flexPLMTypePath: typePath
|
|
68
|
+
};
|
|
69
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
70
|
+
expect(results).toEqual(typePath);
|
|
71
|
+
});
|
|
72
|
+
it('uses mapping-catName', async () => {
|
|
73
|
+
const expectedTypePath = 'Last\\catName';
|
|
74
|
+
const entity = {
|
|
75
|
+
entityType: 'custom-entity',
|
|
76
|
+
typePath: 'custom-entity:catName'
|
|
77
|
+
};
|
|
78
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
79
|
+
.mockImplementation(async () => {
|
|
80
|
+
return mapping;
|
|
81
|
+
});
|
|
82
|
+
try {
|
|
83
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
84
|
+
expect(results).toEqual(expectedTypePath);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
spy.mockRestore();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
it('uses default-noMap', async () => {
|
|
91
|
+
const expectedTypePath = 'Color';
|
|
92
|
+
const entity = {
|
|
93
|
+
entityType: 'color',
|
|
94
|
+
typePath: 'color:noMap'
|
|
95
|
+
};
|
|
96
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
97
|
+
.mockImplementation(async () => {
|
|
98
|
+
return mapping;
|
|
99
|
+
});
|
|
100
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultObjectTypePath')
|
|
101
|
+
.mockImplementation(() => expectedTypePath);
|
|
102
|
+
try {
|
|
103
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
104
|
+
expect(results).toEqual(expectedTypePath);
|
|
105
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
spy.mockRestore();
|
|
109
|
+
spyIdentifiers.mockRestore();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('getIdentifierProperties', () => {
|
|
114
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
115
|
+
it('flexPLMIdentifierProperties', async () => {
|
|
116
|
+
const properties = ['optionName'];
|
|
117
|
+
const entity = {
|
|
118
|
+
flexPLMIdentifierProperties: properties
|
|
119
|
+
};
|
|
120
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
121
|
+
expect(results).toHaveLength(1);
|
|
122
|
+
expect(results).toEqual(properties);
|
|
123
|
+
});
|
|
124
|
+
it('uses mapping-catName', async () => {
|
|
125
|
+
const properties = ['catName', 'catNumber'];
|
|
126
|
+
const entity = {
|
|
127
|
+
entityType: 'custom-entity',
|
|
128
|
+
typePath: 'custom-entity:catName'
|
|
129
|
+
};
|
|
130
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
131
|
+
.mockImplementation(async () => {
|
|
132
|
+
return mapping;
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
136
|
+
expect(results).toHaveLength(2);
|
|
137
|
+
expect(results).toEqual(properties);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
spy.mockRestore();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
it('uses default-noMap', async () => {
|
|
144
|
+
const properties = ['itemNumber'];
|
|
145
|
+
const entity = {
|
|
146
|
+
entityType: 'item',
|
|
147
|
+
typePath: 'item',
|
|
148
|
+
roles: ['family']
|
|
149
|
+
};
|
|
150
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
151
|
+
.mockImplementation(async () => {
|
|
152
|
+
return mapping;
|
|
153
|
+
});
|
|
154
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultIdentifierProperties')
|
|
155
|
+
.mockImplementation(() => properties);
|
|
156
|
+
try {
|
|
157
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
158
|
+
expect(results).toEqual(properties);
|
|
159
|
+
expect(results).toHaveLength(1);
|
|
160
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
spy.mockRestore();
|
|
164
|
+
spyIdentifiers.mockRestore();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('getInformationalProperties', () => {
|
|
169
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
170
|
+
it('flexPLMIdentifierProperties', async () => {
|
|
171
|
+
const properties = ['optionName'];
|
|
172
|
+
const entity = {
|
|
173
|
+
flexPLMInformationalProperties: properties
|
|
174
|
+
};
|
|
175
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
176
|
+
expect(results).toHaveLength(1);
|
|
177
|
+
expect(results).toEqual(properties);
|
|
178
|
+
});
|
|
179
|
+
it('uses mapping-catName', async () => {
|
|
180
|
+
const properties = ['longName'];
|
|
181
|
+
const entity = {
|
|
182
|
+
entityType: 'custom-entity',
|
|
183
|
+
typePath: 'custom-entity:catName'
|
|
184
|
+
};
|
|
185
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
186
|
+
.mockImplementation(async () => {
|
|
187
|
+
return mapping;
|
|
188
|
+
});
|
|
189
|
+
try {
|
|
190
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
191
|
+
expect(results).toHaveLength(1);
|
|
192
|
+
expect(results).toEqual(properties);
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
spy.mockRestore();
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
it('uses default-noMap', async () => {
|
|
199
|
+
const properties = ['optionName', 'description'];
|
|
200
|
+
const entity = {
|
|
201
|
+
entityType: 'item',
|
|
202
|
+
typePath: 'item',
|
|
203
|
+
roles: ['color']
|
|
204
|
+
};
|
|
205
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
206
|
+
.mockImplementation(async () => {
|
|
207
|
+
return mapping;
|
|
208
|
+
});
|
|
209
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultInformationalProperties')
|
|
210
|
+
.mockImplementation(() => properties);
|
|
211
|
+
try {
|
|
212
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
213
|
+
expect(results).toEqual(properties);
|
|
214
|
+
expect(results).toHaveLength(2);
|
|
215
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
spy.mockRestore();
|
|
219
|
+
spyIdentifiers.mockRestore();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
describe('getMapKey', () => {
|
|
224
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
225
|
+
it('custom-entity:pack', async () => {
|
|
226
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
227
|
+
.mockImplementation(async () => {
|
|
228
|
+
return mapping;
|
|
229
|
+
});
|
|
230
|
+
const entity = {
|
|
231
|
+
typePath: 'custom-entity:pack',
|
|
232
|
+
entityType: 'custom-entity'
|
|
233
|
+
};
|
|
234
|
+
const expectedMapKey = 'packaging';
|
|
235
|
+
try {
|
|
236
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
237
|
+
expect(results).toEqual(expectedMapKey);
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
spy.mockRestore();
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
it('custom-entity:prefix', async () => {
|
|
244
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
245
|
+
.mockImplementation(async () => {
|
|
246
|
+
return mapping;
|
|
247
|
+
});
|
|
248
|
+
const entity = {
|
|
249
|
+
typePath: 'custom-entity:prefix',
|
|
250
|
+
entityType: 'custom-entity'
|
|
251
|
+
};
|
|
252
|
+
const expectedMapKey = 'prefix';
|
|
253
|
+
try {
|
|
254
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
255
|
+
expect(results).toEqual(expectedMapKey);
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
spy.mockRestore();
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
it('color - no mapping exists', async () => {
|
|
262
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
263
|
+
.mockImplementation(async () => {
|
|
264
|
+
return mapping;
|
|
265
|
+
});
|
|
266
|
+
const entity = {
|
|
267
|
+
typePath: 'color',
|
|
268
|
+
entityType: 'color'
|
|
269
|
+
};
|
|
270
|
+
const expectedMapKey = 'LCSColor';
|
|
271
|
+
try {
|
|
272
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
273
|
+
expect(results).toEqual(expectedMapKey);
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
spy.mockRestore();
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
describe('getEntityClassFromObject', () => {
|
|
281
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
282
|
+
it('vibeIQEntityClass', async () => {
|
|
283
|
+
const objectClass = 'ObjectClass';
|
|
284
|
+
const object = {
|
|
285
|
+
vibeIQEntityClass: objectClass
|
|
286
|
+
};
|
|
287
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
288
|
+
expect(results).toEqual(objectClass);
|
|
289
|
+
});
|
|
290
|
+
it('uses mapping-catName', async () => {
|
|
291
|
+
const expectedClass = 'custom-entity';
|
|
292
|
+
const object = {
|
|
293
|
+
flexPLMObjectClass: 'LCSLast',
|
|
294
|
+
flexPLMTypePath: 'Last\\catName'
|
|
295
|
+
};
|
|
296
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
297
|
+
.mockImplementation(async () => {
|
|
298
|
+
return mapping;
|
|
299
|
+
});
|
|
300
|
+
try {
|
|
301
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
302
|
+
expect(results).toEqual(expectedClass);
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
spy.mockRestore();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
it('uses default-noMap', async () => {
|
|
309
|
+
const expectedClass = 'color';
|
|
310
|
+
const entity = {
|
|
311
|
+
flexPLMObjectClass: 'LCSColor',
|
|
312
|
+
flexPLMTypePath: 'Color'
|
|
313
|
+
};
|
|
314
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
315
|
+
.mockImplementation(async () => {
|
|
316
|
+
return mapping;
|
|
317
|
+
});
|
|
318
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
|
|
319
|
+
.mockImplementation(() => expectedClass);
|
|
320
|
+
try {
|
|
321
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
322
|
+
expect(results).toEqual(expectedClass);
|
|
323
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
spy.mockRestore();
|
|
327
|
+
spyIdentifiers.mockRestore();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
describe('getEntityTypePathFromOjbect', () => {
|
|
332
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
333
|
+
it('vibeIQTypePath', async () => {
|
|
334
|
+
const typePath = 'item';
|
|
335
|
+
const entity = {
|
|
336
|
+
vibeIQTypePath: typePath
|
|
337
|
+
};
|
|
338
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
339
|
+
expect(results).toEqual(typePath);
|
|
340
|
+
});
|
|
341
|
+
it('uses mapping-catName', async () => {
|
|
342
|
+
const expectedTypePath = 'custom-entity:catName';
|
|
343
|
+
const entity = {
|
|
344
|
+
flexPLMObjectClass: 'LCSLast',
|
|
345
|
+
flexPLMTypePath: 'Last\\catName'
|
|
346
|
+
};
|
|
347
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
348
|
+
.mockImplementation(async () => {
|
|
349
|
+
return mapping;
|
|
350
|
+
});
|
|
351
|
+
try {
|
|
352
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
353
|
+
expect(results).toEqual(expectedTypePath);
|
|
354
|
+
}
|
|
355
|
+
finally {
|
|
356
|
+
spy.mockRestore();
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
it('uses default-noMap', async () => {
|
|
360
|
+
const expectedTypePath = 'color';
|
|
361
|
+
const entity = {
|
|
362
|
+
flexPLMObjectClass: 'LCSColor',
|
|
363
|
+
flexPLMTypePath: 'Color'
|
|
364
|
+
};
|
|
365
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
366
|
+
.mockImplementation(async () => {
|
|
367
|
+
return mapping;
|
|
368
|
+
});
|
|
369
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityTypePath')
|
|
370
|
+
.mockImplementation(() => expectedTypePath);
|
|
371
|
+
try {
|
|
372
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
373
|
+
expect(results).toEqual(expectedTypePath);
|
|
374
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
375
|
+
}
|
|
376
|
+
finally {
|
|
377
|
+
spy.mockRestore();
|
|
378
|
+
spyIdentifiers.mockRestore();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
describe('getIdentifierPropertiesFromObject', () => {
|
|
383
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
384
|
+
it('flexPLMIdentifierProperties', async () => {
|
|
385
|
+
const properties = ['optionName'];
|
|
386
|
+
const object = {
|
|
387
|
+
vibeIQIdentifierProperties: properties
|
|
388
|
+
};
|
|
389
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
390
|
+
expect(results).toHaveLength(1);
|
|
391
|
+
expect(results).toEqual(properties);
|
|
392
|
+
});
|
|
393
|
+
it('uses mapping-catName', async () => {
|
|
394
|
+
const properties = ['catName', 'catNumber'];
|
|
395
|
+
const object = {
|
|
396
|
+
flexPLMObjectClass: 'LCSLast',
|
|
397
|
+
flexPLMTypePath: 'Last\\catName'
|
|
398
|
+
};
|
|
399
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
400
|
+
.mockImplementation(async () => {
|
|
401
|
+
return mapping;
|
|
402
|
+
});
|
|
403
|
+
try {
|
|
404
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
405
|
+
expect(results).toHaveLength(2);
|
|
406
|
+
expect(results).toEqual(properties);
|
|
407
|
+
}
|
|
408
|
+
finally {
|
|
409
|
+
spy.mockRestore();
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
it('uses default-noMap', async () => {
|
|
413
|
+
const properties = ['itemNumber'];
|
|
414
|
+
const object = {
|
|
415
|
+
flexPLMObjectClass: 'LCSProduct',
|
|
416
|
+
flexPLMTypePath: 'Product'
|
|
417
|
+
};
|
|
418
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
419
|
+
.mockImplementation(async () => {
|
|
420
|
+
return mapping;
|
|
421
|
+
});
|
|
422
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultIdentifierPropertiesFromObject')
|
|
423
|
+
.mockImplementation(() => properties);
|
|
424
|
+
try {
|
|
425
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
426
|
+
expect(results).toEqual(properties);
|
|
427
|
+
expect(results).toHaveLength(1);
|
|
428
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
spy.mockRestore();
|
|
432
|
+
spyIdentifiers.mockRestore();
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
describe('getInformationalPropertiesFromObject', () => {
|
|
437
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
438
|
+
it('vibeIQInformationalProperties', async () => {
|
|
439
|
+
const properties = ['optionName'];
|
|
440
|
+
const object = {
|
|
441
|
+
vibeIQInformationalProperties: properties
|
|
442
|
+
};
|
|
443
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
444
|
+
expect(results).toHaveLength(1);
|
|
445
|
+
expect(results).toEqual(properties);
|
|
446
|
+
});
|
|
447
|
+
it('uses mapping-catName', async () => {
|
|
448
|
+
const properties = ['longName'];
|
|
449
|
+
const object = {
|
|
450
|
+
flexPLMObjectClass: 'LCSLast',
|
|
451
|
+
flexPLMTypePath: 'Last\\catName'
|
|
452
|
+
};
|
|
453
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
454
|
+
.mockImplementation(async () => {
|
|
455
|
+
return mapping;
|
|
456
|
+
});
|
|
457
|
+
try {
|
|
458
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
459
|
+
expect(results).toHaveLength(1);
|
|
460
|
+
expect(results).toEqual(properties);
|
|
461
|
+
}
|
|
462
|
+
finally {
|
|
463
|
+
spy.mockRestore();
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
it('uses default-noMap', async () => {
|
|
467
|
+
const properties = ['optionName', 'description'];
|
|
468
|
+
const object = {
|
|
469
|
+
flexPLMObjectClass: 'LCSSKU',
|
|
470
|
+
typePath: 'Product'
|
|
471
|
+
};
|
|
472
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
473
|
+
.mockImplementation(async () => {
|
|
474
|
+
return mapping;
|
|
475
|
+
});
|
|
476
|
+
const spyIdentifiers = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultInformationalPropertiesFromObject')
|
|
477
|
+
.mockImplementation(() => properties);
|
|
478
|
+
try {
|
|
479
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
480
|
+
expect(results).toEqual(properties);
|
|
481
|
+
expect(results).toHaveLength(2);
|
|
482
|
+
expect(spyIdentifiers).toBeCalledTimes(1);
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
spy.mockRestore();
|
|
486
|
+
spyIdentifiers.mockRestore();
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
describe('getMapKeyFromObject', () => {
|
|
491
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
492
|
+
it('Revisable Entity\\packaging', async () => {
|
|
493
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
494
|
+
.mockImplementation(async () => {
|
|
495
|
+
return mapping;
|
|
496
|
+
});
|
|
497
|
+
const object = {
|
|
498
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
499
|
+
flexPLMTypePath: 'Revisable Entity\\packaging'
|
|
500
|
+
};
|
|
501
|
+
const expectedMapKey = 'packaging';
|
|
502
|
+
try {
|
|
503
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
504
|
+
expect(results).toEqual(expectedMapKey);
|
|
505
|
+
}
|
|
506
|
+
finally {
|
|
507
|
+
spy.mockRestore();
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
it('Revisable Entity\\prefix', async () => {
|
|
511
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
512
|
+
.mockImplementation(async () => {
|
|
513
|
+
return mapping;
|
|
514
|
+
});
|
|
515
|
+
const object = {
|
|
516
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
517
|
+
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
518
|
+
};
|
|
519
|
+
const expectedMapKey = 'prefix';
|
|
520
|
+
try {
|
|
521
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
522
|
+
expect(results).toEqual(expectedMapKey);
|
|
523
|
+
}
|
|
524
|
+
finally {
|
|
525
|
+
spy.mockRestore();
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
it('color - no mapping exists', async () => {
|
|
529
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
530
|
+
.mockImplementation(async () => {
|
|
531
|
+
return mapping;
|
|
532
|
+
});
|
|
533
|
+
const object = {
|
|
534
|
+
flexPLMObjectClass: 'LCSColor',
|
|
535
|
+
flexPLMTypePath: 'Color'
|
|
536
|
+
};
|
|
537
|
+
const expectedMapKey = 'LCSColor';
|
|
538
|
+
try {
|
|
539
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
540
|
+
expect(results).toEqual(expectedMapKey);
|
|
541
|
+
}
|
|
542
|
+
finally {
|
|
543
|
+
spy.mockRestore();
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
describe('isInboundCreatableFromObject', () => {
|
|
548
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
549
|
+
it('Revisable Entity\\packaging', async () => {
|
|
550
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
551
|
+
.mockImplementation(async () => {
|
|
552
|
+
return mapping;
|
|
553
|
+
});
|
|
554
|
+
const object = {
|
|
555
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
556
|
+
flexPLMTypePath: 'Revisable Entity\\packaging'
|
|
557
|
+
};
|
|
558
|
+
try {
|
|
559
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
560
|
+
expect(results).toBeFalsy();
|
|
561
|
+
}
|
|
562
|
+
finally {
|
|
563
|
+
spy.mockRestore();
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
it('Revisable Entity\\prefix', async () => {
|
|
567
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
568
|
+
.mockImplementation(async () => {
|
|
569
|
+
return mapping;
|
|
570
|
+
});
|
|
571
|
+
const object = {
|
|
572
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
573
|
+
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
574
|
+
};
|
|
575
|
+
try {
|
|
576
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
577
|
+
expect(results).toBeTruthy();
|
|
578
|
+
}
|
|
579
|
+
finally {
|
|
580
|
+
spy.mockRestore();
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
it('should pass context to isInboundCreatable function', async () => {
|
|
584
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
585
|
+
.mockImplementation(async () => {
|
|
586
|
+
return mapping;
|
|
587
|
+
});
|
|
588
|
+
const object = {
|
|
589
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
590
|
+
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
591
|
+
};
|
|
592
|
+
const context = { skipPrefix: true };
|
|
593
|
+
try {
|
|
594
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, context);
|
|
595
|
+
expect(results).toBeFalsy();
|
|
596
|
+
}
|
|
597
|
+
finally {
|
|
598
|
+
spy.mockRestore();
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
it('should work without context parameter', async () => {
|
|
602
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
603
|
+
.mockImplementation(async () => {
|
|
604
|
+
return mapping;
|
|
605
|
+
});
|
|
606
|
+
const object = {
|
|
607
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
608
|
+
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
609
|
+
};
|
|
610
|
+
try {
|
|
611
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
612
|
+
expect(results).toBeTruthy();
|
|
613
|
+
}
|
|
614
|
+
finally {
|
|
615
|
+
spy.mockRestore();
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
describe('isOutboundCreatableFromEntity', () => {
|
|
620
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
621
|
+
it('should return false for custom-entity:pack', async () => {
|
|
622
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
623
|
+
.mockImplementation(async () => {
|
|
624
|
+
return mapping;
|
|
625
|
+
});
|
|
626
|
+
const entity = {
|
|
627
|
+
entityType: 'custom-entity',
|
|
628
|
+
typePath: 'custom-entity:pack'
|
|
629
|
+
};
|
|
630
|
+
try {
|
|
631
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
632
|
+
expect(results).toBeFalsy();
|
|
633
|
+
}
|
|
634
|
+
finally {
|
|
635
|
+
spy.mockRestore();
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
it('should return true for custom-entity:prefix', async () => {
|
|
639
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
640
|
+
.mockImplementation(async () => {
|
|
641
|
+
return mapping;
|
|
642
|
+
});
|
|
643
|
+
const entity = {
|
|
644
|
+
entityType: 'custom-entity',
|
|
645
|
+
typePath: 'custom-entity:prefix'
|
|
646
|
+
};
|
|
647
|
+
try {
|
|
648
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
649
|
+
expect(results).toBeTruthy();
|
|
650
|
+
}
|
|
651
|
+
finally {
|
|
652
|
+
spy.mockRestore();
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
it('should pass context to isOutboundCreatable function', async () => {
|
|
656
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
657
|
+
.mockImplementation(async () => {
|
|
658
|
+
return mapping;
|
|
659
|
+
});
|
|
660
|
+
const entity = {
|
|
661
|
+
entityType: 'custom-entity',
|
|
662
|
+
typePath: 'custom-entity:prefix'
|
|
663
|
+
};
|
|
664
|
+
const context = { skipPrefix: true };
|
|
665
|
+
try {
|
|
666
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
|
|
667
|
+
expect(results).toBeFalsy();
|
|
668
|
+
}
|
|
669
|
+
finally {
|
|
670
|
+
spy.mockRestore();
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
it('should work without context parameter', async () => {
|
|
674
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
675
|
+
.mockImplementation(async () => {
|
|
676
|
+
return mapping;
|
|
677
|
+
});
|
|
678
|
+
const entity = {
|
|
679
|
+
entityType: 'custom-entity',
|
|
680
|
+
typePath: 'custom-entity:prefix'
|
|
681
|
+
};
|
|
682
|
+
try {
|
|
683
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
684
|
+
expect(results).toBeTruthy();
|
|
685
|
+
}
|
|
686
|
+
finally {
|
|
687
|
+
spy.mockRestore();
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
it('should default to true when no mapping exists', async () => {
|
|
691
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
692
|
+
.mockImplementation(async () => {
|
|
693
|
+
return mapping;
|
|
694
|
+
});
|
|
695
|
+
const entity = {
|
|
696
|
+
entityType: 'custom-entity',
|
|
697
|
+
typePath: 'custom-entity:catName'
|
|
698
|
+
};
|
|
699
|
+
try {
|
|
700
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
701
|
+
expect(results).toBeTruthy();
|
|
702
|
+
}
|
|
703
|
+
finally {
|
|
704
|
+
spy.mockRestore();
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
});
|
|
708
|
+
describe('syncInboundImages', () => {
|
|
709
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
710
|
+
it('should return true for Revisable Entity\\packaging (mapping entry true)', async () => {
|
|
711
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
712
|
+
.mockImplementation(async () => {
|
|
713
|
+
return mapping;
|
|
714
|
+
});
|
|
715
|
+
const obj = {
|
|
716
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
717
|
+
flexPLMTypePath: 'Revisable Entity\\packaging'
|
|
718
|
+
};
|
|
719
|
+
try {
|
|
720
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
|
|
721
|
+
expect(results).toBeTruthy();
|
|
722
|
+
}
|
|
723
|
+
finally {
|
|
724
|
+
spy.mockRestore();
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
it('should return true for Revisable Entity\\prefix (mapping entry true)', async () => {
|
|
728
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
729
|
+
.mockImplementation(async () => {
|
|
730
|
+
return mapping;
|
|
731
|
+
});
|
|
732
|
+
const obj = {
|
|
733
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
734
|
+
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
735
|
+
};
|
|
736
|
+
try {
|
|
737
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
|
|
738
|
+
expect(results).toBeTruthy();
|
|
739
|
+
}
|
|
740
|
+
finally {
|
|
741
|
+
spy.mockRestore();
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
it('should pass context to syncInboundImages function', async () => {
|
|
745
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
746
|
+
.mockImplementation(async () => {
|
|
747
|
+
return mapping;
|
|
748
|
+
});
|
|
749
|
+
const obj = {
|
|
750
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
751
|
+
flexPLMTypePath: 'Revisable Entity\\prefix'
|
|
752
|
+
};
|
|
753
|
+
const context = { skipImages: true };
|
|
754
|
+
try {
|
|
755
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj, context);
|
|
756
|
+
expect(results).toBeFalsy();
|
|
757
|
+
}
|
|
758
|
+
finally {
|
|
759
|
+
spy.mockRestore();
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
it('should default to false when no mapping exists', async () => {
|
|
763
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
764
|
+
.mockImplementation(async () => {
|
|
765
|
+
return mapping;
|
|
766
|
+
});
|
|
767
|
+
const obj = {
|
|
768
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
769
|
+
flexPLMTypePath: 'Revisable Entity\\catName'
|
|
770
|
+
};
|
|
771
|
+
try {
|
|
772
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages(TRANSFORM_MAP_FILE, mapFileUtil, obj);
|
|
773
|
+
expect(results).toBeFalsy();
|
|
774
|
+
}
|
|
775
|
+
finally {
|
|
776
|
+
spy.mockRestore();
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
it('should default to false when no fileId', async () => {
|
|
780
|
+
const obj = {
|
|
781
|
+
flexPLMObjectClass: 'LCSRevisableEntity',
|
|
782
|
+
flexPLMTypePath: 'Revisable Entity\\pack'
|
|
783
|
+
};
|
|
784
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncInboundImages('', mapFileUtil, obj);
|
|
785
|
+
expect(results).toBeFalsy();
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
describe('syncOutboundImages', () => {
|
|
789
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
790
|
+
it('should return false for custom-entity:pack (mapping entry false)', async () => {
|
|
791
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
792
|
+
.mockImplementation(async () => {
|
|
793
|
+
return mapping;
|
|
794
|
+
});
|
|
795
|
+
const entity = {
|
|
796
|
+
entityType: 'custom-entity',
|
|
797
|
+
typePath: 'custom-entity:pack'
|
|
798
|
+
};
|
|
799
|
+
try {
|
|
800
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
801
|
+
expect(results).toBeFalsy();
|
|
802
|
+
}
|
|
803
|
+
finally {
|
|
804
|
+
spy.mockRestore();
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
it('should return true for custom-entity:prefix (mapping entry true)', async () => {
|
|
808
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
809
|
+
.mockImplementation(async () => {
|
|
810
|
+
return mapping;
|
|
811
|
+
});
|
|
812
|
+
const entity = {
|
|
813
|
+
entityType: 'custom-entity',
|
|
814
|
+
typePath: 'custom-entity:prefix'
|
|
815
|
+
};
|
|
816
|
+
try {
|
|
817
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
818
|
+
expect(results).toBeTruthy();
|
|
819
|
+
}
|
|
820
|
+
finally {
|
|
821
|
+
spy.mockRestore();
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
it('should pass context to syncOutboundImages function', async () => {
|
|
825
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
826
|
+
.mockImplementation(async () => {
|
|
827
|
+
return mapping;
|
|
828
|
+
});
|
|
829
|
+
const entity = {
|
|
830
|
+
entityType: 'custom-entity',
|
|
831
|
+
typePath: 'custom-entity:prefix'
|
|
832
|
+
};
|
|
833
|
+
const context = { skipImages: true };
|
|
834
|
+
try {
|
|
835
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity, context);
|
|
836
|
+
expect(results).toBeFalsy();
|
|
837
|
+
}
|
|
838
|
+
finally {
|
|
839
|
+
spy.mockRestore();
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
it('should default to true when no mapping exists', async () => {
|
|
843
|
+
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
844
|
+
.mockImplementation(async () => {
|
|
845
|
+
return mapping;
|
|
846
|
+
});
|
|
847
|
+
const entity = {
|
|
848
|
+
entityType: 'custom-entity',
|
|
849
|
+
typePath: 'custom-entity:catName'
|
|
850
|
+
};
|
|
851
|
+
try {
|
|
852
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages(TRANSFORM_MAP_FILE, mapFileUtil, entity);
|
|
853
|
+
expect(results).toBeTruthy();
|
|
854
|
+
}
|
|
855
|
+
finally {
|
|
856
|
+
spy.mockRestore();
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
it('should default to true when no fileId', async () => {
|
|
860
|
+
const entity = {
|
|
861
|
+
entityType: 'custom-entity',
|
|
862
|
+
typePath: 'custom-entity:pack'
|
|
863
|
+
};
|
|
864
|
+
const results = await type_conversion_utils_1.TypeConversionUtils.syncOutboundImages('', mapFileUtil, entity);
|
|
865
|
+
expect(results).toBeTruthy();
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
});
|