Skip to content

Commit bcf8014

Browse files
committed
polish
1 parent d6860b4 commit bcf8014

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

client/src/main/java/io/split/engine/sse/NotificationParserImp.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public ErrorNotification parseError(String payload) throws EventParsingException
4949
private IncomingNotification parseNotification(GenericNotificationData genericNotificationData) throws Exception {
5050
switch (genericNotificationData.getType()) {
5151
case SPLIT_UPDATE:
52-
return new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.SPLIT_UPDATE, Split.class);
52+
return new CommonChangeNotification(genericNotificationData, Split.class);
5353
case RB_SEGMENT_UPDATE:
54-
return new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.RB_SEGMENT_UPDATE, RuleBasedSegment.class);
54+
return new CommonChangeNotification(genericNotificationData, RuleBasedSegment.class);
5555
case SPLIT_KILL:
5656
return new SplitKillNotification(genericNotificationData);
5757
case SEGMENT_UPDATE:

client/src/main/java/io/split/engine/sse/dtos/CommonChangeNotification.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class CommonChangeNotification<Y> extends IncomingNotification {
2424
private Class _definitionClass;
2525

2626
public CommonChangeNotification(GenericNotificationData genericNotificationData,
27-
IncomingNotification.Type notificationType, Class definitionClass) {
27+
Class definitionClass) {
2828
super(genericNotificationData.getType(), genericNotificationData.getChannel());
2929
changeNumber = genericNotificationData.getChangeNumber();
3030
_definitionClass = definitionClass;

client/src/test/java/io/split/engine/sse/NotificationProcessorTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void processSplitUpdateAddToQueueInWorker() {
3333
.changeNumber(changeNumber)
3434
.channel(channel)
3535
.build();
36-
CommonChangeNotification splitChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.SPLIT_UPDATE, Split.class);
36+
CommonChangeNotification splitChangeNotification = new CommonChangeNotification(genericNotificationData, Split.class);
3737

3838
_notificationProcessor.process(splitChangeNotification);
3939

@@ -47,8 +47,9 @@ public void processRuleBasedSegmentUpdateAddToQueueInWorker() {
4747
GenericNotificationData genericNotificationData = GenericNotificationData.builder()
4848
.changeNumber(changeNumber)
4949
.channel(channel)
50+
.type(IncomingNotification.Type.RB_SEGMENT_UPDATE)
5051
.build();
51-
CommonChangeNotification ruleBasedSegmentChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.RB_SEGMENT_UPDATE, RuleBasedSegment.class);
52+
CommonChangeNotification ruleBasedSegmentChangeNotification = new CommonChangeNotification(genericNotificationData, RuleBasedSegment.class);
5253

5354
_notificationProcessor.process(ruleBasedSegmentChangeNotification);
5455

client/src/test/java/io/split/engine/sse/workers/FeatureFlagWorkerImpTest.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import io.split.engine.matchers.AttributeMatcher;
1717
import io.split.engine.matchers.CombiningMatcher;
1818
import io.split.engine.sse.dtos.CommonChangeNotification;
19-
import io.split.engine.sse.dtos.IncomingNotification;
2019
import io.split.engine.sse.dtos.RawMessageNotification;
2120
import io.split.engine.sse.dtos.GenericNotificationData;
2221
import io.split.storages.RuleBasedSegmentCache;
@@ -52,7 +51,7 @@ public void testRefreshSplitsWithCorrectFF() {
5251
RawMessageNotification rawMessageNotification = Json.fromJson(notification, RawMessageNotification.class);
5352
GenericNotificationData genericNotificationData = Json.fromJson(rawMessageNotification.getData(), GenericNotificationData.class);
5453

55-
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.SPLIT_UPDATE, Split.class);
54+
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, Split.class);
5655
featureFlagsWorker.executeRefresh(featureFlagChangeNotification);
5756
UpdatesFromSSE updatesFromSSE = telemetryRuntimeProducer.popUpdatesFromSSE();
5857
Assert.assertEquals(1, updatesFromSSE.getSplits());
@@ -73,7 +72,7 @@ public void testRefreshSplitsWithEmptyData() {
7372
RawMessageNotification rawMessageNotification = Json.fromJson(notification, RawMessageNotification.class);
7473
GenericNotificationData genericNotificationData = Json.fromJson(rawMessageNotification.getData(), GenericNotificationData.class);
7574

76-
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.SPLIT_UPDATE, Split.class);
75+
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, Split.class);
7776
featureFlagsWorker.executeRefresh(featureFlagChangeNotification);
7877
UpdatesFromSSE updatesFromSSE = telemetryRuntimeProducer.popUpdatesFromSSE();
7978
Assert.assertEquals(0, updatesFromSSE.getSplits());
@@ -94,7 +93,7 @@ public void testRefreshSplitsArchiveFF() {
9493
RawMessageNotification rawMessageNotification = Json.fromJson(notification, RawMessageNotification.class);
9594
GenericNotificationData genericNotificationData = Json.fromJson(rawMessageNotification.getData(), GenericNotificationData.class);
9695

97-
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.SPLIT_UPDATE, Split.class);
96+
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, Split.class);
9897
featureFlagsWorker.executeRefresh(featureFlagChangeNotification);
9998
UpdatesFromSSE updatesFromSSE = telemetryRuntimeProducer.popUpdatesFromSSE();
10099
Assert.assertEquals(1, updatesFromSSE.getSplits());
@@ -127,7 +126,7 @@ public void testUpdateRuleBasedSegmentsWithCorrectFF() {
127126
RawMessageNotification rawMessageNotification = Json.fromJson(notification, RawMessageNotification.class);
128127
GenericNotificationData genericNotificationData = Json.fromJson(rawMessageNotification.getData(), GenericNotificationData.class);
129128

130-
CommonChangeNotification<RuleBasedSegment> ruleBasedSegmentChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.RB_SEGMENT_UPDATE, RuleBasedSegment.class);
129+
CommonChangeNotification<RuleBasedSegment> ruleBasedSegmentChangeNotification = new CommonChangeNotification(genericNotificationData, RuleBasedSegment.class);
131130
featureFlagsWorker.executeRefresh(ruleBasedSegmentChangeNotification);
132131
Mockito.verify(ruleBasedSegmentCache, Mockito.times(1)).update(Arrays.asList(parsedRBS), new ArrayList<>(), 1684265694505L);
133132
}
@@ -147,7 +146,7 @@ public void testRefreshRuleBasedSegmentWithCorrectFF() {
147146
String notification = "{\"id\":\"vQQ61wzBRO:0:0\",\"clientId\":\"pri:MTUxNzg3MDg1OQ==\",\"timestamp\":1684265694676,\"encoding\":\"json\",\"channel\":\"NzM2MDI5Mzc0_MjkyNTIzNjczMw==_splits\",\"data\":\"{\\\"type\\\":\\\"SPLIT_UPDATE\\\",\\\"changeNumber\\\":1684265694505,\\\"pcn\\\":0,\\\"c\\\":0,\\\"d\\\":\\\"eyJjaGFuZ2VOdW1iZXIiOiAxMCwgInRyYWZmaWNUeXBlTmFtZSI6ICJ1c2VyIiwgIm5hbWUiOiAicmJzX2ZsYWciLCAidHJhZmZpY0FsbG9jYXRpb24iOiAxMDAsICJ0cmFmZmljQWxsb2NhdGlvblNlZWQiOiAxODI4Mzc3MzgwLCAic2VlZCI6IC0yODY2MTc5MjEsICJzdGF0dXMiOiAiQUNUSVZFIiwgImtpbGxlZCI6IGZhbHNlLCAiZGVmYXVsdFRyZWF0bWVudCI6ICJvZmYiLCAiYWxnbyI6IDIsICJjb25kaXRpb25zIjogW3siY29uZGl0aW9uVHlwZSI6ICJST0xMT1VUIiwgIm1hdGNoZXJHcm91cCI6IHsiY29tYmluZXIiOiAiQU5EIiwgIm1hdGNoZXJzIjogW3sia2V5U2VsZWN0b3IiOiB7InRyYWZmaWNUeXBlIjogInVzZXIifSwgIm1hdGNoZXJUeXBlIjogIklOX1JVTEVfQkFTRURfU0VHTUVOVCIsICJuZWdhdGUiOiBmYWxzZSwgInVzZXJEZWZpbmVkU2VnbWVudE1hdGNoZXJEYXRhIjogeyJzZWdtZW50TmFtZSI6ICJzYW1wbGVfcnVsZV9iYXNlZF9zZWdtZW50In19XX0sICJwYXJ0aXRpb25zIjogW3sidHJlYXRtZW50IjogIm9uIiwgInNpemUiOiAxMDB9LCB7InRyZWF0bWVudCI6ICJvZmYiLCAic2l6ZSI6IDB9XSwgImxhYmVsIjogImluIHJ1bGUgYmFzZWQgc2VnbWVudCBzYW1wbGVfcnVsZV9iYXNlZF9zZWdtZW50In0sIHsiY29uZGl0aW9uVHlwZSI6ICJST0xMT1VUIiwgIm1hdGNoZXJHcm91cCI6IHsiY29tYmluZXIiOiAiQU5EIiwgIm1hdGNoZXJzIjogW3sia2V5U2VsZWN0b3IiOiB7InRyYWZmaWNUeXBlIjogInVzZXIifSwgIm1hdGNoZXJUeXBlIjogIkFMTF9LRVlTIiwgIm5lZ2F0ZSI6IGZhbHNlfV19LCAicGFydGl0aW9ucyI6IFt7InRyZWF0bWVudCI6ICJvbiIsICJzaXplIjogMH0sIHsidHJlYXRtZW50IjogIm9mZiIsICJzaXplIjogMTAwfV0sICJsYWJlbCI6ICJkZWZhdWx0IHJ1bGUifV0sICJjb25maWd1cmF0aW9ucyI6IHt9LCAic2V0cyI6IFtdLCAiaW1wcmVzc2lvbnNEaXNhYmxlZCI6IGZhbHNlfQ==\\\"}\"}";
148147
RawMessageNotification rawMessageNotification = Json.fromJson(notification, RawMessageNotification.class);
149148
GenericNotificationData genericNotificationData = Json.fromJson(rawMessageNotification.getData(), GenericNotificationData.class);
150-
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, IncomingNotification.Type.SPLIT_UPDATE, Split.class);
149+
CommonChangeNotification<Split> featureFlagChangeNotification = new CommonChangeNotification(genericNotificationData, Split.class);
151150

