mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 09:19:40 -05:00
Breaking changes:
'Gift': changed from class to enum, so now you can handle
incoming gifts in switch
`Events`
- new:
onGiftComboFinished
- Removed:
onGiftBrodcast
- Rename:
onGiftMessage -> onGift
onRoomPinMessage -> onRoomPin
onRoomMessage -> onRoom
onLinkMessage -> onLink
onBarrageMessage -> onBarrage
onPollMessage -> onPoll
onShopMessage -> onShop
onDetectMessage -> onDetect
`GiftManager`
added:
registerGift
findById
findByName
getGifts
removed:
getActiveGifts
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok.common;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import io.github.jwdeveloper.tiktok.messages.WebcastWebsocketMessage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
package io.github.jwdeveloper.tiktok.gifts;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||
import org.junit.Assert;
|
||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -33,40 +33,37 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
|
||||
public class TikTokGiftManagerTest
|
||||
{
|
||||
public class TikTokGiftManagerTest {
|
||||
|
||||
@InjectMocks
|
||||
TikTokGiftManager giftManager;
|
||||
|
||||
private static final Picture rosePicture = new Picture("https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/eba3a9bb85c33e017f3648eaf88d7189~tplv-obj.png");
|
||||
|
||||
@Test
|
||||
void registerGift()
|
||||
{
|
||||
var fakeGift = giftManager.registerGift(123,"Fake gift",123123);
|
||||
void registerGift() {
|
||||
var fakeGift = giftManager.registerGift(123, "Fake gift", 123123, rosePicture);
|
||||
var gifts = giftManager.getGifts();
|
||||
var optional = gifts.stream().filter(r -> r == fakeGift).findFirst();
|
||||
Assertions.assertTrue(optional.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void findById()
|
||||
{
|
||||
var target = giftManager.registerGift(123,"FAKE",123123);
|
||||
void findById() {
|
||||
var target = giftManager.registerGift(123, "FAKE", 123123, rosePicture);
|
||||
var result = giftManager.findById(target.getId());
|
||||
Assertions.assertEquals(target,result);
|
||||
Assertions.assertEquals(target, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByName()
|
||||
{
|
||||
var target = giftManager.registerGift(123,"FAKE",123123);
|
||||
var result = giftManager.findByName(target.getName());
|
||||
Assertions.assertEquals(target,result);
|
||||
void findByName() {
|
||||
var target = giftManager.registerGift(123, "FAKE", 123123, rosePicture);
|
||||
var result = giftManager.findByName(target.getName());
|
||||
Assertions.assertEquals(target, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getGifts()
|
||||
{
|
||||
void getGifts() {
|
||||
Assertions.assertEquals(Gift.values().length, giftManager.getGifts().size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user