@Test public void networkComponentAddedWhenChangedToNonTemporary() { LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), NetworkComponent.class); EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0)); entity.addComponent(new RetainedOnBlockChangeComponent(2)); assertEquals( Lists.newArrayList( new EventInfo(OnAddedComponent.newInstance(), entity), new EventInfo(OnActivatedComponent.newInstance(), entity)), checker.receivedEvents); assertTrue(entity.hasComponent(NetworkComponent.class)); }
@Test public void testComponentsAddedAndActivatedWhenBlockChanged() { LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class); worldProvider.setBlock(Vector3i.zero(), blockWithString); EntityRef blockEntity = worldProvider.getBlockEntityAt(Vector3i.zero()); assertTrue(blockEntity.exists()); assertEquals( Lists.newArrayList( new EventInfo(OnAddedComponent.newInstance(), blockEntity), new EventInfo(OnActivatedComponent.newInstance(), blockEntity)), checker.receivedEvents); }
@Test public void testEntityMissingComponentsAddedBeforeCleanUp() { worldStub.setBlock(Vector3i.zero(), blockWithString); EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0)); entity.removeComponent(StringComponent.class); LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class); worldProvider.update(1.0f); assertEquals( Lists.newArrayList( new EventInfo(OnAddedComponent.newInstance(), entity), new EventInfo(OnActivatedComponent.newInstance(), entity)), checker.receivedEvents); }