/
ChannelInformationTest.java
50 lines (42 loc) · 2.09 KB
/
ChannelInformationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.github.twitch4j.helix.domain;
import com.github.twitch4j.common.util.TypeConvert;
import com.github.twitch4j.eventsub.domain.ContentClassification;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
class ChannelInformationTest {
@Test
void deserializeLabels() {
String json = "{\"content_classification_labels\":[\"Gambling\",\"DrugsIntoxication\",\"MatureGame\"],\"is_branded_content\":true}";
ChannelInformation info = TypeConvert.jsonToObject(json, ChannelInformation.class);
assertNotNull(info);
assertEquals(
Arrays.asList(
new ContentClassificationState(ContentClassification.GAMBLING, true),
new ContentClassificationState(ContentClassification.DRUGS, true),
new ContentClassificationState(ContentClassification.MATURE_GAME, true)
),
info.getContentClassificationLabels()
);
assertTrue(info.isBrandedContent());
}
@Test
void serializeLabels() {
ChannelInformation info = ChannelInformation.builder()
.contentClassificationLabel(new ContentClassificationState(ContentClassification.PROFANITY, true))
.contentClassificationLabel(new ContentClassificationState(ContentClassification.SEXUAL, false))
.build();
String expected = "{\"content_classification_labels\":[{\"id\":\"ProfanityVulgarity\",\"is_enabled\":true},{\"id\":\"SexualThemes\",\"is_enabled\":false}]}";
assertEquals(expected, TypeConvert.objectToJson(info));
}
@Test
void serializeWithoutMature() {
ChannelInformation info = ChannelInformation.builder()
.contentClassificationLabel(new ContentClassificationState(ContentClassification.MATURE_GAME, true))
.build();
String expected = "{\"content_classification_labels\":[]}";
assertEquals(expected, TypeConvert.objectToJson(info));
}
}