Search in sources :

Example 1 with PojoEntityPool

use of org.terasology.engine.entitySystem.entity.internal.PojoEntityPool in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testMoveToPool.

@Test
public void testMoveToPool() {
    EntityRef entity = entityManager.create();
    long id = entity.getId();
    PojoEntityPool pool1 = new PojoEntityPool(entityManager);
    PojoEntityPool pool2 = new PojoEntityPool(entityManager);
    assertFalse(pool1.contains(id));
    assertFalse(pool2.contains(id));
    assertTrue(entityManager.moveToPool(id, pool1));
    assertTrue(pool1.contains(id));
    assertFalse(pool2.contains(id));
    assertTrue(entityManager.moveToPool(id, pool2));
    assertTrue(pool2.contains(id));
    assertFalse(pool1.contains(id));
}
Also used : PojoEntityPool(org.terasology.engine.entitySystem.entity.internal.PojoEntityPool) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 2 with PojoEntityPool

use of org.terasology.engine.entitySystem.entity.internal.PojoEntityPool in project Terasology by MovingBlocks.

the class PojoEntityPoolTest method setup.

@BeforeEach
public void setup() {
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = (PojoEntityManager) context.get(EntityManager.class);
    pool = new PojoEntityPool(entityManager);
}
Also used : PojoEntityPool(org.terasology.engine.entitySystem.entity.internal.PojoEntityPool) NetworkSystem(org.terasology.engine.network.NetworkSystem) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PojoEntityPool (org.terasology.engine.entitySystem.entity.internal.PojoEntityPool)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 NetworkSystem (org.terasology.engine.network.NetworkSystem)1