feat: implemented proper deserialization for EntityID and IntVector2
This commit is contained in:
@ -0,0 +1,37 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.json.ingame;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.jqwik.api.*;
|
||||
import net.jqwik.api.lifecycle.BeforeProperty;
|
||||
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
class IntVector2SerializerTest {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@BeforeProperty
|
||||
void setup() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Property
|
||||
void vectorsGetProperlyDeserialized(@ForAll @From("positions") IntVector2 vector) throws JsonProcessingException {
|
||||
var jsonRepresentingVector = String.format("[%d,%d]", vector.getX(), vector.getY());
|
||||
assertThat(mapper.writeValueAsString(vector))
|
||||
.isEqualTo(jsonRepresentingVector);
|
||||
|
||||
}
|
||||
|
||||
@Provide("positions")
|
||||
Arbitrary<IntVector2> positions() {
|
||||
return Arbitraries.integers()
|
||||
.tuple2()
|
||||
.map(pos -> new IntVector2(pos.get1(), pos.get2()));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user