#3851: Remove output from tests and "base" from dialog json
This commit is contained in:
parent
bccce74c3c
commit
5e59b6dc85
@ -121,6 +121,7 @@ public class DialogSerializer implements JsonDeserializer<Dialog>, JsonSerialize
|
|||||||
|
|
||||||
JsonObject base = (JsonObject) context.serialize( src.getBase() );
|
JsonObject base = (JsonObject) context.serialize( src.getBase() );
|
||||||
object.asMap().putAll( base.asMap() );
|
object.asMap().putAll( base.asMap() );
|
||||||
|
object.remove( "base" );
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
} finally
|
} finally
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.dialog;
|
package net.md_5.bungee.dialog;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.dialog.Dialog;
|
import net.md_5.bungee.api.dialog.Dialog;
|
||||||
@ -11,15 +12,26 @@ import org.junit.jupiter.api.Test;
|
|||||||
public class SimpleTest
|
public class SimpleTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static void testDissembleReassemble(Dialog notice)
|
||||||
|
{
|
||||||
|
String json = VersionedComponentSerializer.getDefault().getDialogSerializer().toString( notice );
|
||||||
|
Dialog parsed = VersionedComponentSerializer.getDefault().getDialogSerializer().deserialize( json );
|
||||||
|
assertEquals( notice, parsed );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotice()
|
public void testSimple()
|
||||||
{
|
{
|
||||||
String json = "{type:\"minecraft:notice\",title:\"Hello\"}";
|
String json = "{type:\"minecraft:notice\",title:\"Hello\"}";
|
||||||
Dialog deserialized = VersionedComponentSerializer.getDefault().getDialogSerializer().deserialize( json );
|
Dialog deserialized = VersionedComponentSerializer.getDefault().getDialogSerializer().deserialize( json );
|
||||||
System.err.println( deserialized );
|
String serialized = VersionedComponentSerializer.getDefault().getDialogSerializer().toString( deserialized );
|
||||||
|
|
||||||
Dialog notice = new NoticeDialog( new DialogBase( new ComponentBuilder( "Hello" ).color( ChatColor.RED ).build() ) );
|
assertEquals( "{\"type\":\"minecraft:notice\",\"title\":{\"text\":\"Hello\"}}", serialized );
|
||||||
String newJson = VersionedComponentSerializer.getDefault().getDialogSerializer().toString( notice );
|
}
|
||||||
System.err.println( newJson );
|
|
||||||
|
@Test
|
||||||
|
public void testNotice()
|
||||||
|
{
|
||||||
|
testDissembleReassemble( new NoticeDialog( new DialogBase( new ComponentBuilder( "Hello" ).color( ChatColor.RED ).build() ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user