Search in sources :

Example 1 with MappedTypeComponent

use of org.terasology.unittest.stubs.MappedTypeComponent in project Terasology by MovingBlocks.

the class EntitySerializerTest method testMappedTypeHandling.

@Test
public void testMappedTypeHandling() throws Exception {
    componentLibrary.register(new ResourceUrn("test", "mappedtype"), MappedTypeComponent.class);
    EntityRef entity = entityManager.create();
    entity.addComponent(new MappedTypeComponent());
    EntityData.Entity entityData = entitySerializer.serialize(entity);
    long nextId = entityManager.getNextId();
    entityManager.clear();
    entityManager.setNextId(nextId);
    EntityRef loadedEntity = entitySerializer.deserialize(entityData);
    assertTrue(loadedEntity.exists());
    assertTrue(loadedEntity.hasComponent(MappedTypeComponent.class));
}
Also used : EntityData(org.terasology.protobuf.EntityData) MappedTypeComponent(org.terasology.unittest.stubs.MappedTypeComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)1 EntityData (org.terasology.protobuf.EntityData)1 MappedTypeComponent (org.terasology.unittest.stubs.MappedTypeComponent)1