worked on tests for EntitySerializer (not ready so far, I work again on it tomorow)
This commit is contained in:
parent
19f6695ba8
commit
9be5f6c10c
@ -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<StoneType> inventory
|
||||
ArrayList<StoneType> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user