Skip to content

Commit 79db362

Browse files
Notification for voltage init reactive slacks over a threshold value (#70)
* Notification for voltage init reactive slacks over a threshold value * Rollback in message payload type from NetworkImpactInfos to String. Signed-off-by: Franck LECUYER <[email protected]>
1 parent f955404 commit 79db362

File tree

4 files changed

+14
-56
lines changed

4 files changed

+14
-56
lines changed

src/main/java/org/gridsuite/study/notification/server/NotificationWebSocketHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.gridsuite.study.notification.server.dto.Filters;
1414
import org.gridsuite.study.notification.server.dto.FiltersToAdd;
1515
import org.gridsuite.study.notification.server.dto.FiltersToRemove;
16-
import org.gridsuite.study.notification.server.dto.NetworkImpactsInfos;
1716
import org.slf4j.Logger;
1817
import org.slf4j.LoggerFactory;
1918
import org.springframework.beans.factory.annotation.Value;
@@ -95,12 +94,12 @@ private void initMetrics(MeterRegistry meterRegistry) {
9594
Gauge.builder(CONNECTIONS_METER_NAME, () -> userConnections.values().stream().mapToInt(Integer::intValue).sum()).register(meterRegistry);
9695
}
9796

98-
Flux<Message<NetworkImpactsInfos>> flux;
97+
Flux<Message<String>> flux;
9998

10099
@Bean
101-
public Consumer<Flux<Message<NetworkImpactsInfos>>> consumeNotification() {
100+
public Consumer<Flux<Message<String>>> consumeNotification() {
102101
return f -> {
103-
ConnectableFlux<Message<NetworkImpactsInfos>> c = f.log(CATEGORY_BROKER_INPUT, Level.FINE).publish();
102+
ConnectableFlux<Message<String>> c = f.log(CATEGORY_BROKER_INPUT, Level.FINE).publish();
104103
this.flux = c;
105104
c.connect();
106105
// Force connect 1 fake subscriber to consumme messages as they come.

src/main/java/org/gridsuite/study/notification/server/dto/EquipmentDeletionInfos.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/org/gridsuite/study/notification/server/dto/NetworkImpactsInfos.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/test/java/org/gridsuite/study/notification/server/NotificationWebSocketHandlerTest.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.fasterxml.jackson.core.JsonProcessingException;
1818
import com.fasterxml.jackson.databind.ObjectMapper;
1919
import com.fasterxml.jackson.databind.ObjectWriter;
20-
import com.google.common.collect.ImmutableSet;
2120

2221
import io.micrometer.core.instrument.MeterRegistry;
2322
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
@@ -133,7 +132,7 @@ private void withFilters(String filterStudyUuid, String filterUpdateType, boolea
133132
}
134133

135134
var notificationWebSocketHandler = new NotificationWebSocketHandler(objectMapper, meterRegistry, Integer.MAX_VALUE);
136-
var atomicRef = new AtomicReference<FluxSink<Message<NetworkImpactsInfos>>>();
135+
var atomicRef = new AtomicReference<FluxSink<Message<String>>>();
137136
var flux = Flux.create(atomicRef::set);
138137
notificationWebSocketHandler.consumeNotification().accept(flux);
139138
var sink = atomicRef.get();
@@ -148,7 +147,7 @@ private void withFilters(String filterStudyUuid, String filterUpdateType, boolea
148147
}
149148
}
150149

151-
List<GenericMessage<NetworkImpactsInfos>> refMessages = Stream.<Map<String, Object>>of(
150+
List<GenericMessage<String>> refMessages = Stream.<Map<String, Object>>of(
152151
Map.of(HEADER_STUDY_UUID, "foo", HEADER_UPDATE_TYPE, "oof"),
153152
Map.of(HEADER_STUDY_UUID, "bar", HEADER_UPDATE_TYPE, "oof"),
154153
Map.of(HEADER_STUDY_UUID, "baz", HEADER_UPDATE_TYPE, "oof"),
@@ -174,7 +173,7 @@ private void withFilters(String filterStudyUuid, String filterUpdateType, boolea
174173
HEADER_PARENT_NODE, UUID.randomUUID().toString(), HEADER_REMOVE_CHILDREN, true),
175174

176175
Map.of(HEADER_STUDY_UUID, "", HEADER_UPDATE_TYPE, "indexation_status_updated", HEADER_INDEXATION_STATUS, "INDEXED"))
177-
.map(map -> new GenericMessage<>(new NetworkImpactsInfos(ImmutableSet.of(), ImmutableSet.of(new EquipmentDeletionInfos()), ImmutableSet.of()), map))
176+
.map(map -> new GenericMessage<>("", map))
178177
.collect(Collectors.toList());
179178

180179
@SuppressWarnings("unchecked")
@@ -300,7 +299,7 @@ public void testWsReceiveFilters() throws JsonProcessingException {
300299
when(ws2.getAttributes()).thenReturn(map);
301300

302301
var notificationWebSocketHandler = new NotificationWebSocketHandler(new ObjectMapper(), meterRegistry, 60);
303-
var flux = Flux.<Message<NetworkImpactsInfos>>empty();
302+
var flux = Flux.<Message<String>>empty();
304303
notificationWebSocketHandler.consumeNotification().accept(flux);
305304
notificationWebSocketHandler.receive(ws2).subscribe();
306305

@@ -327,7 +326,7 @@ public void testWsRemoveFilters() throws JsonProcessingException {
327326
assertEquals("updateType", ws2.getAttributes().get(FILTER_UPDATE_TYPE));
328327
assertEquals("studyUuid", ws2.getAttributes().get(FILTER_STUDY_UUID));
329328
var notificationWebSocketHandler = new NotificationWebSocketHandler(new ObjectMapper(), meterRegistry, Integer.MAX_VALUE);
330-
var flux = Flux.<Message<NetworkImpactsInfos>>empty();
329+
var flux = Flux.<Message<String>>empty();
331330
notificationWebSocketHandler.consumeNotification().accept(flux);
332331
notificationWebSocketHandler.receive(ws2).subscribe();
333332

@@ -348,7 +347,7 @@ public void testWsReceiveEmptyFilters() throws JsonProcessingException {
348347
when(ws2.getAttributes()).thenReturn(map);
349348

350349
var notificationWebSocketHandler = new NotificationWebSocketHandler(new ObjectMapper(), meterRegistry, Integer.MAX_VALUE);
351-
var flux = Flux.<Message<NetworkImpactsInfos>>empty();
350+
var flux = Flux.<Message<String>>empty();
352351
notificationWebSocketHandler.consumeNotification().accept(flux);
353352
notificationWebSocketHandler.receive(ws2).subscribe();
354353

@@ -366,7 +365,7 @@ public void testWsReceiveUnprocessableFilter() {
366365
when(ws2.getAttributes()).thenReturn(map);
367366

368367
var notificationWebSocketHandler = new NotificationWebSocketHandler(new ObjectMapper(), meterRegistry, 60);
369-
var flux = Flux.<Message<NetworkImpactsInfos>>empty();
368+
var flux = Flux.<Message<String>>empty();
370369
notificationWebSocketHandler.consumeNotification().accept(flux);
371370
notificationWebSocketHandler.receive(ws2).subscribe();
372371

@@ -379,7 +378,7 @@ public void testHeartbeat() {
379378
setUpUriComponentBuilder("userId");
380379

381380
var notificationWebSocketHandler = new NotificationWebSocketHandler(null, meterRegistry, 1);
382-
var flux = Flux.<Message<NetworkImpactsInfos>>empty();
381+
var flux = Flux.<Message<String>>empty();
383382
notificationWebSocketHandler.consumeNotification().accept(flux);
384383
notificationWebSocketHandler.handle(ws);
385384

@@ -394,13 +393,13 @@ public void testDiscard() {
394393
setUpUriComponentBuilder("userId");
395394

396395
var notificationWebSocketHandler = new NotificationWebSocketHandler(objectMapper, meterRegistry, Integer.MAX_VALUE);
397-
var atomicRef = new AtomicReference<FluxSink<Message<NetworkImpactsInfos>>>();
396+
var atomicRef = new AtomicReference<FluxSink<Message<String>>>();
398397
var flux = Flux.create(atomicRef::set);
399398
notificationWebSocketHandler.consumeNotification().accept(flux);
400399
var sink = atomicRef.get();
401400
Map<String, Object> headers = Map.of(HEADER_STUDY_UUID, "foo", HEADER_UPDATE_TYPE, "oof");
402401

403-
sink.next(new GenericMessage<>(new NetworkImpactsInfos(ImmutableSet.of(), ImmutableSet.of(new EquipmentDeletionInfos()), ImmutableSet.of()), headers)); // should be discarded, no client connected
402+
sink.next(new GenericMessage<>("", headers)); // should be discarded, no client connected
404403

405404
notificationWebSocketHandler.handle(ws);
406405

@@ -411,7 +410,7 @@ public void testDiscard() {
411410
Disposable d1 = out1.map(WebSocketMessage::getPayloadAsText).subscribe(messages1::add);
412411
d1.dispose();
413412

414-
sink.next(new GenericMessage<>(new NetworkImpactsInfos(ImmutableSet.of(), ImmutableSet.of(new EquipmentDeletionInfos()), ImmutableSet.of()), headers)); // should be discarded, first client disconnected
413+
sink.next(new GenericMessage<>("", headers)); // should be discarded, first client disconnected
415414

416415
notificationWebSocketHandler.handle(ws);
417416

0 commit comments

Comments
 (0)