152151
featureFlagsWorker.executeRefresh(featureFlagChangeNotification);
153152
Mockito.verify(synchronizer, Mockito.times(0)).refreshSplits(0L, 1684265694505L);

client/src/test/java/io/split/engine/sse/workers/SplitsWorkerTest.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,20 @@ public void addToQueueWithElementsWShouldTriggerFetch() throws InterruptedExcept
6262

6363
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
6464
.changeNumber(1585956698457L)
65-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
65+
.type(IncomingNotification.Type.SPLIT_UPDATE)
66+
.build(), Split.class));
6667
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
6768
.changeNumber(1585956698467L)
68-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
69+
.type(IncomingNotification.Type.SPLIT_UPDATE)
70+
.build(), Split.class));
6971
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
7072
.changeNumber(1585956698477L)
71-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
73+
.type(IncomingNotification.Type.SPLIT_UPDATE)
74+
.build(), Split.class));
7275
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
7376
.changeNumber(1585956698476L)
74-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
77+
.type(IncomingNotification.Type.SPLIT_UPDATE)
78+
.build(), Split.class));
7579
Thread.sleep(1000);
7680

7781
Mockito.verify(syncMock, Mockito.times(4)).refreshSplits(cnCaptor.capture(), cnCaptor2.capture());
@@ -118,7 +122,8 @@ public void messagesNotProcessedWhenWorkerStopped() throws InterruptedException
118122
featureFlagsWorker.start();
119123
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
120124
.changeNumber(1585956698457L)
121-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
125+
.type(IncomingNotification.Type.SPLIT_UPDATE)
126+
.build(), Split.class));
122127
Thread.sleep(500);
123128

124129

@@ -127,14 +132,16 @@ public void messagesNotProcessedWhenWorkerStopped() throws InterruptedException
127132

128133
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
129134
.changeNumber(1585956698467L)
130-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
135+
.type(IncomingNotification.Type.SPLIT_UPDATE)
136+
.build(), Split.class));
131137
Mockito.verify(syncMock, Mockito.times(1)).refreshSplits(Mockito.anyObject(), Mockito.anyObject()); // Previous one!
132138

133139
Mockito.reset(syncMock);
134140
featureFlagsWorker.start();
135141
featureFlagsWorker.addToQueue(new CommonChangeNotification(GenericNotificationData.builder()
136142
.changeNumber(1585956698477L)
137-
.build(), IncomingNotification.Type.SPLIT_UPDATE, Split.class));
143+
.type(IncomingNotification.Type.SPLIT_UPDATE)
144+
.build(), Split.class));
138145
Thread.sleep(500);
139146
Mockito.verify(syncMock, Mockito.times(1)).refreshSplits(Mockito.anyObject(), Mockito.anyObject());
140147
featureFlagsWorker.stop();

0 commit comments

Comments
 (0)