@contrail/flexplm 1.6.0-alpha.8e73fa3 → 1.6.0-alpha.d2464c6
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.
|
@@ -86,10 +86,8 @@ export declare class BaseProcessPublishAssortment {
|
|
|
86
86
|
getResultsCount(events: any): any;
|
|
87
87
|
private sendEvents;
|
|
88
88
|
private sendToFlexPLM;
|
|
89
|
-
private buildPublishError;
|
|
90
89
|
private saveToLocalFile;
|
|
91
90
|
private handleVibeIQFile;
|
|
92
|
-
private sendPublishPayloadEvent;
|
|
93
91
|
private getCurrentDateString;
|
|
94
92
|
getItemFamilyChanges(pcd: PublishChangeData, changeDetail: any, assortmentItemFullChangeMap: Map<string, any>, assortmentItemDeleteMap: Map<string, any>): Map<string, ItemFamilyChanges>;
|
|
95
93
|
getEventsForPublishChangeData(publishChangeData: PublishChangeData): Promise<SeasonalPayload[]>;
|
|
@@ -595,37 +595,14 @@ class BaseProcessPublishAssortment {
|
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
597
|
async sendToFlexPLM(events, eventType) {
|
|
598
|
-
const
|
|
598
|
+
const asyncEvent = {
|
|
599
599
|
taskId: this.config.taskId,
|
|
600
600
|
eventType,
|
|
601
601
|
objectClass: 'LCSSeason',
|
|
602
602
|
events
|
|
603
603
|
};
|
|
604
604
|
const flexPLMConnect = new flexplm_connect_1.FlexPLMConnect(this.config);
|
|
605
|
-
|
|
606
|
-
flexPLMConnect.sendToFlexPLM(outboundPublishEvent),
|
|
607
|
-
this.sendPublishPayloadEvent(outboundPublishEvent)
|
|
608
|
-
]);
|
|
609
|
-
if (sendResult.status === 'rejected' || eventResult.status === 'rejected') {
|
|
610
|
-
throw this.buildPublishError(sendResult, eventResult, outboundPublishEvent);
|
|
611
|
-
}
|
|
612
|
-
const result = sendResult.value;
|
|
613
|
-
const isResultObject = typeof result === 'object' && result !== null;
|
|
614
|
-
return isResultObject
|
|
615
|
-
? { ...result, outboundPublishEvent }
|
|
616
|
-
: { result, outboundPublishEvent };
|
|
617
|
-
}
|
|
618
|
-
buildPublishError(sendResult, eventResult, outboundPublishEvent) {
|
|
619
|
-
const baseReason = sendResult.status === 'rejected' ? sendResult.reason : eventResult.reason;
|
|
620
|
-
const error = baseReason instanceof Error ? baseReason : new Error(String(baseReason));
|
|
621
|
-
error.outboundPublishEvent = outboundPublishEvent;
|
|
622
|
-
error.sendToFlexPLMResult = sendResult.status === 'fulfilled'
|
|
623
|
-
? sendResult.value
|
|
624
|
-
: { error: sendResult.reason?.message ?? String(sendResult.reason) };
|
|
625
|
-
error.sendPublishPayloadEventResult = eventResult.status === 'fulfilled'
|
|
626
|
-
? eventResult.value
|
|
627
|
-
: { error: eventResult.reason?.message ?? String(eventResult.reason) };
|
|
628
|
-
return error;
|
|
605
|
+
return await flexPLMConnect.sendToFlexPLM(asyncEvent);
|
|
629
606
|
}
|
|
630
607
|
async saveToLocalFile(events, eventType) {
|
|
631
608
|
let results = {};
|
|
@@ -637,16 +614,15 @@ class BaseProcessPublishAssortment {
|
|
|
637
614
|
const eventDirName = 'events-output';
|
|
638
615
|
const fileName = `${path.sep}${eventDirName}${path.sep}events-${dateString}.json`;
|
|
639
616
|
fileHandle = await fsPromise.open('.' + fileName, 'a');
|
|
640
|
-
const
|
|
617
|
+
const asyncEvent = {
|
|
641
618
|
taskId: this.config.taskId,
|
|
642
619
|
eventType,
|
|
643
620
|
objectClass: 'LCSSeason',
|
|
644
621
|
events
|
|
645
622
|
};
|
|
646
|
-
await fileHandle.writeFile(JSON.stringify(
|
|
623
|
+
await fileHandle.writeFile(JSON.stringify(asyncEvent));
|
|
647
624
|
results = {
|
|
648
625
|
message: 'Successfully Saved File',
|
|
649
|
-
outboundPublishEvent,
|
|
650
626
|
fileLocation: dirName + fileName
|
|
651
627
|
};
|
|
652
628
|
}
|
|
@@ -662,7 +638,7 @@ class BaseProcessPublishAssortment {
|
|
|
662
638
|
const eventBuffer = Buffer.from(JSON.stringify(events), 'utf-8');
|
|
663
639
|
const fileName = 'ASYNC_PUBLISH_SEASON-events.json';
|
|
664
640
|
const uploadFile = await new sdk_1.Files().createAndUploadFileFromBuffer(eventBuffer, 'application/json', fileName, null, this.TTL);
|
|
665
|
-
const
|
|
641
|
+
const asyncEvent = {
|
|
666
642
|
taskId: this.config.taskId,
|
|
667
643
|
eventType,
|
|
668
644
|
objectClass: 'LCSSeason',
|
|
@@ -672,46 +648,15 @@ class BaseProcessPublishAssortment {
|
|
|
672
648
|
};
|
|
673
649
|
if (sendMode === 'vibeiqfile') {
|
|
674
650
|
const flexPLMConnect = new flexplm_connect_1.FlexPLMConnect(this.config);
|
|
675
|
-
|
|
676
|
-
flexPLMConnect.sendToFlexPLM(outboundPublishEvent),
|
|
677
|
-
this.sendPublishPayloadEvent(outboundPublishEvent)
|
|
678
|
-
]);
|
|
679
|
-
if (sendResult.status === 'rejected' || eventResult.status === 'rejected') {
|
|
680
|
-
throw this.buildPublishError(sendResult, eventResult, outboundPublishEvent);
|
|
681
|
-
}
|
|
682
|
-
const result = sendResult.value;
|
|
683
|
-
const isResultObject = typeof result === 'object' && result !== null;
|
|
684
|
-
return isResultObject
|
|
685
|
-
? { ...result, outboundPublishEvent }
|
|
686
|
-
: { result, outboundPublishEvent };
|
|
651
|
+
return await flexPLMConnect.sendToFlexPLM(asyncEvent);
|
|
687
652
|
}
|
|
688
653
|
else {
|
|
689
|
-
await this.sendPublishPayloadEvent(outboundPublishEvent);
|
|
690
654
|
return {
|
|
691
655
|
message: 'Successfully Uploaded File.',
|
|
692
|
-
|
|
656
|
+
asyncEvent
|
|
693
657
|
};
|
|
694
658
|
}
|
|
695
659
|
}
|
|
696
|
-
async sendPublishPayloadEvent(outboundPublishEvent) {
|
|
697
|
-
console.info('sendPublishPayloadEvent()');
|
|
698
|
-
let initialEvent = {};
|
|
699
|
-
if (this.config?.event) {
|
|
700
|
-
initialEvent = (typeof this.config?.event === 'string')
|
|
701
|
-
? JSON.parse(this.config?.event)
|
|
702
|
-
: this.config?.event;
|
|
703
|
-
}
|
|
704
|
-
const eventBody = {
|
|
705
|
-
originSystemType: 'VibeIQ',
|
|
706
|
-
objectClass: 'AssortmentPublishedToFlexPLM',
|
|
707
|
-
outboundPublishEvent,
|
|
708
|
-
initialEvent
|
|
709
|
-
};
|
|
710
|
-
await new sdk_1.Entities().create({
|
|
711
|
-
entityName: 'external-event',
|
|
712
|
-
object: eventBody
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
660
|
getCurrentDateString() {
|
|
716
661
|
const d = new Date();
|
|
717
662
|
return '' + d.getUTCFullYear()
|
|
@@ -9,7 +9,6 @@ const sdk_1 = require("@contrail/sdk");
|
|
|
9
9
|
const type_conversion_utils_1 = require("../util/type-conversion-utils");
|
|
10
10
|
const map_utils_1 = require("../util/map-utils");
|
|
11
11
|
const item_family_changes_1 = require("../interfaces/item-family-changes");
|
|
12
|
-
const flexplm_connect_1 = require("../util/flexplm-connect");
|
|
13
12
|
let federatedId = '';
|
|
14
13
|
jest.mock('../util/data-converter', () => {
|
|
15
14
|
return {
|
|
@@ -32,13 +31,6 @@ jest.mock('../util/federation', () => {
|
|
|
32
31
|
});
|
|
33
32
|
let entityObject = {};
|
|
34
33
|
let getOptionsObject = {};
|
|
35
|
-
let createCallArg = undefined;
|
|
36
|
-
let fileUploadCalls = [];
|
|
37
|
-
let fileUploadResult = {
|
|
38
|
-
id: 'file-123',
|
|
39
|
-
downloadUrl: 'https://download.url',
|
|
40
|
-
adminDownloadUrl: 'https://admin.download.url'
|
|
41
|
-
};
|
|
42
34
|
jest.mock('@contrail/sdk', () => {
|
|
43
35
|
return {
|
|
44
36
|
Entities: class {
|
|
@@ -46,18 +38,6 @@ jest.mock('@contrail/sdk', () => {
|
|
|
46
38
|
getOptionsObject = _getOtionsObject;
|
|
47
39
|
return entityObject;
|
|
48
40
|
}
|
|
49
|
-
create(arg) {
|
|
50
|
-
createCallArg = arg;
|
|
51
|
-
return Promise.resolve({});
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
Files: class {
|
|
55
|
-
createAndUploadFileFromBuffer(buffer, mimeType, fileName, _x, ttl) {
|
|
56
|
-
fileUploadCalls.push({ buffer, mimeType, fileName, ttl });
|
|
57
|
-
return Promise.resolve(fileUploadResult);
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
Request: class {
|
|
61
41
|
}
|
|
62
42
|
};
|
|
63
43
|
});
|
|
@@ -1706,195 +1686,3 @@ describe('getEventsForItemFamilyChanges - conditional eventType', () => {
|
|
|
1706
1686
|
expect(type_conversion_utils_1.TypeConversionUtils.isOutboundCreatableFromEntity).toHaveBeenNthCalledWith(2, undefined, mapFileUtil, colorProjectItem, { item: itemData, assortment });
|
|
1707
1687
|
});
|
|
1708
1688
|
});
|
|
1709
|
-
describe('sendToFlexPLM / handleVibeIQFile / sendPublishPayloadEvent', () => {
|
|
1710
|
-
const config = {
|
|
1711
|
-
taskId: 'task-abc',
|
|
1712
|
-
event: '{"sourceEventId":"src-1"}'
|
|
1713
|
-
};
|
|
1714
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
1715
|
-
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
1716
|
-
const events = [{ objectClass: 'LCSProductSeasonLink' }];
|
|
1717
|
-
const eventType = 'ASYNC_PUBLISH_SEASON';
|
|
1718
|
-
beforeEach(() => {
|
|
1719
|
-
createCallArg = undefined;
|
|
1720
|
-
fileUploadCalls = [];
|
|
1721
|
-
fileUploadResult = {
|
|
1722
|
-
id: 'file-123',
|
|
1723
|
-
downloadUrl: 'https://download.url',
|
|
1724
|
-
adminDownloadUrl: 'https://admin.download.url'
|
|
1725
|
-
};
|
|
1726
|
-
});
|
|
1727
|
-
afterEach(() => {
|
|
1728
|
-
jest.restoreAllMocks();
|
|
1729
|
-
});
|
|
1730
|
-
it('should merge outboundPublishEvent into result and call sendPublishPayloadEvent in parallel', async () => {
|
|
1731
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1732
|
-
const flexResponse = { status: 200, data: { ok: true } };
|
|
1733
|
-
let flexResolved = false;
|
|
1734
|
-
let eventResolved = false;
|
|
1735
|
-
const spyFlex = jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM')
|
|
1736
|
-
.mockImplementation(async () => {
|
|
1737
|
-
await new Promise(r => setTimeout(r, 5));
|
|
1738
|
-
flexResolved = true;
|
|
1739
|
-
return flexResponse;
|
|
1740
|
-
});
|
|
1741
|
-
const spyEvent = jest.spyOn(bppa, 'sendPublishPayloadEvent')
|
|
1742
|
-
.mockImplementation(async () => {
|
|
1743
|
-
await new Promise(r => setTimeout(r, 5));
|
|
1744
|
-
eventResolved = true;
|
|
1745
|
-
});
|
|
1746
|
-
const result = await bppa.sendToFlexPLM(events, eventType);
|
|
1747
|
-
expect(spyFlex).toHaveBeenCalledTimes(1);
|
|
1748
|
-
expect(spyEvent).toHaveBeenCalledTimes(1);
|
|
1749
|
-
expect(flexResolved).toBe(true);
|
|
1750
|
-
expect(eventResolved).toBe(true);
|
|
1751
|
-
const passedOutboundPublishEvent = spyFlex.mock.calls[0][0];
|
|
1752
|
-
expect(passedOutboundPublishEvent.taskId).toBe('task-abc');
|
|
1753
|
-
expect(passedOutboundPublishEvent.eventType).toBe(eventType);
|
|
1754
|
-
expect(passedOutboundPublishEvent.objectClass).toBe('LCSSeason');
|
|
1755
|
-
expect(passedOutboundPublishEvent.events).toBe(events);
|
|
1756
|
-
expect(spyEvent).toHaveBeenCalledWith(passedOutboundPublishEvent);
|
|
1757
|
-
expect(result).toEqual({ ...flexResponse, outboundPublishEvent: passedOutboundPublishEvent });
|
|
1758
|
-
});
|
|
1759
|
-
it('sendToFlexPLM throws when flexPLMConnect.sendToFlexPLM fails, attaching outboundPublishEvent and both results', async () => {
|
|
1760
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1761
|
-
const flexError = new Error('flex failed');
|
|
1762
|
-
const eventResponse = { eventOk: true };
|
|
1763
|
-
jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM').mockRejectedValue(flexError);
|
|
1764
|
-
jest.spyOn(bppa, 'sendPublishPayloadEvent').mockResolvedValue(eventResponse);
|
|
1765
|
-
await expect(bppa.sendToFlexPLM(events, eventType)).rejects.toMatchObject({
|
|
1766
|
-
message: 'flex failed',
|
|
1767
|
-
outboundPublishEvent: expect.objectContaining({ taskId: 'task-abc', eventType, objectClass: 'LCSSeason', events }),
|
|
1768
|
-
sendToFlexPLMResult: { error: 'flex failed' },
|
|
1769
|
-
sendPublishPayloadEventResult: eventResponse
|
|
1770
|
-
});
|
|
1771
|
-
});
|
|
1772
|
-
it('sendToFlexPLM throws when sendPublishPayloadEvent fails, with flex result attached', async () => {
|
|
1773
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1774
|
-
const flexResponse = { status: 200 };
|
|
1775
|
-
const eventError = new Error('event failed');
|
|
1776
|
-
jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM').mockResolvedValue(flexResponse);
|
|
1777
|
-
jest.spyOn(bppa, 'sendPublishPayloadEvent').mockRejectedValue(eventError);
|
|
1778
|
-
await expect(bppa.sendToFlexPLM(events, eventType)).rejects.toMatchObject({
|
|
1779
|
-
message: 'event failed',
|
|
1780
|
-
outboundPublishEvent: expect.objectContaining({ taskId: 'task-abc', eventType }),
|
|
1781
|
-
sendToFlexPLMResult: flexResponse,
|
|
1782
|
-
sendPublishPayloadEventResult: { error: 'event failed' }
|
|
1783
|
-
});
|
|
1784
|
-
});
|
|
1785
|
-
it('sendToFlexPLM throws the flexPLMConnect error when both fail', async () => {
|
|
1786
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1787
|
-
const flexError = new Error('flex failed');
|
|
1788
|
-
const eventError = new Error('event failed');
|
|
1789
|
-
jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM').mockRejectedValue(flexError);
|
|
1790
|
-
jest.spyOn(bppa, 'sendPublishPayloadEvent').mockRejectedValue(eventError);
|
|
1791
|
-
await expect(bppa.sendToFlexPLM(events, eventType)).rejects.toBe(flexError);
|
|
1792
|
-
expect(flexError.outboundPublishEvent).toBeDefined();
|
|
1793
|
-
expect(flexError.sendToFlexPLMResult).toEqual({ error: 'flex failed' });
|
|
1794
|
-
expect(flexError.sendPublishPayloadEventResult).toEqual({ error: 'event failed' });
|
|
1795
|
-
});
|
|
1796
|
-
it('handleVibeIQFile (vibeiqfile) throws when flexPLMConnect.sendToFlexPLM fails, with both results attached', async () => {
|
|
1797
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1798
|
-
const flexError = new Error('flex failed');
|
|
1799
|
-
const eventResponse = { eventOk: true };
|
|
1800
|
-
jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM').mockRejectedValue(flexError);
|
|
1801
|
-
jest.spyOn(bppa, 'sendPublishPayloadEvent').mockResolvedValue(eventResponse);
|
|
1802
|
-
await expect(bppa.handleVibeIQFile(events, eventType, 'vibeiqfile')).rejects.toMatchObject({
|
|
1803
|
-
message: 'flex failed',
|
|
1804
|
-
outboundPublishEvent: expect.objectContaining({ eventsFileId: 'file-123' }),
|
|
1805
|
-
sendToFlexPLMResult: { error: 'flex failed' },
|
|
1806
|
-
sendPublishPayloadEventResult: eventResponse
|
|
1807
|
-
});
|
|
1808
|
-
});
|
|
1809
|
-
it('handleVibeIQFile (vibeiqfile) throws when sendPublishPayloadEvent fails, with flex result attached', async () => {
|
|
1810
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1811
|
-
const flexResponse = { status: 200 };
|
|
1812
|
-
const eventError = new Error('event failed');
|
|
1813
|
-
jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM').mockResolvedValue(flexResponse);
|
|
1814
|
-
jest.spyOn(bppa, 'sendPublishPayloadEvent').mockRejectedValue(eventError);
|
|
1815
|
-
await expect(bppa.handleVibeIQFile(events, eventType, 'vibeiqfile')).rejects.toMatchObject({
|
|
1816
|
-
message: 'event failed',
|
|
1817
|
-
outboundPublishEvent: expect.objectContaining({ eventsFileId: 'file-123' }),
|
|
1818
|
-
sendToFlexPLMResult: flexResponse,
|
|
1819
|
-
sendPublishPayloadEventResult: { error: 'event failed' }
|
|
1820
|
-
});
|
|
1821
|
-
});
|
|
1822
|
-
it('handleVibeIQFile (vibeiqfile) throws the flexPLMConnect error when both fail', async () => {
|
|
1823
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1824
|
-
const flexError = new Error('flex failed');
|
|
1825
|
-
const eventError = new Error('event failed');
|
|
1826
|
-
jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM').mockRejectedValue(flexError);
|
|
1827
|
-
jest.spyOn(bppa, 'sendPublishPayloadEvent').mockRejectedValue(eventError);
|
|
1828
|
-
await expect(bppa.handleVibeIQFile(events, eventType, 'vibeiqfile')).rejects.toBe(flexError);
|
|
1829
|
-
expect(flexError.sendToFlexPLMResult).toEqual({ error: 'flex failed' });
|
|
1830
|
-
expect(flexError.sendPublishPayloadEventResult).toEqual({ error: 'event failed' });
|
|
1831
|
-
});
|
|
1832
|
-
it('should merge outboundPublishEvent into FlexPLM result and call sendPublishPayloadEvent when mode is vibeiqfile', async () => {
|
|
1833
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1834
|
-
const flexResponse = { status: 200, data: { ok: true } };
|
|
1835
|
-
const spyFlex = jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM')
|
|
1836
|
-
.mockResolvedValue(flexResponse);
|
|
1837
|
-
const spyEvent = jest.spyOn(bppa, 'sendPublishPayloadEvent')
|
|
1838
|
-
.mockResolvedValue(undefined);
|
|
1839
|
-
const result = await bppa.handleVibeIQFile(events, eventType, 'vibeiqfile');
|
|
1840
|
-
expect(fileUploadCalls).toHaveLength(1);
|
|
1841
|
-
expect(fileUploadCalls[0].fileName).toBe('ASYNC_PUBLISH_SEASON-events.json');
|
|
1842
|
-
expect(fileUploadCalls[0].mimeType).toBe('application/json');
|
|
1843
|
-
const passedOutboundPublishEvent = spyFlex.mock.calls[0][0];
|
|
1844
|
-
expect(passedOutboundPublishEvent.taskId).toBe('task-abc');
|
|
1845
|
-
expect(passedOutboundPublishEvent.eventType).toBe(eventType);
|
|
1846
|
-
expect(passedOutboundPublishEvent.objectClass).toBe('LCSSeason');
|
|
1847
|
-
expect(passedOutboundPublishEvent.eventsFileId).toBe('file-123');
|
|
1848
|
-
expect(passedOutboundPublishEvent.eventsDownloadLink).toBe('https://download.url');
|
|
1849
|
-
expect(passedOutboundPublishEvent.eventsAdminDownloadLink).toBe('https://admin.download.url');
|
|
1850
|
-
expect(spyFlex).toHaveBeenCalledTimes(1);
|
|
1851
|
-
expect(spyEvent).toHaveBeenCalledTimes(1);
|
|
1852
|
-
expect(spyEvent).toHaveBeenCalledWith(passedOutboundPublishEvent);
|
|
1853
|
-
expect(result).toEqual({ ...flexResponse, outboundPublishEvent: passedOutboundPublishEvent });
|
|
1854
|
-
});
|
|
1855
|
-
it('should skip FlexPLM but still call sendPublishPayloadEvent when mode is vibeiqfile-dontsendtoflexplm', async () => {
|
|
1856
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1857
|
-
const spyFlex = jest.spyOn(flexplm_connect_1.FlexPLMConnect.prototype, 'sendToFlexPLM')
|
|
1858
|
-
.mockResolvedValue({});
|
|
1859
|
-
const spyEvent = jest.spyOn(bppa, 'sendPublishPayloadEvent')
|
|
1860
|
-
.mockResolvedValue(undefined);
|
|
1861
|
-
const result = await bppa.handleVibeIQFile(events, eventType, 'vibeiqfile-dontsendtoflexplm');
|
|
1862
|
-
expect(spyFlex).not.toHaveBeenCalled();
|
|
1863
|
-
expect(spyEvent).toHaveBeenCalledTimes(1);
|
|
1864
|
-
const passedOutboundPublishEvent = spyEvent.mock.calls[0][0];
|
|
1865
|
-
expect(passedOutboundPublishEvent.eventsFileId).toBe('file-123');
|
|
1866
|
-
expect(result).toEqual({
|
|
1867
|
-
message: 'Successfully Uploaded File.',
|
|
1868
|
-
outboundPublishEvent: passedOutboundPublishEvent
|
|
1869
|
-
});
|
|
1870
|
-
});
|
|
1871
|
-
it('should create an external-event with initialEvent parsed from config', async () => {
|
|
1872
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(config, dc, mapFileUtil);
|
|
1873
|
-
const outboundPublishEvent = { foo: 'bar' };
|
|
1874
|
-
await bppa.sendPublishPayloadEvent(outboundPublishEvent);
|
|
1875
|
-
expect(createCallArg).toEqual({
|
|
1876
|
-
entityName: 'external-event',
|
|
1877
|
-
object: {
|
|
1878
|
-
originSystemType: 'VibeIQ',
|
|
1879
|
-
objectClass: 'AssortmentPublishedToFlexPLM',
|
|
1880
|
-
outboundPublishEvent,
|
|
1881
|
-
initialEvent: { sourceEventId: 'src-1' }
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
});
|
|
1885
|
-
it('should default initialEvent to {} when config has no event', async () => {
|
|
1886
|
-
const bareConfig = { taskId: 'task-x' };
|
|
1887
|
-
const bppa = new base_process_publish_assortment_1.BaseProcessPublishAssortment(bareConfig, dc, mapFileUtil);
|
|
1888
|
-
const outboundPublishEvent = { hello: 'world' };
|
|
1889
|
-
await bppa.sendPublishPayloadEvent(outboundPublishEvent);
|
|
1890
|
-
expect(createCallArg).toEqual({
|
|
1891
|
-
entityName: 'external-event',
|
|
1892
|
-
object: {
|
|
1893
|
-
originSystemType: 'VibeIQ',
|
|
1894
|
-
objectClass: 'AssortmentPublishedToFlexPLM',
|
|
1895
|
-
outboundPublishEvent,
|
|
1896
|
-
initialEvent: {}
|
|
1897
|
-
}
|
|
1898
|
-
});
|
|
1899
|
-
});
|
|
1900
|
-
});
|