use of org.terasology.protobuf.EntityData in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaLoadAddedComponent.
@Test
public void testDeltaLoadAddedComponent() throws Exception {
EntityRef entity = entityManager.create("test:Test");
entity.addComponent(new IntegerComponent(2));
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(StringComponent.class));
assertEquals("Value", loadedEntity.getComponent(StringComponent.class).value);
assertTrue(loadedEntity.hasComponent(IntegerComponent.class));
assertEquals(2, loadedEntity.getComponent(IntegerComponent.class).value);
}
Aggregations