Skip to content

Commit becea2d

Browse files
committed
Make reason more lenient by setting its type to String
1 parent fe13d55 commit becea2d

9 files changed

Lines changed: 15 additions & 32 deletions

File tree

miner/src/main/java/fr/rakambda/channelpointsminer/miner/api/ws/data/message/subtype/PointGain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ public class PointGain{
2020
private int totalPoints;
2121
@JsonProperty("reason_code")
2222
@NotNull
23-
private PointReasonCode reasonCode;
23+
private String reasonCode;
2424
}

miner/src/main/java/fr/rakambda/channelpointsminer/miner/api/ws/data/message/subtype/PointReasonCode.java

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

miner/src/main/java/fr/rakambda/channelpointsminer/miner/database/DatabaseEventHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ else if(predictionEvent.getStatus() == EventStatus.RESOLVED){
7878
public void onPointsEarnedEvent(@NotNull PointsEarnedEvent event) throws SQLException{
7979
var pointsEarnedData = event.getPointsEarnedData();
8080
var reasonCode = pointsEarnedData.getPointGain().getReasonCode();
81-
updateBalance(event, pointsEarnedData.getBalance(), reasonCode.name());
81+
updateBalance(event, pointsEarnedData.getBalance(), reasonCode);
8282
}
8383

8484
@Override

miner/src/main/java/fr/rakambda/channelpointsminer/miner/event/impl/PointsEarnedEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public String lookup(String key){
4040
return millify(pointsEarnedData.getPointGain().getTotalPoints(), true);
4141
}
4242
if(EventVariableKey.REASON.equals(key)){
43-
return pointsEarnedData.getPointGain().getReasonCode().toString();
43+
return pointsEarnedData.getPointGain().getReasonCode();
4444
}
4545
if(EventVariableKey.BALANCE.equals(key)){
4646
return millify(pointsEarnedData.getBalance().getBalance(), false);

miner/src/test/java/fr/rakambda/channelpointsminer/miner/api/ws/TwitchPubSubWebSocketClientMessageTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import java.net.MalformedURLException;
4545
import java.net.URI;
4646
import java.time.ZonedDateTime;
47-
import static fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointReasonCode.CLAIM;
4847
import static fr.rakambda.channelpointsminer.miner.api.ws.data.request.topic.TopicName.COMMUNITY_MOMENTS_CHANNEL_V1;
4948
import static fr.rakambda.channelpointsminer.miner.api.ws.data.request.topic.TopicName.COMMUNITY_POINTS_USER_V1;
5049
import static fr.rakambda.channelpointsminer.miner.api.ws.data.request.topic.TopicName.ONSITE_NOTIFICATIONS;
@@ -87,7 +86,7 @@ void onPointsEarned(WebsocketMockServer server){
8786
.channelId("987654321")
8887
.pointGain(PointGain.builder()
8988
.totalPoints(50)
90-
.reasonCode(CLAIM)
89+
.reasonCode("CLAIM")
9190
.build())
9291
.balance(Balance.builder()
9392
.channelId("987654321")

miner/src/test/java/fr/rakambda/channelpointsminer/miner/database/DatabaseEventHandlerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.EventStatus;
1010
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Outcome;
1111
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointGain;
12-
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointReasonCode;
1312
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Prediction;
1413
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Predictor;
1514
import fr.rakambda.channelpointsminer.miner.event.impl.ChatMessageEvent;
@@ -206,7 +205,7 @@ void onPointsEarned() throws SQLException{
206205
when(balance.getBalance()).thenReturn(BALANCE);
207206

208207
var pointGain = mock(PointGain.class);
209-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.RAID);
208+
when(pointGain.getReasonCode()).thenReturn("RAID");
210209

211210
var pointsEarnedData = mock(PointsEarnedData.class);
212211
when(pointsEarnedData.getBalance()).thenReturn(balance);
@@ -228,7 +227,7 @@ void onPointsEarnedDatabaseException() throws SQLException{
228227
when(balance.getBalance()).thenReturn(BALANCE);
229228

230229
var pointGain = mock(PointGain.class);
231-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.RAID);
230+
when(pointGain.getReasonCode()).thenReturn("RAID");
232231

233232
var pointsEarnedData = mock(PointsEarnedData.class);
234233
when(pointsEarnedData.getBalance()).thenReturn(balance);

miner/src/test/java/fr/rakambda/channelpointsminer/miner/log/discord/DiscordMessageBuilderEmbedTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Outcome;
1515
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.OutcomeColor;
1616
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointGain;
17-
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointReasonCode;
1817
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Prediction;
1918
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PredictionResultPayload;
2019
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PredictionResultType;
@@ -190,7 +189,7 @@ void onPointsEarned(){
190189
when(data.getBalance()).thenReturn(balance);
191190
when(data.getTimestamp()).thenReturn(ZONED_NOW);
192191
when(pointGain.getTotalPoints()).thenReturn(25);
193-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
192+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
194193
when(balance.getBalance()).thenReturn(200);
195194

196195
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);
@@ -220,7 +219,7 @@ void onPointsEarnedBigValue(){
220219
when(data.getBalance()).thenReturn(balance);
221220
when(data.getTimestamp()).thenReturn(ZONED_NOW);
222221
when(pointGain.getTotalPoints()).thenReturn(2500);
223-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
222+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
224223
when(balance.getBalance()).thenReturn(12345678);
225224

226225
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);
@@ -250,7 +249,7 @@ void onPointsEarnedBigNegativeValue(){
250249
when(data.getBalance()).thenReturn(balance);
251250
when(data.getTimestamp()).thenReturn(ZONED_NOW);
252251
when(pointGain.getTotalPoints()).thenReturn(-2500);
253-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
252+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
254253
when(balance.getBalance()).thenReturn(12345678);
255254

256255
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);

miner/src/test/java/fr/rakambda/channelpointsminer/miner/log/discord/DiscordMessageBuilderMessageTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Outcome;
1111
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.OutcomeColor;
1212
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointGain;
13-
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointReasonCode;
1413
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Prediction;
1514
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PredictionResultPayload;
1615
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PredictionResultType;
@@ -143,7 +142,7 @@ void onPointsEarned(){
143142
when(data.getBalance()).thenReturn(balance);
144143
when(data.getTimestamp()).thenReturn(ZONED_NOW);
145144
when(pointGain.getTotalPoints()).thenReturn(25);
146-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
145+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
147146
when(balance.getBalance()).thenReturn(200);
148147

149148
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);
@@ -165,7 +164,7 @@ void onPointsEarnedBigValue(){
165164
when(data.getBalance()).thenReturn(balance);
166165
when(data.getTimestamp()).thenReturn(ZONED_NOW);
167166
when(pointGain.getTotalPoints()).thenReturn(2500);
168-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
167+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
169168
when(balance.getBalance()).thenReturn(12345678);
170169

171170
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);
@@ -187,7 +186,7 @@ void onPointsEarnedBigNegativeValue(){
187186
when(data.getBalance()).thenReturn(balance);
188187
when(data.getTimestamp()).thenReturn(ZONED_NOW);
189188
when(pointGain.getTotalPoints()).thenReturn(-2500);
190-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
189+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
191190
when(balance.getBalance()).thenReturn(12345678);
192191

193192
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);

miner/src/test/java/fr/rakambda/channelpointsminer/miner/log/telegram/TelegramMessageBuilderMessageTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Outcome;
1111
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.OutcomeColor;
1212
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointGain;
13-
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PointReasonCode;
1413
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.Prediction;
1514
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PredictionResultPayload;
1615
import fr.rakambda.channelpointsminer.miner.api.ws.data.message.subtype.PredictionResultType;
@@ -148,7 +147,7 @@ void onPointsEarned(){
148147
when(data.getBalance()).thenReturn(balance);
149148
when(data.getTimestamp()).thenReturn(ZONED_NOW);
150149
when(pointGain.getTotalPoints()).thenReturn(25);
151-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
150+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
152151
when(balance.getBalance()).thenReturn(200);
153152

154153
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);
@@ -171,7 +170,7 @@ void onPointsEarnedBigValue(){
171170
when(data.getBalance()).thenReturn(balance);
172171
when(data.getTimestamp()).thenReturn(ZONED_NOW);
173172
when(pointGain.getTotalPoints()).thenReturn(2500);
174-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
173+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
175174
when(balance.getBalance()).thenReturn(12345678);
176175

177176
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);
@@ -194,7 +193,7 @@ void onPointsEarnedBigNegativeValue(){
194193
when(data.getBalance()).thenReturn(balance);
195194
when(data.getTimestamp()).thenReturn(ZONED_NOW);
196195
when(pointGain.getTotalPoints()).thenReturn(-2500);
197-
when(pointGain.getReasonCode()).thenReturn(PointReasonCode.CLAIM);
196+
when(pointGain.getReasonCode()).thenReturn("CLAIM");
198197
when(balance.getBalance()).thenReturn(12345678);
199198

200199
var event = new PointsEarnedEvent(STREAMER_ID, STREAMER_USERNAME, streamer, data);

0 commit comments

Comments
 (0)