some improvements for tests
This commit is contained in:
parent
38865aea70
commit
8dd5b864f3
@ -220,7 +220,7 @@ class EventBuilderTest {
|
||||
@Test
|
||||
void buildWrongEntityEvent() {
|
||||
EventBuilder eb = new EventBuilder(EventType.DestroyedEntityEvent);
|
||||
//the target entity is not set
|
||||
//the target entity is not set. This is an error.
|
||||
EntityEvent des2 = eb
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.buildEntityEvent();
|
||||
@ -234,7 +234,7 @@ class EventBuilderTest {
|
||||
@Test
|
||||
void buildWrongCharacterEvent() {
|
||||
EventBuilder eb = new EventBuilder(EventType.MeleeAttackEvent);
|
||||
//the target entity is not set
|
||||
//the target entity is not set. This is an error.
|
||||
CharacterEvent des2 = eb
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.buildCharacterEvent();
|
||||
@ -247,7 +247,7 @@ class EventBuilderTest {
|
||||
|
||||
@Test
|
||||
void buildEntityEvent() {
|
||||
//testing EntityEvent class
|
||||
//testing EntityEvent and EventBuilder classes
|
||||
assertThat(new EventBuilder(EventType.DestroyedEntityEvent)
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.withTargetEntity(new EntityID(EntityType.P1,1))
|
||||
@ -264,11 +264,10 @@ class EventBuilderTest {
|
||||
.withTargetEntity(new EntityID(EntityType.P1,1))
|
||||
.buildEntityEvent();
|
||||
|
||||
//testing EventBuilder and EntityEvent class
|
||||
//testing EventBuilder and EntityEvent classes
|
||||
assertEquals(des.type, des2.type);
|
||||
assertEquals(des.targetEntity, des2.targetEntity);
|
||||
assertEquals(des.targetField, des2.targetField);
|
||||
// EntityEvent des2 = new EntityEvent(eb.);
|
||||
|
||||
assertEquals(des, des2);
|
||||
assertEquals(des.hashCode(), des2.hashCode());
|
||||
@ -283,7 +282,7 @@ class EventBuilderTest {
|
||||
|
||||
@Test
|
||||
void buildCharacterEvent() {
|
||||
//testing CharacterEvent class
|
||||
//testing CharacterEvent and EventBuilder classes
|
||||
assertThat(new EventBuilder(EventType.MeleeAttackEvent)
|
||||
.withOriginField(new IntVector2(2,2))
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
@ -364,7 +363,7 @@ class EventBuilderTest {
|
||||
|
||||
@Test
|
||||
void buildCustomEvent() {
|
||||
//testing CustomEvent class
|
||||
//testing CustomEvent and EventBuilder classes
|
||||
assertThat(new EventBuilder(EventType.CustomEvent)
|
||||
.withCustomContent(new HashMap<>())
|
||||
.buildCustomEvent().check()).isTrue();
|
||||
|
@ -17,7 +17,7 @@ class EntitySerializerTest {
|
||||
@Test
|
||||
void serializeCharacter() throws JsonProcessingException {
|
||||
|
||||
//test if all required values are set in json
|
||||
//testing, if all required values are set in json
|
||||
// and that this is done in the right order as defined in the methods serialize() and serializeCharacter().
|
||||
|
||||
var mapper = new ObjectMapper();
|
||||
@ -90,8 +90,6 @@ class EntitySerializerTest {
|
||||
|
||||
//________________________________________________
|
||||
|
||||
// al.removeStone(StoneType.MindStone);
|
||||
//Inventory inv = new Inventory(al);
|
||||
var npc0= new NPC(
|
||||
new EntityID(EntityType.NPC, 3),
|
||||
new IntVector2(12, 24));
|
||||
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
//import net.jqwik.api.*;
|
||||
//import net.jqwik.api.lifecycle.BeforeProperty;
|
||||
import net.jqwik.api.*;
|
||||
import net.jqwik.api.lifecycle.BeforeProperty;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.*;
|
||||
@ -14,7 +16,6 @@ import java.util.HashMap;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
public class EventSerializerTest {
|
||||
//System.out.println(mapper.writeValueAsString(gse));
|
||||
|
||||
EntityID[] turns;
|
||||
EntityID turn;
|
||||
@ -72,10 +73,18 @@ public class EventSerializerTest {
|
||||
gse2.activeCharacter = ac;
|
||||
System.out.println(mapper.writeValueAsString(gse2));
|
||||
|
||||
// ERROR!!! "Can not write a field name, expecting a value" bei active Character
|
||||
jsonRepresentingGSE = """
|
||||
{"eventType":"GamestateEvent",
|
||||
"entities":[{"entityType":"NPC","ID":1,"MP":0,"stones":[],
|
||||
"position":[1,1]}],"mapSize":[42,24],
|
||||
"turnOrder":[{"entityID":"NPC","ID":1}],
|
||||
"activeCharacter":{"entityID":"P1","ID":2},
|
||||
"stoneCooldowns":[6,5,4,3,2,1],
|
||||
"winCondition":false
|
||||
}""".replace("\n", "");
|
||||
|
||||
// assertThat(mapper.writeValueAsString(gse2))
|
||||
// .isEqualTo(jsonRepresentingGSE);
|
||||
assertThat(mapper.writeValueAsString(gse2))
|
||||
.isEqualTo(jsonRepresentingGSE);
|
||||
|
||||
}
|
||||
|
||||
@ -181,13 +190,8 @@ public class EventSerializerTest {
|
||||
|
||||
System.out.println(mapper.writeValueAsString(ce2));
|
||||
|
||||
// ERROR !!! "Can not start an object, expecting field name (context: Object)" bei stoneType
|
||||
//assertThat(mapper.writeValueAsString(ce2))
|
||||
// .isEqualTo(jsonRepresentingEE);
|
||||
|
||||
//gen.writeObject(new EntityID(EntityType.InfinityStones, value.stoneType.getID()));
|
||||
|
||||
|
||||
assertThat(mapper.writeValueAsString(ce2))
|
||||
.isEqualTo(jsonRepresentingEE);
|
||||
|
||||
}
|
||||
|
||||
@ -203,19 +207,16 @@ public class EventSerializerTest {
|
||||
ge.characterOrder = eid;
|
||||
|
||||
var jsonRepresentingEE = """
|
||||
{
|
||||
"eventType":"MeleeAttackEvent",
|
||||
"originEntity":{"entityID":"P2","ID":7},
|
||||
"targetEntity":{"entityID":"P1","ID":5},
|
||||
"originField":null,"targetField":[2,2]
|
||||
}""".replace("\n", "");
|
||||
{
|
||||
"eventType":"RoundSetupEvent",
|
||||
"roundCount":5,
|
||||
"characterOrder":[{"entityID":"NPC","ID":1}]
|
||||
}""".replace("\n", "");
|
||||
|
||||
// System.out.println(mapper.writeValueAsString(ge));
|
||||
|
||||
// ERROR !!! "Current context not Array but Object" bei characterorder
|
||||
|
||||
// assertThat(mapper.writeValueAsString(ge))
|
||||
// .isEqualTo(jsonRepresentingEE);
|
||||
assertThat(mapper.writeValueAsString(ge))
|
||||
.isEqualTo(jsonRepresentingEE);
|
||||
|
||||
GameEvent ge2 = new GameEvent();
|
||||
ge2.type = EventType.TurnEvent;
|
||||
@ -301,7 +302,7 @@ public class EventSerializerTest {
|
||||
.isEqualTo(jsonRepresentingEE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
ObjectMapper mapper;
|
||||
|
||||
@BeforeProperty
|
||||
@ -376,6 +377,6 @@ public class EventSerializerTest {
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class RequestBuilderTest {
|
||||
.buildCharacterRequest();
|
||||
|
||||
//since we tested in the test before that the equals() method from the CharacterRequest class works fine
|
||||
// we can use this method here. and do not have to test all properties for itself, e.g.: "assertEquals(cr.targetEntity, cr2.targetEntity)";
|
||||
// we can use this method here and do not have to test all properties for itself, e.g.: "assertEquals(cr.targetEntity, cr2.targetEntity)";
|
||||
|
||||
assertTrue(cr.equals(cr2));
|
||||
|
||||
@ -89,8 +89,6 @@ class RequestBuilderTest {
|
||||
@Test
|
||||
void testBuildGameRequest() {
|
||||
|
||||
//implementation of the GameRequest class is mostly missing yet.
|
||||
|
||||
GameRequest gr = new GameRequest();
|
||||
gr.type = RequestType.PauseStopRequest;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user