diff --git a/src/test/java/uulm/teamname/marvelous/gamelibrary/json/ingame/serialize/EntitySerializerTest.java b/src/test/java/uulm/teamname/marvelous/gamelibrary/json/ingame/serialize/EntitySerializerTest.java index 2957ef3..ab6e46f 100644 --- a/src/test/java/uulm/teamname/marvelous/gamelibrary/json/ingame/serialize/EntitySerializerTest.java +++ b/src/test/java/uulm/teamname/marvelous/gamelibrary/json/ingame/serialize/EntitySerializerTest.java @@ -4,12 +4,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; import uulm.teamname.marvelous.gamelibrary.IntVector2; +import uulm.teamname.marvelous.gamelibrary.entities.*; import uulm.teamname.marvelous.gamelibrary.entities.Character; -import uulm.teamname.marvelous.gamelibrary.entities.EntityID; -import uulm.teamname.marvelous.gamelibrary.entities.EntityType; -import uulm.teamname.marvelous.gamelibrary.entities.StoneType; import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EntityDeserializer; +import java.util.ArrayList; + import static org.mockito.Mockito.*; import static org.junit.jupiter.api.Assertions.*; import static org.assertj.core.api.Assertions.*; @@ -53,4 +53,39 @@ class EntitySerializerTest { .isEqualTo(jsonRepresentingCharacter); } + @Test + void serializeNPC() throws JsonProcessingException { + var mapper = new ObjectMapper(); + //(EntityID id, IntVector2 position, int maxMP, ArrayList inventory + ArrayList al = new ArrayList<>(); + al.add(StoneType.MindStone); + + var npc = new NPC( + new EntityID(EntityType.NPC, 3), + new IntVector2(12, 24), + 200, + al); +/* + var npc2 = new NPC( + new EntityID(EntityType.P2, 3), + new IntVector2(12, 24), + 200, + new Inventory()); +*/ + + var jsonRepresentingNPC = """ + { + "entityType":"NPC", + "name":"CoolHeroThing", + "PID":2, + "ID":3, + "MP":200, + "stones":[1], + "position":[12,24] + }""".replace("\n", ""); + + assertThat(mapper.writeValueAsString(npc)) + .isEqualTo(jsonRepresentingNPC); + } + }