Skip to content

Commit b0a33d7

Browse files
Rakambdambax
authored andcommitted
Parse emote-sets as String as it can contain UUIDs
1 parent 9dc486a commit b0a33d7

File tree

2 files changed

+51
-3
lines changed
  • src
    • main/java/org/kitteh/irc/client/library/feature/twitch/messagetag
    • test/java/org/kitteh/irc/client/library/feature/twitch/messagetag

2 files changed

+51
-3
lines changed

src/main/java/org/kitteh/irc/client/library/feature/twitch/messagetag/EmoteSets.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ public class EmoteSets extends MessageTagManager.DefaultMessageTag {
5050
@SuppressWarnings("ConstantConditions")
5151
public static final TriFunction<Client, String, String, EmoteSets> FUNCTION = (client, name, value) -> new EmoteSets(name, value);
5252

53-
private final List<Integer> emoteSets;
53+
private final List<String> emoteSets;
5454

5555
private EmoteSets(@NonNull String name, @Nullable String value) {
5656
super(name, value);
57-
this.emoteSets = (value == null) ? Collections.emptyList() : Collections.unmodifiableList(Arrays.stream(value.split(",")).map(Integer::valueOf).collect(Collectors.toList()));
57+
this.emoteSets = (value == null) ? Collections.emptyList() : Collections.unmodifiableList(Arrays.asList(value.split(",")));
5858
}
5959

6060
/**
6161
* Gets the list of emote sets.
6262
*
6363
* @return list of integers, at least containing 0.
6464
*/
65-
public @NonNull List<Integer> getEmoteSets() {
65+
public @NonNull List<String> getEmoteSets() {
6666
return this.emoteSets;
6767
}
6868

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.kitteh.irc.client.library.feature.twitch.messagetag;
2+
3+
import org.kitteh.irc.client.library.Client;
4+
import org.mockito.Mockito;
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
import java.util.Arrays;
8+
import java.util.Collections;
9+
import java.util.List;
10+
11+
public class EmoteSetsTest{
12+
private static final String NAME = "emote-sets";
13+
14+
/**
15+
* Verifies integer format is accepted.
16+
*/
17+
@Test
18+
public void verifyInteger(){
19+
Client client = Mockito.mock(Client.class);
20+
EmoteSets tested = EmoteSets.FUNCTION.apply(client, NAME, "123,456,789");
21+
22+
List<String> expected = Arrays.asList("123", "456", "789");
23+
Assert.assertEquals(expected, tested.getEmoteSets());
24+
}
25+
26+
/**
27+
* Verifies UUID format is accepted.
28+
*/
29+
@Test
30+
public void verifyUUID(){
31+
Client client = Mockito.mock(Client.class);
32+
EmoteSets tested = EmoteSets.FUNCTION.apply(client, NAME, "fb70df85-0e31-41ea-a13f-c3201bac7013,1a313266-b8e1-49c2-9409-68526a85a350");
33+
34+
List<String> expected = Arrays.asList("fb70df85-0e31-41ea-a13f-c3201bac7013", "1a313266-b8e1-49c2-9409-68526a85a350");
35+
Assert.assertEquals(expected, tested.getEmoteSets());
36+
}
37+
38+
/**
39+
* Verifies null values returns an empty list.
40+
*/
41+
@Test
42+
public void verifyNull(){
43+
Client client = Mockito.mock(Client.class);
44+
EmoteSets tested = EmoteSets.FUNCTION.apply(client, NAME, null);
45+
46+
Assert.assertEquals(Collections.emptyList(), tested.getEmoteSets());
47+
}
48+
}

0 commit comments

Comments
 (0)