-
Notifications
You must be signed in to change notification settings - Fork 5
/
batch_operations_upsert_test.js
53 lines (41 loc) · 1.52 KB
/
batch_operations_upsert_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const testedResource = require('../common.js').testedResource;
const http = require('../http.js');
const entitiesResource = testedResource + '/entities/';
const batchUpsertResource = testedResource + '/entityOperations/upsert';
describe('Batch Entity Upsert. JSON', () => {
const entity1 = {
id: 'urn:ngsi-ld:T:' + new Date().getTime(),
type: 'T'
};
const entity2 = {
id: 'urn:ngsi-ld:T:' + new Date().getTime() + 1,
type: 'T',
P1: {
type: 'Property',
value: 'Hola'
}
};
const entities = [entity1, entity2];
const entityIds = [encodeURIComponent(entity1.id), encodeURIComponent(entity2.id)];
beforeAll(() => {
const requests = [];
for (let j = 0; j < entities.length; j++) {
requests.push(http.post(entitiesResource, entities[j]));
}
return Promise.all(requests);
});
afterAll(() => {
const requests = [];
for (let j = 0; j < entityIds.length; j++) {
requests.push(http.delete(entitiesResource + entityIds[j]));
}
return Promise.all(requests);
});
it('should upsert a list of entities 004', async function() {
// const entities2 = [entity1, entity2];
// Default mode is replace (for upsert)
const response = await http.post(batchUpsertResource, entities);
expect(response.response).toHaveProperty('statusCode', 204);
//assertBatchOperation(response, [entities2[0].id, entities2[1].id], []);
});
});