Search in sources :

Example 1 with EntityStore

use of org.terasology.entitySystem.entity.EntityStore in project Terasology by MovingBlocks.

the class LocalChunkProviderTest method testCompleteUpdateGeneratesStoredEntitiesFromPrefab.

@Test
public void testCompleteUpdateGeneratesStoredEntitiesFromPrefab() throws Exception {
    final Chunk chunk = mockChunkAt(0, 0, 0);
    final Prefab prefab = mock(Prefab.class);
    final ChunkProviderTestComponent testComponent = new ChunkProviderTestComponent();
    final EntityStore entityStore = createEntityStoreWithPrefabAndComponents(prefab, testComponent);
    final List<EntityStore> entityStores = Collections.singletonList(entityStore);
    final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForNewChunk(chunk, new TShortObjectHashMap<>(), entityStores);
    when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo);
    final EntityRef mockEntity = mock(EntityRef.class);
    when(entityManager.create(any(Prefab.class))).thenReturn(mockEntity);
    chunkProvider.completeUpdate();
    verify(entityManager).create(eq(prefab));
    verify(mockEntity).addComponent(eq(testComponent));
}
Also used : ReadyChunkInfo(org.terasology.world.chunks.internal.ReadyChunkInfo) EntityStore(org.terasology.entitySystem.entity.EntityStore) Chunk(org.terasology.world.chunks.Chunk) Prefab(org.terasology.entitySystem.prefab.Prefab) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Example 2 with EntityStore

use of org.terasology.entitySystem.entity.EntityStore in project Terasology by MovingBlocks.

the class LocalChunkProviderTest method testCompleteUpdateGeneratesStoredEntities.

@Test
public void testCompleteUpdateGeneratesStoredEntities() throws Exception {
    final Chunk chunk = mockChunkAt(0, 0, 0);
    final ChunkProviderTestComponent testComponent = new ChunkProviderTestComponent();
    final EntityStore entityStore = createEntityStoreWithComponents(testComponent);
    final List<EntityStore> entityStores = Collections.singletonList(entityStore);
    final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForNewChunk(chunk, new TShortObjectHashMap<>(), entityStores);
    when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo);
    final EntityRef mockEntity = mock(EntityRef.class);
    when(entityManager.create()).thenReturn(mockEntity);
    chunkProvider.completeUpdate();
    verify(mockEntity).addComponent(eq(testComponent));
}
Also used : ReadyChunkInfo(org.terasology.world.chunks.internal.ReadyChunkInfo) EntityStore(org.terasology.entitySystem.entity.EntityStore) Chunk(org.terasology.world.chunks.Chunk) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 EntityStore (org.terasology.entitySystem.entity.EntityStore)2 Chunk (org.terasology.world.chunks.Chunk)2 ReadyChunkInfo (org.terasology.world.chunks.internal.ReadyChunkInfo)2 Prefab (org.terasology.entitySystem.prefab.Prefab)1