raain-model 0.2.7 → 0.3.1
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/EventNode.d.ts +10 -0
- package/EventNode.js +17 -0
- package/EventNode.js.map +1 -0
- package/GaugeMeasure.d.ts +7 -0
- package/GaugeMeasure.js +31 -0
- package/GaugeMeasure.js.map +1 -0
- package/GaugeMeasureValue.d.ts +16 -0
- package/GaugeMeasureValue.js +66 -0
- package/GaugeMeasureValue.js.map +1 -0
- package/GaugeNode.d.ts +19 -0
- package/GaugeNode.js +48 -0
- package/GaugeNode.js.map +1 -0
- package/GaugeNodeMap.d.ts +22 -0
- package/GaugeNodeMap.js +61 -0
- package/GaugeNodeMap.js.map +1 -0
- package/{src/IMeasureValue.ts → IMeasureValue.d.ts} +4 -13
- package/IMeasureValue.js +3 -0
- package/IMeasureValue.js.map +1 -0
- package/IVersion.d.ts +3 -0
- package/IVersion.js +3 -0
- package/IVersion.js.map +1 -0
- package/Link.d.ts +17 -0
- package/Link.js +36 -0
- package/Link.js.map +1 -0
- package/Measure.d.ts +9 -0
- package/Measure.js +43 -0
- package/Measure.js.map +1 -0
- package/MeasureValuePolarContainer.d.ts +7 -0
- package/{src/MeasureValuePolarContainer.ts → MeasureValuePolarContainer.js} +11 -17
- package/MeasureValuePolarContainer.js.map +1 -0
- package/PeopleNode.d.ts +7 -0
- package/PeopleNode.js +14 -0
- package/PeopleNode.js.map +1 -0
- package/PolarValue.d.ts +6 -0
- package/PolarValue.js +12 -0
- package/PolarValue.js.map +1 -0
- package/README.md +2 -3
- package/RELEASE.md +6 -0
- package/RaainNode.d.ts +18 -0
- package/RaainNode.js +103 -0
- package/RaainNode.js.map +1 -0
- package/RadarMeasure.d.ts +7 -0
- package/RadarMeasure.js +31 -0
- package/RadarMeasure.js.map +1 -0
- package/RadarMeasureValue.d.ts +19 -0
- package/RadarMeasureValue.js +75 -0
- package/RadarMeasureValue.js.map +1 -0
- package/RadarNode.d.ts +14 -0
- package/RadarNode.js +49 -0
- package/RadarNode.js.map +1 -0
- package/RadarNodeMap.d.ts +11 -0
- package/RadarNodeMap.js +56 -0
- package/RadarNodeMap.js.map +1 -0
- package/RainComputationMap.d.ts +11 -0
- package/RainComputationMap.js +59 -0
- package/RainComputationMap.js.map +1 -0
- package/RainComputationNode.d.ts +42 -0
- package/RainComputationNode.js +148 -0
- package/RainComputationNode.js.map +1 -0
- package/RainMeasure.d.ts +5 -0
- package/RainMeasure.js +29 -0
- package/RainMeasure.js.map +1 -0
- package/RainMeasureValue.d.ts +21 -0
- package/RainMeasureValue.js +74 -0
- package/RainMeasureValue.js.map +1 -0
- package/RainNode.d.ts +21 -0
- package/RainNode.js +107 -0
- package/RainNode.js.map +1 -0
- package/{src/index.ts → index.d.ts} +0 -0
- package/index.js +26 -0
- package/index.js.map +1 -0
- package/package.json +6 -7
- package/tools/PolarValues.d.ts +16 -0
- package/{src/tools/PolarValues.ts → tools/PolarValues.js} +46 -49
- package/tools/PolarValues.js.map +1 -0
- package/.travis.deploy.sh +0 -49
- package/.travis.yml +0 -20
- package/examples/creation.example.ts +0 -17
- package/examples/helper.js +0 -113
- package/examples/v1/asCustomer.spec.js +0 -656
- package/src/EventNode.ts +0 -17
- package/src/GaugeMeasure.ts +0 -13
- package/src/GaugeMeasureValue.ts +0 -77
- package/src/GaugeNode.ts +0 -46
- package/src/GaugeNodeMap.ts +0 -57
- package/src/Link.ts +0 -28
- package/src/Measure.ts +0 -36
- package/src/PeopleNode.ts +0 -12
- package/src/PolarValue.ts +0 -9
- package/src/RaainNode.ts +0 -92
- package/src/RadarMeasure.ts +0 -13
- package/src/RadarMeasureValue.ts +0 -93
- package/src/RadarNode.ts +0 -46
- package/src/RadarNodeMap.ts +0 -53
- package/src/RainComputationMap.ts +0 -60
- package/src/RainComputationNode.ts +0 -175
- package/src/RainMeasure.ts +0 -9
- package/src/RainMeasureValue.ts +0 -83
- package/src/RainNode.ts +0 -104
- package/tsconfig.json +0 -14
|
@@ -1,656 +0,0 @@
|
|
|
1
|
-
const chai = require('chai');
|
|
2
|
-
chai.use(require('chai-as-promised'));
|
|
3
|
-
const should = chai.should();
|
|
4
|
-
const {promisify} = require('util');
|
|
5
|
-
const sleep = promisify(setTimeout);
|
|
6
|
-
const _helper = require('../helper');
|
|
7
|
-
const _$app = _helper.$app;
|
|
8
|
-
const _request = _helper.request;
|
|
9
|
-
|
|
10
|
-
const RadarNode = _helper.RadarNode;
|
|
11
|
-
const RadarNodeMap = _helper.RadarNodeMap;
|
|
12
|
-
const RainNode = _helper.RainNode;
|
|
13
|
-
const GaugeNode = _helper.GaugeNode;
|
|
14
|
-
const RadarMeasure = _helper.RadarMeasure;
|
|
15
|
-
const RainComputationNode = _helper.RainComputationNode;
|
|
16
|
-
const RainComputationMap = _helper.RainComputationMap;
|
|
17
|
-
const RadarMeasureValue = _helper.RadarMeasureValue;
|
|
18
|
-
const RainMeasureValue = _helper.RainMeasureValue;
|
|
19
|
-
const MeasureValuePolarContainer = _helper.MeasureValuePolarContainer;
|
|
20
|
-
const RainMeasure = _helper.RainMeasure;
|
|
21
|
-
const GaugeMeasure = _helper.GaugeMeasure;
|
|
22
|
-
const GaugeNodeMap = _helper.GaugeNodeMap;
|
|
23
|
-
|
|
24
|
-
describe('as Customer with all roles', function () {
|
|
25
|
-
|
|
26
|
-
const _created = {};
|
|
27
|
-
|
|
28
|
-
before(async () => {
|
|
29
|
-
await _helper.cleanup();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
after(async () => {
|
|
33
|
-
// await _helper.cleanup();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
xdescribe('during team setup', () => {
|
|
37
|
-
|
|
38
|
-
it('should get my team', () => {
|
|
39
|
-
'todo'.should.equal('todo?', 'alors moi je dis...');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
xdescribe('during radars setup', () => {
|
|
45
|
-
|
|
46
|
-
xit('should 401 from not authorized user', async () => {
|
|
47
|
-
const res = await _request(await _$app)
|
|
48
|
-
.get('/v1/radars')
|
|
49
|
-
// .auth('username', 'password')
|
|
50
|
-
// .set('Accept', 'application/json')
|
|
51
|
-
.expect('Content-Type', /application\/json/)
|
|
52
|
-
.expect(401)
|
|
53
|
-
.expect(/Authorization needed \(012\)/);
|
|
54
|
-
|
|
55
|
-
res.body.should.equal('???');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should create a new radar', async () => {
|
|
59
|
-
const res = await _request(await _$app)
|
|
60
|
-
.post('/v1/radars')
|
|
61
|
-
.send({
|
|
62
|
-
name: 'asCustomer.testPost',
|
|
63
|
-
latitude: 5.6,
|
|
64
|
-
longitude: -4.2
|
|
65
|
-
})
|
|
66
|
-
.expect('Content-Type', /application\/json/)
|
|
67
|
-
.expect(201);
|
|
68
|
-
|
|
69
|
-
_created.createdRadar = new RadarNode(res.body);
|
|
70
|
-
_created.createdRadar.should.not.be.undefined;
|
|
71
|
-
_created.createdRadar.id.should.not.be.undefined;
|
|
72
|
-
_created.createdRadar.name.should.equal('asCustomer.testPost');
|
|
73
|
-
_created.createdRadar.latitude.should.equal(5.6);
|
|
74
|
-
_created.createdRadar.longitude.should.equal(-4.2);
|
|
75
|
-
_created.createdRadar.getLink('rain').should.be.not.undefined;
|
|
76
|
-
_created.createdRadar.getLinkId('rain').should.be.not.undefined;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should modify the created radar', async () => {
|
|
80
|
-
const res = await _request(await _$app)
|
|
81
|
-
.put('/v1/radars/' + _created.createdRadar.id)
|
|
82
|
-
.send({
|
|
83
|
-
name: 'asCustomer.testPut',
|
|
84
|
-
latitude: 9.2,
|
|
85
|
-
longitude: 7.2
|
|
86
|
-
})
|
|
87
|
-
.expect('Content-Type', /application\/json/)
|
|
88
|
-
.expect(200);
|
|
89
|
-
|
|
90
|
-
const modifiedRadar = new RadarNode(res.body);
|
|
91
|
-
modifiedRadar.should.not.be.undefined;
|
|
92
|
-
modifiedRadar.id.should.not.be.undefined;
|
|
93
|
-
modifiedRadar.name.should.equal('asCustomer.testPut');
|
|
94
|
-
modifiedRadar.latitude.should.equal(9.2);
|
|
95
|
-
modifiedRadar.longitude.should.equal(7.2);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should get the radar information', async () => {
|
|
99
|
-
const res = await _request(await _$app)
|
|
100
|
-
.get('/v1/radars/' + _created.createdRadar.id)
|
|
101
|
-
.expect('Content-Type', /application\/json/)
|
|
102
|
-
.expect(200);
|
|
103
|
-
|
|
104
|
-
const receivedRadar = new RadarNode(res.body);
|
|
105
|
-
receivedRadar.should.not.be.undefined;
|
|
106
|
-
receivedRadar.id.should.not.be.undefined;
|
|
107
|
-
receivedRadar.name.should.equal('asCustomer.testPut');
|
|
108
|
-
receivedRadar.latitude.should.equal(9.2);
|
|
109
|
-
receivedRadar.longitude.should.equal(7.2);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
xit('should not create another radar', async () => {
|
|
113
|
-
await _request(await _$app)
|
|
114
|
-
.post('/v1/radars')
|
|
115
|
-
.send({
|
|
116
|
-
name: 'asCustomer.anotherTest',
|
|
117
|
-
latitude: 1,
|
|
118
|
-
longitude: 1
|
|
119
|
-
})
|
|
120
|
-
.expect('Content-Type', /application\/json/)
|
|
121
|
-
.expect(409);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should post radar measures', async () => {
|
|
125
|
-
let values = _buildRadarMeasures(8);
|
|
126
|
-
_created.createdRadarMeasures = [];
|
|
127
|
-
const date1 = new Date('2018-06-01 13:05:00') // 2018-06-01T11:05:00.000Z
|
|
128
|
-
let res = await _request(await _$app)
|
|
129
|
-
.post('/v1/radars/' + _created.createdRadar.id + '/measures')
|
|
130
|
-
// .set('Authorization', 'Basic ' + btoa('' + _mocks.userAdmin.email + ':' + _mocks.userAdmin.password))
|
|
131
|
-
.send({
|
|
132
|
-
date: date1.toISOString(),
|
|
133
|
-
values: values
|
|
134
|
-
})
|
|
135
|
-
.expect('Content-Type', /application\/json/)
|
|
136
|
-
.expect(201);
|
|
137
|
-
|
|
138
|
-
const measure = new RadarMeasure(res.body)
|
|
139
|
-
measure.should.be.not.undefined;
|
|
140
|
-
measure.id.should.be.not.undefined;
|
|
141
|
-
measure.date.should.equal(date1.toISOString());
|
|
142
|
-
measure.values.length.should.equal(values.length);
|
|
143
|
-
_created.createdRadarMeasures.push(measure);
|
|
144
|
-
|
|
145
|
-
// Post other ones, for fun :)
|
|
146
|
-
for (let i = 0; i < 20; i++) {
|
|
147
|
-
values = _buildRadarMeasures(i + 5);
|
|
148
|
-
const otherDate = new Date(new Date('2018-06-01 13:12:34').getTime() + (i * 5 * 60000)); // 2018-06-01T11:12:34.000Z + (i * 5min)
|
|
149
|
-
res = await _request(await _$app)
|
|
150
|
-
.post('/v1/radars/' + _created.createdRadar.id + '/measures')
|
|
151
|
-
.send({
|
|
152
|
-
date: otherDate.toISOString(),
|
|
153
|
-
values: values
|
|
154
|
-
})
|
|
155
|
-
.expect('Content-Type', /application\/json/)
|
|
156
|
-
.expect(201);
|
|
157
|
-
|
|
158
|
-
_created.createdRadarMeasures.push(new RadarMeasure(res.body));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}).timeout(60000);
|
|
162
|
-
|
|
163
|
-
it('should get the radar measures information', async () => {
|
|
164
|
-
const res = await _request(await _$app)
|
|
165
|
-
.get('/v1/radars/' + _created.createdRadar.id + '/measures/' + _created.createdRadarMeasures[0].id)
|
|
166
|
-
//.set('Authorization', 'Basic ' + btoa('' + _mocks.userAdmin.email + ':' + _mocks.userAdmin.password))
|
|
167
|
-
.expect('Content-Type', /application\/json/)
|
|
168
|
-
.expect(200);
|
|
169
|
-
|
|
170
|
-
const radarMeasure = new RadarMeasure(res.body);
|
|
171
|
-
radarMeasure.id.should.equal(_created.createdRadarMeasures[0].id);
|
|
172
|
-
radarMeasure.date.should.equal(_created.createdRadarMeasures[0].date);
|
|
173
|
-
radarMeasure.values.length.should.equal(_created.createdRadarMeasures[0].values.length);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
xit('should get the radar information as a map format', async () => {
|
|
177
|
-
const res = await _request(await _$app)
|
|
178
|
-
.get('/v1/radars/' + _created.createdRadar.id + '?format=map&begin=2018-06-01 12:05:06&end=2018-06-01 13:05:06')
|
|
179
|
-
.expect('Content-Type', /application\/json/)
|
|
180
|
-
.expect(200);
|
|
181
|
-
|
|
182
|
-
const receivedRadarMap = new RadarNodeMap(res.body);
|
|
183
|
-
receivedRadarMap.should.not.be.undefined;
|
|
184
|
-
receivedRadarMap.id.should.not.be.undefined;
|
|
185
|
-
receivedRadarMap.getMapData().length.should.equal(1);
|
|
186
|
-
receivedRadarMap.getMapData()[0].id.should.not.be.undefined;
|
|
187
|
-
receivedRadarMap.getMapData()[0].date.should.not.be.undefined;
|
|
188
|
-
receivedRadarMap.getMapData()[0].values.length.should.equal(3);
|
|
189
|
-
|
|
190
|
-
const radarMeasure0 = new RadarMeasure(receivedRadarMap.getMapData()[0]);
|
|
191
|
-
radarMeasure0.id.should.not.be.undefined;
|
|
192
|
-
radarMeasure0.date.should.not.be.undefined;
|
|
193
|
-
|
|
194
|
-
const measure0 = new RadarMeasureValue(radarMeasure0.values[0]);
|
|
195
|
-
measure0.angle.should.equal(0.4);
|
|
196
|
-
measure0.getPolars().length.should.equal(720);
|
|
197
|
-
new MeasureValuePolarContainer(measure0.getPolars()[200]).azimuth.should.equal(100);
|
|
198
|
-
new MeasureValuePolarContainer(measure0.getPolars()[200]).distance.should.equal(1000);
|
|
199
|
-
new MeasureValuePolarContainer(measure0.getPolars()[200]).polarEdges.length.should.equal(250);
|
|
200
|
-
|
|
201
|
-
const measure1 = new RadarMeasureValue(radarMeasure0.values[1]);
|
|
202
|
-
measure1.angle.should.equal(1.4);
|
|
203
|
-
measure1.getPolars().length.should.equal(720);
|
|
204
|
-
new MeasureValuePolarContainer(measure1.getPolars()[200]).azimuth.should.equal(100);
|
|
205
|
-
new MeasureValuePolarContainer(measure1.getPolars()[200]).distance.should.equal(1000);
|
|
206
|
-
new MeasureValuePolarContainer(measure1.getPolars()[200]).polarEdges.length.should.equal(250);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
xdescribe('during gauges setup', () => {
|
|
212
|
-
|
|
213
|
-
xit('should 401 from not authorized user', async () => {
|
|
214
|
-
const res = await _request(await _$app)
|
|
215
|
-
.get('/v1/gauges')
|
|
216
|
-
// .auth('username', 'password')
|
|
217
|
-
// .set('Accept', 'application/json')
|
|
218
|
-
.expect('Content-Type', /application\/json/)
|
|
219
|
-
.expect(401)
|
|
220
|
-
.expect(/Authorization needed \(012\)/);
|
|
221
|
-
|
|
222
|
-
res.body.should.equal('???');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('should create a new gauge', async () => {
|
|
226
|
-
const res = await _request(await _$app)
|
|
227
|
-
.post('/v1/gauges')
|
|
228
|
-
.send({
|
|
229
|
-
name: 'asCustomer.testPost',
|
|
230
|
-
latitude: 5.6,
|
|
231
|
-
longitude: -4.2
|
|
232
|
-
})
|
|
233
|
-
.expect('Content-Type', /application\/json/)
|
|
234
|
-
.expect(201);
|
|
235
|
-
|
|
236
|
-
_created.createdGauge = new GaugeNode(res.body);
|
|
237
|
-
_created.createdGauge.should.not.be.undefined;
|
|
238
|
-
_created.createdGauge.id.should.not.be.undefined;
|
|
239
|
-
_created.createdGauge.name.should.equal('asCustomer.testPost');
|
|
240
|
-
_created.createdGauge.latitude.should.equal(5.6);
|
|
241
|
-
_created.createdGauge.longitude.should.equal(-4.2);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('should modify the created gauge', async () => {
|
|
245
|
-
const res = await _request(await _$app)
|
|
246
|
-
.put('/v1/gauges/' + _created.createdGauge.id)
|
|
247
|
-
.send({
|
|
248
|
-
name: 'asCustomer.testPut',
|
|
249
|
-
latitude: 9.3,
|
|
250
|
-
longitude: 7.3
|
|
251
|
-
})
|
|
252
|
-
.expect('Content-Type', /application\/json/)
|
|
253
|
-
.expect(200);
|
|
254
|
-
|
|
255
|
-
const modifiedGauge = new GaugeNode(res.body);
|
|
256
|
-
modifiedGauge.should.not.be.undefined;
|
|
257
|
-
modifiedGauge.id.should.not.be.undefined;
|
|
258
|
-
modifiedGauge.name.should.equal('asCustomer.testPut');
|
|
259
|
-
modifiedGauge.latitude.should.equal(9.3);
|
|
260
|
-
modifiedGauge.longitude.should.equal(7.3);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it('should get the gauge information', async () => {
|
|
264
|
-
const res = await _request(await _$app)
|
|
265
|
-
.get('/v1/gauges/' + _created.createdGauge.id)
|
|
266
|
-
.expect('Content-Type', /application\/json/)
|
|
267
|
-
.expect(200);
|
|
268
|
-
|
|
269
|
-
const receivedGauge = new GaugeNode(res.body);
|
|
270
|
-
receivedGauge.should.not.be.undefined;
|
|
271
|
-
receivedGauge.id.should.not.be.undefined;
|
|
272
|
-
receivedGauge.name.should.equal('asCustomer.testPut');
|
|
273
|
-
receivedGauge.latitude.should.equal(9.3);
|
|
274
|
-
receivedGauge.longitude.should.equal(7.3);
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('should get the all gauges information', async () => {
|
|
278
|
-
const res = await _request(await _$app)
|
|
279
|
-
.get('/v1/gauges')
|
|
280
|
-
.expect('Content-Type', /application\/json/)
|
|
281
|
-
.expect(200);
|
|
282
|
-
|
|
283
|
-
const receivedGauges = res.body.gauges;
|
|
284
|
-
receivedGauges.length.should.be.equal(1);
|
|
285
|
-
receivedGauges.forEach(rg => {
|
|
286
|
-
const gauge = new GaugeNode(rg);
|
|
287
|
-
gauge.id.should.not.be.undefined;
|
|
288
|
-
gauge.name.should.equal('asCustomer.testPut');
|
|
289
|
-
gauge.latitude.should.equal(9.3);
|
|
290
|
-
gauge.longitude.should.equal(7.3);
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('should post gauge measures', async () => {
|
|
295
|
-
let value = 7.65; // _buildGaugeMeasure();
|
|
296
|
-
let res = await _request(await _$app)
|
|
297
|
-
.post('/v1/gauges/' + _created.createdGauge.id + '/measures')
|
|
298
|
-
// .set('Authorization', 'Basic ' + btoa('' + _mocks.userAdmin.email + ':' + _mocks.userAdmin.password))
|
|
299
|
-
.send({
|
|
300
|
-
date: '2018-06-01T11:05:00.000Z',
|
|
301
|
-
values: [value]
|
|
302
|
-
})
|
|
303
|
-
.expect('Content-Type', /application\/json/)
|
|
304
|
-
.expect(201);
|
|
305
|
-
|
|
306
|
-
const measure = new GaugeMeasure(res.body)
|
|
307
|
-
measure.should.be.not.undefined;
|
|
308
|
-
measure.id.should.be.not.undefined;
|
|
309
|
-
measure.date.should.be.equal('2018-06-01T11:05:00.000Z');
|
|
310
|
-
|
|
311
|
-
// Post other ones, for fun :)
|
|
312
|
-
for (let i = 0; i < 100; i++) {
|
|
313
|
-
value = Math.random() * 10;
|
|
314
|
-
const otherDate = new Date(new Date('2018-06-01T11:05:07.000Z').getTime() + (i * 5 * 60000)); // +(i * 5min)
|
|
315
|
-
res = await _request(await _$app)
|
|
316
|
-
.post('/v1/gauges/' + _created.createdGauge.id + '/measures')
|
|
317
|
-
.send({
|
|
318
|
-
date: otherDate,
|
|
319
|
-
values: [value]
|
|
320
|
-
})
|
|
321
|
-
.expect('Content-Type', /application\/json/)
|
|
322
|
-
.expect(201);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
it('should get gauge measures', async () => {
|
|
328
|
-
const res = await _request(await _$app)
|
|
329
|
-
.get('/v1/gauges/' + _created.createdGauge.id + '?format=map&begin=2018-06-01 12:05:06&end=2018-06-01 13:05:06')
|
|
330
|
-
.expect('Content-Type', /application\/json/)
|
|
331
|
-
.expect(200);
|
|
332
|
-
|
|
333
|
-
const receivedGaugeMap = new GaugeNodeMap(res.body);
|
|
334
|
-
receivedGaugeMap.id.should.be.equal(_created.createdGauge.id);
|
|
335
|
-
receivedGaugeMap.getMapData().length.should.be.equal(1);
|
|
336
|
-
const gaugeMeasuresMap = receivedGaugeMap.getMapData();
|
|
337
|
-
gaugeMeasuresMap[0].values[0].should.be.equal(7.65);
|
|
338
|
-
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
xdescribe('expecting rains computations', () => {
|
|
344
|
-
|
|
345
|
-
it('should get the created radar linked rains zones', async () => {
|
|
346
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
347
|
-
rainId.should.be.not.undefined;
|
|
348
|
-
|
|
349
|
-
let res = await _request(await _$app)
|
|
350
|
-
.get('/v1/rains/' + rainId)
|
|
351
|
-
.expect('Content-Type', /application\/json/)
|
|
352
|
-
.expect(200);
|
|
353
|
-
|
|
354
|
-
_created.createdRain = new RainNode(res.body);
|
|
355
|
-
_created.createdRain.should.be.not.undefined;
|
|
356
|
-
_created.createdRain.id.should.be.equal(rainId);
|
|
357
|
-
_created.createdRain.status.should.equal(0);
|
|
358
|
-
_created.createdRain.quality.should.equal(-1);
|
|
359
|
-
_created.createdRain.getLinkId('radar').should.equal(_created.createdRadar.id);
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
it('should not modify rain zone and wait for rain validation by raain team (ask to your sales@raain.io)', async () => {
|
|
363
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
364
|
-
await _request(await _$app)
|
|
365
|
-
.put('/v1/rains/' + rainId)
|
|
366
|
-
.send({
|
|
367
|
-
step: 'prepare',
|
|
368
|
-
radarMeasureToIdentifyEchoes: _created.createdRadarMeasures[0].id,
|
|
369
|
-
inputsAreValidated: 1
|
|
370
|
-
})
|
|
371
|
-
.expect('Content-Type', /application\/json/)
|
|
372
|
-
.expect(403);
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it('should get before any computation what is the status of the zone (prepared/ready or not)', async () => {
|
|
376
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
377
|
-
let res = {body: {}};
|
|
378
|
-
let rainNode = new RainNode(res.body);
|
|
379
|
-
|
|
380
|
-
for (let i = 0; rainNode.status !== 1 && i < 20; i++) {
|
|
381
|
-
await sleep(10000);
|
|
382
|
-
res = await _request(await _$app)
|
|
383
|
-
.get('/v1/rains/' + rainId)
|
|
384
|
-
.expect('Content-Type', /application\/json/);
|
|
385
|
-
|
|
386
|
-
rainNode = new RainNode(res.body);
|
|
387
|
-
rainNode.status.should.be.gte(0.2); // rainNode in progress
|
|
388
|
-
// rainNode.quality.should.equal(1); // === system still doesn't know rainNode quality
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
console.log(res.status, rainNode);
|
|
392
|
-
if (rainNode.status !== 1) {
|
|
393
|
-
process.exit(1); // we can't move forward
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
res.status.should.equal(200);
|
|
397
|
-
rainNode.status.should.equal(1);
|
|
398
|
-
rainNode.quality.should.equal(1);
|
|
399
|
-
|
|
400
|
-
}).timeout(240000);
|
|
401
|
-
|
|
402
|
-
it('should ask (post) for rain computation', async () => {
|
|
403
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
404
|
-
let res = await _request(await _$app)
|
|
405
|
-
.post('/v1/rains/' + rainId + '/computations')
|
|
406
|
-
.send({
|
|
407
|
-
periodBegin: new Date('2018-06-01 13:05:00'),
|
|
408
|
-
periodEnd: new Date('2018-06-01 14:10:00'),
|
|
409
|
-
limit: 10
|
|
410
|
-
})
|
|
411
|
-
.expect('Content-Type', /application\/json/)
|
|
412
|
-
.expect(202);
|
|
413
|
-
|
|
414
|
-
const computations = res.body.computations;
|
|
415
|
-
computations.length.should.equal(10);
|
|
416
|
-
_created.createdRainComputation = new RainComputationNode(computations[0]);
|
|
417
|
-
|
|
418
|
-
for (let index = 0; index < computations.length; index++) {
|
|
419
|
-
const c = computations[index];
|
|
420
|
-
const rc = new RainComputationNode(c);
|
|
421
|
-
const begin = new Date(_created.createdRadarMeasures[index].date);
|
|
422
|
-
const end = new Date(begin.getTime() + 5 * 60000);
|
|
423
|
-
rc.id.should.be.not.undefined;
|
|
424
|
-
rc.periodBegin.should.equal(begin.toISOString());
|
|
425
|
-
rc.periodEnd.should.equal(end.toISOString());
|
|
426
|
-
// rc.progressIngest.should.equal(1);
|
|
427
|
-
rc.progressComputing.should.equal(0.5);
|
|
428
|
-
rc.launchedBy.should.equal('demo');
|
|
429
|
-
rc.getLinkId('radar', 0).should.equal(_created.createdRadar.id);
|
|
430
|
-
rc.getLinkId('rain').should.equal(rainId);
|
|
431
|
-
rc.getLinkId('radar-measure').should.equal(_created.createdRadarMeasures[index].id);
|
|
432
|
-
}
|
|
433
|
-
}).timeout(100000);
|
|
434
|
-
|
|
435
|
-
xit('should get the rain computation in progress status', async () => {
|
|
436
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
437
|
-
|
|
438
|
-
let res = await _request(await _$app)
|
|
439
|
-
.get('/v1/rains/' + rainId + '/computations/' + _created.createdRainComputation.id)
|
|
440
|
-
.expect('Content-Type', /application\/json/)
|
|
441
|
-
.expect(202);
|
|
442
|
-
|
|
443
|
-
const rainComputation = new RainComputationNode(res.body);
|
|
444
|
-
rainComputation.progressComputing.should.be.greaterThan(0);
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
it('should get the rain computation final status', async () => {
|
|
448
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
449
|
-
await sleep(2000);
|
|
450
|
-
|
|
451
|
-
let res = await _request(await _$app)
|
|
452
|
-
.get('/v1/rains/' + rainId + '/computations/' + _created.createdRainComputation.id)
|
|
453
|
-
.expect('Content-Type', /application\/json/)
|
|
454
|
-
.expect(200);
|
|
455
|
-
|
|
456
|
-
const rainComputation = new RainComputationNode(res.body);
|
|
457
|
-
rainComputation.should.be.not.undefined;
|
|
458
|
-
rainComputation.progressIngest.should.equal(1);
|
|
459
|
-
rainComputation.progressComputing.should.be.greaterThan(0);
|
|
460
|
-
}).timeout(3000);
|
|
461
|
-
|
|
462
|
-
it('should get the rain computation result (direct or with map format)', async () => {
|
|
463
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
464
|
-
let res = await _request(await _$app)
|
|
465
|
-
.get('/v1/rains/' + rainId + '/computations/' + _created.createdRainComputation.id)
|
|
466
|
-
.expect('Content-Type', /application\/json/)
|
|
467
|
-
.expect(200);
|
|
468
|
-
|
|
469
|
-
const rainComputation = new RainComputationNode(res.body);
|
|
470
|
-
rainComputation.should.be.not.undefined;
|
|
471
|
-
rainComputation.progressIngest.should.equal(1);
|
|
472
|
-
rainComputation.progressComputing.should.equal(1);
|
|
473
|
-
rainComputation.timeSpentInMs.should.be.greaterThan(10);
|
|
474
|
-
rainComputation.timeSpentInMs.should.be.lessThan(5000);
|
|
475
|
-
rainComputation.getLinkId('radar', 0).should.equal(_created.createdRadar.id);
|
|
476
|
-
rainComputation.getLinkId('rain', 0).should.equal(rainId);
|
|
477
|
-
|
|
478
|
-
res = await _request(await _$app)
|
|
479
|
-
.get('/v1/rains/' + rainId + '/computations/' + _created.createdRainComputation.id + '?format=map')
|
|
480
|
-
.expect('Content-Type', /application\/json/)
|
|
481
|
-
.expect(200);
|
|
482
|
-
const rainComputationMap = new RainComputationMap(res.body);
|
|
483
|
-
rainComputationMap.should.be.not.undefined;
|
|
484
|
-
rainComputationMap.periodBegin.should.equal("2018-06-01T11:05:00.000Z");
|
|
485
|
-
rainComputationMap.periodEnd.should.equal("2018-06-01T11:10:00.000Z");
|
|
486
|
-
rainComputationMap.id.should.not.be.undefined;
|
|
487
|
-
rainComputationMap.getMapData().length.should.equal(1);
|
|
488
|
-
|
|
489
|
-
const rainMeasure0 = new RainMeasure(rainComputationMap.getMapData()[0]);
|
|
490
|
-
rainMeasure0.id.should.be.not.undefined;
|
|
491
|
-
rainMeasure0.date.should.equal(rainComputationMap.periodBegin)
|
|
492
|
-
const measure0 = new RainMeasureValue(rainMeasure0.values[0]);
|
|
493
|
-
measure0.getPolars().length.should.equal(720);
|
|
494
|
-
new MeasureValuePolarContainer(measure0.getPolars()[200]).azimuth.should.equal(100);
|
|
495
|
-
new MeasureValuePolarContainer(measure0.getPolars()[200]).distance.should.equal(1000);
|
|
496
|
-
new MeasureValuePolarContainer(measure0.getPolars()[200]).polarEdges.length.should.equal(250);
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it('should (as shorcut) get the last computations in rain zone', async () => {
|
|
500
|
-
const rainId = _created.createdRadar.getLinkId('rain');
|
|
501
|
-
let res = await _request(await _$app)
|
|
502
|
-
.get('/v1/rains/' + rainId)
|
|
503
|
-
.expect('Content-Type', /application\/json/)
|
|
504
|
-
.expect(200);
|
|
505
|
-
|
|
506
|
-
const rainNode = new RainNode(res.body);
|
|
507
|
-
rainNode.status.should.equal(1);
|
|
508
|
-
rainNode.getLinkId('rain-computation', 0).should.equal(_created.createdRainComputation.id);
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
it('should (as awesome shortcut) get the rain computation result directly from a radar measure post (or put)', async () => {
|
|
512
|
-
// const rainId = _created.createdRadar.getLinkId('rain');
|
|
513
|
-
// let res = await _request(await _$app)
|
|
514
|
-
// // .post('/v1/radars/' + _created.createdRadar.id + '/measures')
|
|
515
|
-
// // or
|
|
516
|
-
// .put('/v1/radars/' + _created.createdRadar.id + '/measures/' + _created.createdRadarMeasures[0].id)
|
|
517
|
-
// .send({computation: true})
|
|
518
|
-
// .expect('Content-Type', /application\/json/)
|
|
519
|
-
// .expect(201);
|
|
520
|
-
|
|
521
|
-
// const measure = new RadarMeasure(res.body);
|
|
522
|
-
// measure.should.be.not.undefined;
|
|
523
|
-
// measure.links.computations.should.be.not.undefined;
|
|
524
|
-
// measure.links.computations.length.should.equal(1);
|
|
525
|
-
//
|
|
526
|
-
// res = await _request(await _$app)
|
|
527
|
-
// .get('/v1/rains/' + rainId + '/computations/' + measure.links.computations[0])
|
|
528
|
-
// .expect('Content-Type', /application\/json/)
|
|
529
|
-
// .expect(200);
|
|
530
|
-
//
|
|
531
|
-
// const rainComputation = new RainComputationNode(res.body);
|
|
532
|
-
// rainComputation.should.be.not.undefined;
|
|
533
|
-
// rainComputation.progressIngest.should.equal(1);
|
|
534
|
-
// rainComputation.progressComputing.should.equal(1);
|
|
535
|
-
// rainComputation.timeSpentInMs.should.greaterThan(0);
|
|
536
|
-
//
|
|
537
|
-
// res = await _request(await _$app)
|
|
538
|
-
// .get('/v1/rains/' + rainId + '/computations/' + _created.createdRainComputation.id + '?format=map')
|
|
539
|
-
// .expect('Content-Type', /application\/json/)
|
|
540
|
-
// .expect(200);
|
|
541
|
-
// const rainComputationMap = new RainComputationMap(res.body);
|
|
542
|
-
// rainComputationMap.should.be.not.undefined;
|
|
543
|
-
// rainComputationMap.map.should.equal('????');
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
const _buildRadarMeasures = (moduloOption) => {
|
|
549
|
-
const values = [];
|
|
550
|
-
const modulo = moduloOption ? moduloOption : Math.round(Math.random() * 10);
|
|
551
|
-
for (let angle = 0.4; angle < 3; angle++) {
|
|
552
|
-
let value = {angle: angle};
|
|
553
|
-
const polars = [];
|
|
554
|
-
for (let azimuth = 0; azimuth < 360; azimuth += 0.5) {
|
|
555
|
-
let data = [];
|
|
556
|
-
for (let distance = 0; distance < 250; distance++) {
|
|
557
|
-
if (azimuth % modulo) {
|
|
558
|
-
data.push(Math.round(Math.random() * 56));
|
|
559
|
-
} else {
|
|
560
|
-
data.push(0);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
const polar = {
|
|
564
|
-
azimuth: azimuth,
|
|
565
|
-
distance: 1000,
|
|
566
|
-
polarEdges: data
|
|
567
|
-
};
|
|
568
|
-
polars.push(polar);
|
|
569
|
-
}
|
|
570
|
-
value.polars = polars;
|
|
571
|
-
values.push(value);
|
|
572
|
-
}
|
|
573
|
-
return values;
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
const _buildGaugeMeasure = () => {
|
|
577
|
-
return Math.floor(Math.random() * Math.floor(12));
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
xdescribe('as Customer with `customerInsert` role', function () {
|
|
583
|
-
|
|
584
|
-
it('should post/put on radars, gauges', () => {
|
|
585
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
it('should not access other api', () => {
|
|
589
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
xdescribe('as Customer with `customerWeb` role', function () {
|
|
595
|
-
|
|
596
|
-
it('should get on radars, gauges, rains', () => {
|
|
597
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
it('should not modify radars, gauges, rains', () => {
|
|
601
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
it('should not access other api', () => {
|
|
605
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
xdescribe('as Customer with `customerResult` role', function () {
|
|
611
|
-
|
|
612
|
-
it('should get rains dedicated result', () => {
|
|
613
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
it('should not modify anything', () => {
|
|
617
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
it('should not access other api', () => {
|
|
621
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
622
|
-
});
|
|
623
|
-
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
xdescribe('as Customer with `customerComputing` role', function () {
|
|
627
|
-
|
|
628
|
-
it('should get rains dedicated result', () => {
|
|
629
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
it('should not modify anything', () => {
|
|
633
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
it('should not access other api', () => {
|
|
637
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
xdescribe('as Customer with `customerAdmin` role (IN PROGRESS)', function () {
|
|
643
|
-
|
|
644
|
-
it('should post/put users and his team', () => {
|
|
645
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
it('should not modify anything', () => {
|
|
649
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
it('should not access other api', () => {
|
|
653
|
-
'todo'.should.equal('todo?', 'TODO');
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
});
|
package/src/EventNode.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// api/notifications/:id
|
|
4
|
-
export class EventNode {
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
public id: string,
|
|
8
|
-
public title: string,
|
|
9
|
-
public status: number,
|
|
10
|
-
public red: boolean,
|
|
11
|
-
public description: string,
|
|
12
|
-
public created: Date,
|
|
13
|
-
public modified: Date
|
|
14
|
-
) {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|