use of org.terasology.world.chunks.internal.ReadyChunkInfo in project Terasology by MovingBlocks.
the class LocalChunkProviderTest method testCompleteUpdateRestoresEntitiesForRestoredChunks.
@Test
public void testCompleteUpdateRestoresEntitiesForRestoredChunks() throws Exception {
final Chunk chunk = mockChunkAt(0, 0, 0);
final ChunkStore chunkStore = mock(ChunkStore.class);
final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForRestoredChunk(chunk, new TShortObjectHashMap<>(), chunkStore, Collections.emptyList());
when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo);
chunkProvider.completeUpdate();
verify(chunkStore).restoreEntities();
}
use of org.terasology.world.chunks.internal.ReadyChunkInfo 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));
}
use of org.terasology.world.chunks.internal.ReadyChunkInfo in project Terasology by MovingBlocks.
the class LocalChunkProviderTest method testCompleteUpdateMarksChunkReady.
@Test
public void testCompleteUpdateMarksChunkReady() throws Exception {
final Chunk chunk = mockChunkAt(0, 0, 0);
final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForNewChunk(chunk, new TShortObjectHashMap<>(), Collections.emptyList());
when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo);
chunkProvider.completeUpdate();
verify(chunk).markReady();
}
use of org.terasology.world.chunks.internal.ReadyChunkInfo in project Terasology by MovingBlocks.
the class LocalChunkProviderTest method testCompleteUpdateHandlesFinalizedChunkIfReady.
@Test
public void testCompleteUpdateHandlesFinalizedChunkIfReady() throws Exception {
final Chunk chunk = mockChunkAt(0, 0, 0);
final ReadyChunkInfo readyChunkInfo = ReadyChunkInfo.createForNewChunk(chunk, new TShortObjectHashMap<>(), Collections.emptyList());
when(chunkFinalizer.completeFinalization()).thenReturn(readyChunkInfo);
chunkProvider.completeUpdate();
final InOrder inOrderVerification = inOrder(worldEntity);
inOrderVerification.verify(worldEntity).send(any(OnChunkGenerated.class));
inOrderVerification.verify(worldEntity).send(any(OnChunkLoaded.class));
}
use of org.terasology.world.chunks.internal.ReadyChunkInfo 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));
}
Aggregations