Search in sources :

Example 1 with MappedTypeComponent

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

the class EntitySerializerTest method testMappedTypeHandling.

@Test
public void testMappedTypeHandling() throws Exception {
    componentLibrary.register(new SimpleUri("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 : SimpleUri(org.terasology.engine.SimpleUri) EntityData(org.terasology.protobuf.EntityData) MappedTypeComponent(org.terasology.entitySystem.stubs.MappedTypeComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 SimpleUri (org.terasology.engine.SimpleUri)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 MappedTypeComponent (org.terasology.entitySystem.stubs.MappedTypeComponent)1 EntityData (org.terasology.protobuf.EntityData)1