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