Context implements IContext<TEntity> { @Override public void destroyAllEntities() { for (TEntity entity : getEntities()) { entity.destroy(); } _entities.clear(); if (_retainedEntities.size() != 0) { throw new ContextStillHasRetainedEntitiesException(this); } } Context(int totalComponents, int startCreationIndex, ContextInfo contexInfo,
                   EntityBaseFactory<TEntity> factoryMethod, Function<TEntity, IAERC> aercFactory); @Override TEntity createEntity(); @Override void destroyAllEntities(); @Override boolean hasEntity(TEntity entity); @Override TEntity[] getEntities(); @Override int getTotalComponents(); @Override Group<TEntity> getGroup(IMatcher matcher); @Override void addEntityIndex(IEntityIndex entityIndex); @Override IEntityIndex getEntityIndex(String name); @Override void resetCreationIndex(); @Override void clearComponentPool(int index); @Override void clearComponentPools(); @Override void reset(); void updateGroupsComponentAddedOrRemoved(TEntity entity, int index, IComponent component, List<Group<TEntity>>[] groupsForIndex); @Override Stack<IComponent>[] getComponentPools(); @Override ContextInfo getContextInfo(); @Override int getCount(); @Override int getReusableEntitiesCount(); @Override int getRetainedEntitiesCount(); IEntity[] getEntities(IMatcher matcher); @Override Collector createCollector(IMatcher matcher); @Override Collector createCollector(IMatcher matcher, GroupEvent groupEvent); Collector<TEntity> createCollector(Context context, TriggerOnEvent<TEntity>[] triggers); void clearEventsListener(); void OnEntityCreated(ContextEntityChanged listener); void OnEntityWillBeDestroyed(ContextEntityChanged listener); void OnEntityDestroyed(ContextEntityChanged listener); void OnGroupCreated(ContextGroupChanged listener); void notifyEntityCreated(IEntity entity); void notifyEntityWillBeDestroyed(IEntity entity); void notifyEntityDestroyed(IEntity entity); void notifyGroupCreated(IGroup group); @Override String toString(); public int _totalComponents; public Class<TEntity> entityType; public Set<ContextEntityChanged> OnEntityCreated; public Set<ContextEntityChanged> OnEntityWillBeDestroyed; public Set<ContextEntityChanged> OnEntityDestroyed; public Set<ContextGroupChanged> OnGroupCreated; }
@Test(expected = ContextStillHasRetainedEntitiesException.class) public void PoolStillHasRetainedEntitiesExceptionTest() { entity.retain(new Object()); context.destroyEntity(entity); context.destroyAllEntities(); }