@yousolution/node-red-contrib-you-sap-service-layer 0.0.3 → 0.0.6
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/CHANGELOG.md +13 -3
- package/data/package.json +2 -2
- package/nodes/closeSap.html +2 -2
- package/nodes/createSap.html +7 -7
- package/nodes/crossJoinSap.html +269 -263
- package/nodes/deleteSap.html +7 -7
- package/nodes/getSap.html +7 -7
- package/nodes/listSap.html +5 -5
- package/nodes/manipulateEntitySap.html +177 -0
- package/nodes/manipulateEntitySap.js +43 -0
- package/nodes/nextLink.html +1 -1
- package/nodes/patchSap.html +6 -6
- package/nodes/serviceSap.html +207 -0
- package/nodes/serviceSap.js +41 -0
- package/nodes/support.js +29 -3
- package/package.json +4 -2
- package/resources/entities.json +59 -0
- package/resources/services.json +343 -0
- package/test/manipulateEntitySap.spec.js +191 -0
- package/test/serviceSap.spec.js +170 -0
- package/test/support.spec.js +280 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
const should = require('should');
|
|
2
|
+
const helper = require('node-red-node-test-helper');
|
|
3
|
+
const manipulateEntitySap = require('../nodes/manipulateEntitySap');
|
|
4
|
+
const Context = require('../node_modules/./@node-red/runtime/lib/nodes/context/index');
|
|
5
|
+
const sinon = require('sinon');
|
|
6
|
+
const Support = require('../nodes/support');
|
|
7
|
+
|
|
8
|
+
helper.init(require.resolve('node-red'));
|
|
9
|
+
|
|
10
|
+
describe('manipulateEntitySap Node', () => {
|
|
11
|
+
beforeEach((done) => {
|
|
12
|
+
helper.startServer(done);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function initContext(done) {
|
|
16
|
+
Context.init({
|
|
17
|
+
contextStorage: {
|
|
18
|
+
memory0: {
|
|
19
|
+
module: 'memory',
|
|
20
|
+
},
|
|
21
|
+
memory1: {
|
|
22
|
+
module: 'memory',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
Context.load().then(function () {
|
|
27
|
+
done();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
afterEach((done) => {
|
|
32
|
+
helper
|
|
33
|
+
.unload()
|
|
34
|
+
.then(function () {
|
|
35
|
+
return Context.clean({ allNodes: {} });
|
|
36
|
+
})
|
|
37
|
+
.then(function () {
|
|
38
|
+
return Context.close();
|
|
39
|
+
})
|
|
40
|
+
.then(function () {
|
|
41
|
+
helper.stopServer(done);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Restore the default sandbox here
|
|
45
|
+
sinon.restore();
|
|
46
|
+
|
|
47
|
+
// helper.unload();
|
|
48
|
+
// helper.stopServer(done);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should be loaded', (done) => {
|
|
52
|
+
const flow = [
|
|
53
|
+
{
|
|
54
|
+
id: 'n1',
|
|
55
|
+
type: 'manipulateEntitySap',
|
|
56
|
+
name: 'manipulateEntitySap',
|
|
57
|
+
wires: [['n2']],
|
|
58
|
+
z: 'flow',
|
|
59
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
helper.load(manipulateEntitySap, flow, () => {
|
|
64
|
+
initContext(function () {
|
|
65
|
+
const n1 = helper.getNode('n1');
|
|
66
|
+
|
|
67
|
+
// console.log(helper.log().args);
|
|
68
|
+
|
|
69
|
+
// n1.context().flow.set('A', 1, 'memory1', function (error) {
|
|
70
|
+
// console.log(error);
|
|
71
|
+
// });
|
|
72
|
+
|
|
73
|
+
// console.log(n1.context().flow.get('A', 'memory1'));
|
|
74
|
+
// console.log('- - - B- - - -');
|
|
75
|
+
|
|
76
|
+
// n1.id
|
|
77
|
+
// flow.push({
|
|
78
|
+
// [`_YOU_SapServiceLayer_${n1.id}.headers`]:
|
|
79
|
+
// })
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
// n1.status.calledWith({ fill: 'gray', shape: 'ring', text: 'Set credentials1' });
|
|
83
|
+
// should.equal(n1.status.calledWith({ fill: 'gray', shape: 'ring', text: 'Missing credentials' }), true);
|
|
84
|
+
n1.should.have.property('name', 'manipulateEntitySap');
|
|
85
|
+
done();
|
|
86
|
+
} catch (err) {
|
|
87
|
+
done(err);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should have correct request with data', (done) => {
|
|
94
|
+
const flow = [
|
|
95
|
+
{
|
|
96
|
+
id: 'n1',
|
|
97
|
+
type: 'manipulateEntitySap',
|
|
98
|
+
name: 'manipulateEntitySap',
|
|
99
|
+
entity: 'PickLists',
|
|
100
|
+
manipulateMethod: 'GetReleasedAllocation',
|
|
101
|
+
entityId: '123',
|
|
102
|
+
wires: [['n2']],
|
|
103
|
+
z: 'flow',
|
|
104
|
+
bodyData: 'data',
|
|
105
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
106
|
+
},
|
|
107
|
+
{ id: 'n2', type: 'helper' },
|
|
108
|
+
];
|
|
109
|
+
helper.load(manipulateEntitySap, flow, () => {
|
|
110
|
+
const n2 = helper.getNode('n2');
|
|
111
|
+
const n1 = helper.getNode('n1');
|
|
112
|
+
|
|
113
|
+
sinon.stub(Support, 'sendRequest').resolves({ data: 'ok', status: 200 });
|
|
114
|
+
|
|
115
|
+
n1.receive({ data: { cardCode: '00000001', cardName: '0000001' } });
|
|
116
|
+
|
|
117
|
+
n2.on('input', (msg) => {
|
|
118
|
+
try {
|
|
119
|
+
msg.should.have.property('_msgid');
|
|
120
|
+
msg.should.have.property('payload', 'ok');
|
|
121
|
+
msg.should.have.property('statusCode', 200);
|
|
122
|
+
done();
|
|
123
|
+
} catch (err) {
|
|
124
|
+
done(err);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should have request without data', (done) => {
|
|
131
|
+
const flow = [
|
|
132
|
+
{
|
|
133
|
+
id: 'n1',
|
|
134
|
+
type: 'manipulateEntitySap',
|
|
135
|
+
name: 'manipulateEntitySap',
|
|
136
|
+
wires: [['n2']],
|
|
137
|
+
z: 'flow',
|
|
138
|
+
bodyPost: 'data',
|
|
139
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
140
|
+
},
|
|
141
|
+
{ id: 'n2', type: 'helper' },
|
|
142
|
+
];
|
|
143
|
+
helper.load(manipulateEntitySap, flow, () => {
|
|
144
|
+
const n2 = helper.getNode('n2');
|
|
145
|
+
const n1 = helper.getNode('n1');
|
|
146
|
+
|
|
147
|
+
sinon.stub(Support, 'sendRequest').resolves({ data: 'ok', status: 200 });
|
|
148
|
+
n1.receive({});
|
|
149
|
+
|
|
150
|
+
n2.on('input', (msg) => {
|
|
151
|
+
try {
|
|
152
|
+
msg.should.have.property('_msgid');
|
|
153
|
+
msg.should.have.property('payload', 'ok');
|
|
154
|
+
done();
|
|
155
|
+
} catch (err) {
|
|
156
|
+
done(err);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('should handle the error', (done) => {
|
|
163
|
+
const flow = [
|
|
164
|
+
{
|
|
165
|
+
id: 'n1',
|
|
166
|
+
type: 'manipulateEntitySap',
|
|
167
|
+
name: 'manipulateEntitySap',
|
|
168
|
+
wires: [['n2']],
|
|
169
|
+
z: 'flow',
|
|
170
|
+
bodyPatch: 'data',
|
|
171
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
172
|
+
},
|
|
173
|
+
{ id: 'n2', type: 'helper' },
|
|
174
|
+
];
|
|
175
|
+
helper.load(manipulateEntitySap, flow, () => {
|
|
176
|
+
const n2 = helper.getNode('n2');
|
|
177
|
+
const n1 = helper.getNode('n1');
|
|
178
|
+
|
|
179
|
+
const expected = new Error('Custom error');
|
|
180
|
+
|
|
181
|
+
sinon.stub(Support, 'sendRequest').rejects(expected);
|
|
182
|
+
|
|
183
|
+
n1.receive({ data: { cardCode: '00000001', cardName: '0000001' } });
|
|
184
|
+
|
|
185
|
+
n1.on('call:error', (error) => {
|
|
186
|
+
should.deepEqual(error.args[0], expected);
|
|
187
|
+
done();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const should = require('should');
|
|
2
|
+
const helper = require('node-red-node-test-helper');
|
|
3
|
+
const serviceSap = require('../nodes/serviceSap');
|
|
4
|
+
const Context = require('../node_modules/./@node-red/runtime/lib/nodes/context/index');
|
|
5
|
+
const sinon = require('sinon');
|
|
6
|
+
const Support = require('../nodes/support');
|
|
7
|
+
|
|
8
|
+
helper.init(require.resolve('node-red'));
|
|
9
|
+
|
|
10
|
+
describe('serviceSap Node', () => {
|
|
11
|
+
beforeEach((done) => {
|
|
12
|
+
helper.startServer(done);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function initContext(done) {
|
|
16
|
+
Context.init({
|
|
17
|
+
contextStorage: {
|
|
18
|
+
memory0: {
|
|
19
|
+
module: 'memory',
|
|
20
|
+
},
|
|
21
|
+
memory1: {
|
|
22
|
+
module: 'memory',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
Context.load().then(function () {
|
|
27
|
+
done();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
afterEach((done) => {
|
|
32
|
+
helper
|
|
33
|
+
.unload()
|
|
34
|
+
.then(function () {
|
|
35
|
+
return Context.clean({ allNodes: {} });
|
|
36
|
+
})
|
|
37
|
+
.then(function () {
|
|
38
|
+
return Context.close();
|
|
39
|
+
})
|
|
40
|
+
.then(function () {
|
|
41
|
+
helper.stopServer(done);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Restore the default sandbox here
|
|
45
|
+
sinon.restore();
|
|
46
|
+
|
|
47
|
+
// helper.unload();
|
|
48
|
+
// helper.stopServer(done);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should be loaded', (done) => {
|
|
52
|
+
const flow = [
|
|
53
|
+
{
|
|
54
|
+
id: 'n1',
|
|
55
|
+
type: 'serviceSap',
|
|
56
|
+
name: 'serviceSap',
|
|
57
|
+
wires: [['n2']],
|
|
58
|
+
z: 'flow',
|
|
59
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
helper.load(serviceSap, flow, () => {
|
|
64
|
+
initContext(function () {
|
|
65
|
+
const n1 = helper.getNode('n1');
|
|
66
|
+
try {
|
|
67
|
+
n1.should.have.property('name', 'serviceSap');
|
|
68
|
+
done();
|
|
69
|
+
} catch (err) {
|
|
70
|
+
done(err);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should have correct request with data', (done) => {
|
|
77
|
+
const flow = [
|
|
78
|
+
{
|
|
79
|
+
id: 'n1',
|
|
80
|
+
type: 'serviceSap',
|
|
81
|
+
name: 'serviceSap',
|
|
82
|
+
wires: [['n2']],
|
|
83
|
+
z: 'flow',
|
|
84
|
+
bodyPost: 'data',
|
|
85
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
86
|
+
},
|
|
87
|
+
{ id: 'n2', type: 'helper' },
|
|
88
|
+
];
|
|
89
|
+
helper.load(serviceSap, flow, () => {
|
|
90
|
+
const n2 = helper.getNode('n2');
|
|
91
|
+
const n1 = helper.getNode('n1');
|
|
92
|
+
|
|
93
|
+
sinon.stub(Support, 'sendRequest').resolves('ok');
|
|
94
|
+
|
|
95
|
+
n1.receive({ data: { cardCode: '00000001', cardName: '0000001' } });
|
|
96
|
+
|
|
97
|
+
n2.on('input', (msg) => {
|
|
98
|
+
try {
|
|
99
|
+
msg.should.have.property('_msgid');
|
|
100
|
+
msg.should.have.property('payload', 'ok');
|
|
101
|
+
done();
|
|
102
|
+
} catch (err) {
|
|
103
|
+
done(err);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should have request without data', (done) => {
|
|
110
|
+
const flow = [
|
|
111
|
+
{
|
|
112
|
+
id: 'n1',
|
|
113
|
+
type: 'serviceSap',
|
|
114
|
+
name: 'serviceSap',
|
|
115
|
+
wires: [['n2']],
|
|
116
|
+
z: 'flow',
|
|
117
|
+
bodyPost: 'data',
|
|
118
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
119
|
+
},
|
|
120
|
+
{ id: 'n2', type: 'helper' },
|
|
121
|
+
];
|
|
122
|
+
helper.load(serviceSap, flow, () => {
|
|
123
|
+
const n2 = helper.getNode('n2');
|
|
124
|
+
const n1 = helper.getNode('n1');
|
|
125
|
+
|
|
126
|
+
sinon.stub(Support, 'sendRequest').resolves('ok');
|
|
127
|
+
n1.receive({});
|
|
128
|
+
|
|
129
|
+
n2.on('input', (msg) => {
|
|
130
|
+
try {
|
|
131
|
+
msg.should.have.property('_msgid');
|
|
132
|
+
msg.should.have.property('payload', 'ok');
|
|
133
|
+
done();
|
|
134
|
+
} catch (err) {
|
|
135
|
+
done(err);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should handle the error', (done) => {
|
|
142
|
+
const flow = [
|
|
143
|
+
{
|
|
144
|
+
id: 'n1',
|
|
145
|
+
type: 'serviceSap',
|
|
146
|
+
name: 'serviceSap',
|
|
147
|
+
wires: [['n2']],
|
|
148
|
+
z: 'flow',
|
|
149
|
+
bodyPost: 'data',
|
|
150
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
151
|
+
},
|
|
152
|
+
{ id: 'n2', type: 'helper' },
|
|
153
|
+
];
|
|
154
|
+
helper.load(serviceSap, flow, () => {
|
|
155
|
+
const n2 = helper.getNode('n2');
|
|
156
|
+
const n1 = helper.getNode('n1');
|
|
157
|
+
|
|
158
|
+
const expected = new Error('Custom error');
|
|
159
|
+
|
|
160
|
+
sinon.stub(Support, 'sendRequest').rejects(expected);
|
|
161
|
+
|
|
162
|
+
n1.receive({ data: { cardCode: '00000001', cardName: '0000001' } });
|
|
163
|
+
|
|
164
|
+
n1.on('call:error', (error) => {
|
|
165
|
+
should.deepEqual(error.args[0], expected);
|
|
166
|
+
done();
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
package/test/support.spec.js
CHANGED
|
@@ -555,6 +555,286 @@ describe('support library', () => {
|
|
|
555
555
|
should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
|
|
556
556
|
});
|
|
557
557
|
|
|
558
|
+
it('should generate a correct request with Services', () => {
|
|
559
|
+
const node = {
|
|
560
|
+
context: () => {
|
|
561
|
+
return {
|
|
562
|
+
flow: {
|
|
563
|
+
get: (param) => {
|
|
564
|
+
if (param == '_YOU_SapServiceLayer_1.host') {
|
|
565
|
+
return 'host';
|
|
566
|
+
}
|
|
567
|
+
if (param == '_YOU_SapServiceLayer_1.port') {
|
|
568
|
+
return 'port';
|
|
569
|
+
}
|
|
570
|
+
if (param == '_YOU_SapServiceLayer_1.version') {
|
|
571
|
+
return 'version';
|
|
572
|
+
}
|
|
573
|
+
if (param == '_YOU_SapServiceLayer_1.headers') {
|
|
574
|
+
return ['header:1', 'header:2'];
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
};
|
|
579
|
+
},
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const msg = {
|
|
583
|
+
_YOU_SapServiceLayer: {
|
|
584
|
+
idAuth: 1,
|
|
585
|
+
},
|
|
586
|
+
DocEntry: 1,
|
|
587
|
+
};
|
|
588
|
+
let config = {
|
|
589
|
+
service: 'ApprovalTemplatesService_GetApprovalTemplateList',
|
|
590
|
+
};
|
|
591
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: false, isService: true };
|
|
592
|
+
const expectedValue = {
|
|
593
|
+
axiosOptions: {
|
|
594
|
+
headers: {
|
|
595
|
+
Cookie: 'header:1;header:2',
|
|
596
|
+
},
|
|
597
|
+
method: 'POST',
|
|
598
|
+
rejectUnauthorized: false,
|
|
599
|
+
url: 'https://host:port/b1s/version/ApprovalTemplatesService_GetApprovalTemplateList',
|
|
600
|
+
withCredentials: true,
|
|
601
|
+
},
|
|
602
|
+
idAuthNode: 1,
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it('should generate a error request with Services missing service', () => {
|
|
609
|
+
const node = {
|
|
610
|
+
context: () => {
|
|
611
|
+
return {
|
|
612
|
+
flow: {
|
|
613
|
+
get: (param) => {
|
|
614
|
+
if (param == '_YOU_SapServiceLayer_1.host') {
|
|
615
|
+
return 'host';
|
|
616
|
+
}
|
|
617
|
+
if (param == '_YOU_SapServiceLayer_1.port') {
|
|
618
|
+
return 'port';
|
|
619
|
+
}
|
|
620
|
+
if (param == '_YOU_SapServiceLayer_1.version') {
|
|
621
|
+
return 'version';
|
|
622
|
+
}
|
|
623
|
+
if (param == '_YOU_SapServiceLayer_1.headers') {
|
|
624
|
+
return ['header:1', 'header:2'];
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
};
|
|
629
|
+
},
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
const msg = {
|
|
633
|
+
_YOU_SapServiceLayer: {
|
|
634
|
+
idAuth: 1,
|
|
635
|
+
},
|
|
636
|
+
DocEntry: 1,
|
|
637
|
+
};
|
|
638
|
+
let config = {
|
|
639
|
+
// service: 'ApprovalTemplatesService_GetApprovalTemplateList',
|
|
640
|
+
};
|
|
641
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: false, isService: true };
|
|
642
|
+
const expectedValue = {
|
|
643
|
+
axiosOptions: {
|
|
644
|
+
headers: {
|
|
645
|
+
Cookie: 'header:1;header:2',
|
|
646
|
+
},
|
|
647
|
+
method: 'POST',
|
|
648
|
+
rejectUnauthorized: false,
|
|
649
|
+
url: 'https://host:port/b1s/version/ApprovalTemplatesService_GetApprovalTemplateList',
|
|
650
|
+
withCredentials: true,
|
|
651
|
+
},
|
|
652
|
+
idAuthNode: 1,
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
expect(() => {
|
|
656
|
+
Support.generateRequest(node, msg, config, options);
|
|
657
|
+
}).to.throw('Missing service');
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
it('should generate a correct request with Manipulate Entity', () => {
|
|
661
|
+
const node = {
|
|
662
|
+
context: () => {
|
|
663
|
+
return {
|
|
664
|
+
flow: {
|
|
665
|
+
get: (param) => {
|
|
666
|
+
if (param == '_YOU_SapServiceLayer_1.host') {
|
|
667
|
+
return 'host';
|
|
668
|
+
}
|
|
669
|
+
if (param == '_YOU_SapServiceLayer_1.port') {
|
|
670
|
+
return 'port';
|
|
671
|
+
}
|
|
672
|
+
if (param == '_YOU_SapServiceLayer_1.version') {
|
|
673
|
+
return 'version';
|
|
674
|
+
}
|
|
675
|
+
if (param == '_YOU_SapServiceLayer_1.headers') {
|
|
676
|
+
return ['header:1', 'header:2'];
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
},
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const msg = {
|
|
685
|
+
_YOU_SapServiceLayer: {
|
|
686
|
+
idAuth: 1,
|
|
687
|
+
},
|
|
688
|
+
entityId: 3,
|
|
689
|
+
};
|
|
690
|
+
let config = {
|
|
691
|
+
entity: 'PickLists',
|
|
692
|
+
entityId: 'entityId',
|
|
693
|
+
manipulateMethod: 'GetReleasedAllocation',
|
|
694
|
+
};
|
|
695
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true };
|
|
696
|
+
const expectedValue = {
|
|
697
|
+
axiosOptions: {
|
|
698
|
+
headers: {
|
|
699
|
+
Cookie: 'header:1;header:2',
|
|
700
|
+
},
|
|
701
|
+
method: 'POST',
|
|
702
|
+
rejectUnauthorized: false,
|
|
703
|
+
url: 'https://host:port/b1s/version/PickLists(3)/GetReleasedAllocation',
|
|
704
|
+
withCredentials: true,
|
|
705
|
+
},
|
|
706
|
+
idAuthNode: 1,
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
it('should generate an error request with Manipulate Entity missing entity', () => {
|
|
713
|
+
const node = {
|
|
714
|
+
context: () => {
|
|
715
|
+
return {
|
|
716
|
+
flow: {
|
|
717
|
+
get: (param) => {
|
|
718
|
+
if (param == '_YOU_SapServiceLayer_1.host') {
|
|
719
|
+
return 'host';
|
|
720
|
+
}
|
|
721
|
+
if (param == '_YOU_SapServiceLayer_1.port') {
|
|
722
|
+
return 'port';
|
|
723
|
+
}
|
|
724
|
+
if (param == '_YOU_SapServiceLayer_1.version') {
|
|
725
|
+
return 'version';
|
|
726
|
+
}
|
|
727
|
+
if (param == '_YOU_SapServiceLayer_1.headers') {
|
|
728
|
+
return ['header:1', 'header:2'];
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
},
|
|
732
|
+
};
|
|
733
|
+
},
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
const msg = {
|
|
737
|
+
_YOU_SapServiceLayer: {
|
|
738
|
+
idAuth: 1,
|
|
739
|
+
},
|
|
740
|
+
entityId: 3,
|
|
741
|
+
};
|
|
742
|
+
let config = {
|
|
743
|
+
// entity: 'PickLists',
|
|
744
|
+
entityId: 'entityId',
|
|
745
|
+
manipulateMethod: 'GetReleasedAllocation',
|
|
746
|
+
};
|
|
747
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true };
|
|
748
|
+
|
|
749
|
+
expect(() => {
|
|
750
|
+
Support.generateRequest(node, msg, config, options);
|
|
751
|
+
}).to.throw('Missing entity');
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
it('should generate an error request with Manipulate Entity missing entity id', () => {
|
|
755
|
+
const node = {
|
|
756
|
+
context: () => {
|
|
757
|
+
return {
|
|
758
|
+
flow: {
|
|
759
|
+
get: (param) => {
|
|
760
|
+
if (param == '_YOU_SapServiceLayer_1.host') {
|
|
761
|
+
return 'host';
|
|
762
|
+
}
|
|
763
|
+
if (param == '_YOU_SapServiceLayer_1.port') {
|
|
764
|
+
return 'port';
|
|
765
|
+
}
|
|
766
|
+
if (param == '_YOU_SapServiceLayer_1.version') {
|
|
767
|
+
return 'version';
|
|
768
|
+
}
|
|
769
|
+
if (param == '_YOU_SapServiceLayer_1.headers') {
|
|
770
|
+
return ['header:1', 'header:2'];
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
};
|
|
775
|
+
},
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
const msg = {
|
|
779
|
+
_YOU_SapServiceLayer: {
|
|
780
|
+
idAuth: 1,
|
|
781
|
+
},
|
|
782
|
+
entityId: 3,
|
|
783
|
+
};
|
|
784
|
+
let config = {
|
|
785
|
+
entity: 'PickLists',
|
|
786
|
+
// entityId: 'entityId',
|
|
787
|
+
manipulateMethod: 'GetReleasedAllocation',
|
|
788
|
+
};
|
|
789
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true };
|
|
790
|
+
|
|
791
|
+
expect(() => {
|
|
792
|
+
Support.generateRequest(node, msg, config, options);
|
|
793
|
+
}).to.throw('Missing entityId');
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
it('should generate an error request with Manipulate Entity missing method', () => {
|
|
797
|
+
const node = {
|
|
798
|
+
context: () => {
|
|
799
|
+
return {
|
|
800
|
+
flow: {
|
|
801
|
+
get: (param) => {
|
|
802
|
+
if (param == '_YOU_SapServiceLayer_1.host') {
|
|
803
|
+
return 'host';
|
|
804
|
+
}
|
|
805
|
+
if (param == '_YOU_SapServiceLayer_1.port') {
|
|
806
|
+
return 'port';
|
|
807
|
+
}
|
|
808
|
+
if (param == '_YOU_SapServiceLayer_1.version') {
|
|
809
|
+
return 'version';
|
|
810
|
+
}
|
|
811
|
+
if (param == '_YOU_SapServiceLayer_1.headers') {
|
|
812
|
+
return ['header:1', 'header:2'];
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
},
|
|
816
|
+
};
|
|
817
|
+
},
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
const msg = {
|
|
821
|
+
_YOU_SapServiceLayer: {
|
|
822
|
+
idAuth: 1,
|
|
823
|
+
},
|
|
824
|
+
entityId: 3,
|
|
825
|
+
};
|
|
826
|
+
let config = {
|
|
827
|
+
entity: 'PickLists',
|
|
828
|
+
entityId: 'entityId',
|
|
829
|
+
// manipulateMethod: 'GetReleasedAllocation',
|
|
830
|
+
};
|
|
831
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true };
|
|
832
|
+
|
|
833
|
+
expect(() => {
|
|
834
|
+
Support.generateRequest(node, msg, config, options);
|
|
835
|
+
}).to.throw('Missing method');
|
|
836
|
+
});
|
|
837
|
+
|
|
558
838
|
it('should have error missing object', () => {
|
|
559
839
|
const node = {
|
|
560
840
|
context: () => {
|