use of org.terasology.unittest.stubs.EntityRefComponent in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testDestroyingEntityInvalidatesEntityRefs.
@Test
public void testDestroyingEntityInvalidatesEntityRefs() {
EntityRef main = entityManager.create();
main.addComponent(new StringComponent());
EntityRef reference = entityManager.create();
EntityRefComponent refComp = reference.addComponent(new EntityRefComponent());
refComp.entityRef = entityManager.getEntitiesWith(StringComponent.class).iterator().next();
assertTrue(main.exists());
entityManager.getEntitiesWith(StringComponent.class).iterator().next().destroy();
assertFalse(main.exists());
assertFalse(refComp.entityRef.exists());
}
use of org.terasology.unittest.stubs.EntityRefComponent in project Terasology by MovingBlocks.
the class StorageManagerTest method testReferenceRemainsValidOverStorageRestoral.
@Test
public void testReferenceRemainsValidOverStorageRestoral() throws Exception {
EntityRef someEntity = entityManager.create();
character.addComponent(new EntityRefComponent(someEntity));
esm.waitForCompletionOfPreviousSaveAndStartSaving();
esm.finishSavingAndShutdown();
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
EngineEntityManager newEntityManager = context.get(EngineEntityManager.class);
StorageManager newSM = new ReadWriteStorageManager(savePath, moduleEnvironment, newEntityManager, blockManager, extraDataManager, false, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
newSM.loadGlobalStore();
PlayerStore restored = newSM.loadPlayerStore(PLAYER_ID);
restored.restoreEntities();
assertTrue(restored.getCharacter().getComponent(EntityRefComponent.class).entityRef.exists());
}
Aggregations