6
6
*/
7
7
package org .gridsuite .study .notification .server ;
8
8
9
- import java .time .Duration ;
10
- import java .util .*;
11
- import java .util .concurrent .ConcurrentHashMap ;
12
- import java .util .concurrent .atomic .AtomicReference ;
13
- import java .util .function .Function ;
14
- import java .util .stream .Collectors ;
15
- import java .util .stream .Stream ;
16
-
17
9
import com .fasterxml .jackson .core .JsonProcessingException ;
18
10
import com .fasterxml .jackson .databind .ObjectMapper ;
19
11
import com .fasterxml .jackson .databind .ObjectWriter ;
20
-
21
12
import io .micrometer .core .instrument .MeterRegistry ;
22
13
import io .micrometer .core .instrument .simple .SimpleMeterRegistry ;
23
- import org .gridsuite .study .notification .server .dto .*;
24
- import org .junit .Before ;
25
- import org .junit .Test ;
14
+ import org .gridsuite .study .notification .server .dto .Filters ;
15
+ import org .gridsuite .study .notification .server .dto .FiltersToAdd ;
16
+ import org .gridsuite .study .notification .server .dto .FiltersToRemove ;
17
+ import org .junit .jupiter .api .BeforeEach ;
18
+ import org .junit .jupiter .api .Test ;
26
19
import org .mockito .ArgumentCaptor ;
27
20
import org .mockito .Mockito ;
28
21
import org .springframework .core .io .buffer .DataBuffer ;
40
33
import reactor .core .publisher .FluxSink ;
41
34
import reactor .core .publisher .Mono ;
42
35
36
+ import java .time .Duration ;
37
+ import java .util .*;
38
+ import java .util .concurrent .ConcurrentHashMap ;
39
+ import java .util .concurrent .atomic .AtomicReference ;
40
+ import java .util .function .Function ;
41
+ import java .util .stream .Collectors ;
42
+ import java .util .stream .Stream ;
43
+
43
44
import static org .gridsuite .study .notification .server .NotificationWebSocketHandler .*;
44
- import static org .junit .Assert .*;
45
+ import static org .junit .jupiter . api . Assertions .*;
45
46
import static org .mockito .ArgumentMatchers .any ;
46
47
import static org .mockito .Mockito .*;
47
48
48
49
/**
49
50
* @author Jon Harper <jon.harper at rte-france.com>
50
51
*/
51
- public class NotificationWebSocketHandlerTest {
52
+ class NotificationWebSocketHandlerTest {
52
53
53
54
private ObjectMapper objectMapper ;
54
55
private WebSocketSession ws ;
@@ -57,8 +58,8 @@ public class NotificationWebSocketHandlerTest {
57
58
58
59
private final MeterRegistry meterRegistry = new SimpleMeterRegistry ();
59
60
60
- @ Before
61
- public void setup () {
61
+ @ BeforeEach
62
+ void setup () {
62
63
objectMapper = new ObjectMapper ();
63
64
var dataBufferFactory = new DefaultDataBufferFactory ();
64
65
@@ -193,7 +194,7 @@ private void withFilters(String filterStudyUuid, String filterUpdateType, boolea
193
194
return (filterStudyUuid == null || filterStudyUuid .equals (studyUuid )) && (filterUpdateType == null || filterUpdateType .equals (updateType ));
194
195
})
195
196
.map (GenericMessage ::getHeaders )
196
- .map (this ::toResultHeader )
197
+ .map (NotificationWebSocketHandlerTest ::toResultHeader )
197
198
.collect (Collectors .toList ());
198
199
199
200
List <Map <String , Object >> actual = messages .stream ().map (t -> {
@@ -207,7 +208,7 @@ private void withFilters(String filterStudyUuid, String filterUpdateType, boolea
207
208
assertNotEquals (0 , actual .size ());
208
209
}
209
210
210
- private Map <String , Object > toResultHeader (Map <String , Object > messageHeader ) {
211
+ private static Map <String , Object > toResultHeader (Map <String , Object > messageHeader ) {
211
212
var resHeader = new HashMap <String , Object >();
212
213
resHeader .put (HEADER_TIMESTAMP , messageHeader .get (HEADER_TIMESTAMP ));
213
214
resHeader .put (HEADER_UPDATE_TYPE , messageHeader .get (HEADER_UPDATE_TYPE ));
@@ -228,64 +229,64 @@ private Map<String, Object> toResultHeader(Map<String, Object> messageHeader) {
228
229
return resHeader ;
229
230
}
230
231
231
- private void passHeaderRef (Map <String , Object > messageHeader , HashMap <String , Object > resHeader , String headerName ) {
232
+ private static void passHeaderRef (Map <String , Object > messageHeader , HashMap <String , Object > resHeader , String headerName ) {
232
233
if (messageHeader .get (headerName ) != null ) {
233
234
resHeader .put (headerName , messageHeader .get (headerName ));
234
235
}
235
236
}
236
237
237
238
@ Test
238
- public void testWithoutFilterInBody () {
239
+ void testWithoutFilterInBody () {
239
240
withFilters (null , null , false );
240
241
}
241
242
242
243
@ Test
243
- public void testWithoutFilterInUrl () {
244
+ void testWithoutFilterInUrl () {
244
245
withFilters (null , null , true );
245
246
}
246
247
247
248
@ Test
248
- public void testStudyFilterInBody () {
249
+ void testStudyFilterInBody () {
249
250
withFilters ("bar" , null , false );
250
251
}
251
252
252
253
@ Test
253
- public void testStudyFilterInUrl () {
254
+ void testStudyFilterInUrl () {
254
255
withFilters ("bar" , null , true );
255
256
}
256
257
257
258
@ Test
258
- public void testTypeFilterInBody () {
259
+ void testTypeFilterInBody () {
259
260
withFilters (null , "rab" , false );
260
261
}
261
262
262
263
@ Test
263
- public void testTypeFilterInUrl () {
264
+ void testTypeFilterInUrl () {
264
265
withFilters (null , "rab" , true );
265
266
}
266
267
267
268
@ Test
268
- public void testStudyAndTypeFilterInBody () {
269
+ void testStudyAndTypeFilterInBody () {
269
270
withFilters ("bar" , "rab" , false );
270
271
}
271
272
272
273
@ Test
273
- public void testStudyAndTypeFilterInUrl () {
274
+ void testStudyAndTypeFilterInUrl () {
274
275
withFilters ("bar" , "rab" , true );
275
276
}
276
277
277
278
@ Test
278
- public void testEncodingCharactersInBody () {
279
+ void testEncodingCharactersInBody () {
279
280
withFilters ("foo bar/bar" , "foobar" , false );
280
281
}
281
282
282
283
@ Test
283
- public void testEncodingCharactersInUrl () {
284
+ void testEncodingCharactersInUrl () {
284
285
withFilters ("foo bar/bar" , "foobar" , true );
285
286
}
286
287
287
288
@ Test
288
- public void testWsReceiveFilters () throws JsonProcessingException {
289
+ void testWsReceiveFilters () throws Exception {
289
290
setUpUriComponentBuilder ("userId" );
290
291
var dataBufferFactory = new DefaultDataBufferFactory ();
291
292
@@ -308,7 +309,7 @@ public void testWsReceiveFilters() throws JsonProcessingException {
308
309
}
309
310
310
311
@ Test
311
- public void testWsRemoveFilters () throws JsonProcessingException {
312
+ void testWsRemoveFilters () throws Exception {
312
313
setUpUriComponentBuilder ("userId" );
313
314
var dataBufferFactory = new DefaultDataBufferFactory ();
314
315
@@ -335,7 +336,7 @@ public void testWsRemoveFilters() throws JsonProcessingException {
335
336
}
336
337
337
338
@ Test
338
- public void testWsReceiveEmptyFilters () throws JsonProcessingException {
339
+ void testWsReceiveEmptyFilters () throws Exception {
339
340
setUpUriComponentBuilder ("userId" );
340
341
var dataBufferFactory = new DefaultDataBufferFactory ();
341
342
@@ -356,7 +357,7 @@ public void testWsReceiveEmptyFilters() throws JsonProcessingException {
356
357
}
357
358
358
359
@ Test
359
- public void testWsReceiveUnprocessableFilter () {
360
+ void testWsReceiveUnprocessableFilter () {
360
361
setUpUriComponentBuilder ("userId" );
361
362
var dataBufferFactory = new DefaultDataBufferFactory ();
362
363
@@ -374,7 +375,7 @@ public void testWsReceiveUnprocessableFilter() {
374
375
}
375
376
376
377
@ Test
377
- public void testHeartbeat () {
378
+ void testHeartbeat () {
378
379
setUpUriComponentBuilder ("userId" );
379
380
380
381
var notificationWebSocketHandler = new NotificationWebSocketHandler (null , meterRegistry , 1 );
@@ -389,7 +390,7 @@ public void testHeartbeat() {
389
390
}
390
391
391
392
@ Test
392
- public void testDiscard () {
393
+ void testDiscard () {
393
394
setUpUriComponentBuilder ("userId" );
394
395
395
396
var notificationWebSocketHandler = new NotificationWebSocketHandler (objectMapper , meterRegistry , Integer .MAX_VALUE );
0 commit comments