ManagerComponentImpl implements ManagerComponent { @Override @SuppressWarnings("unchecked") public <E> Manager<E> managerOf(Class<E> entityClass) { requireNonNull(entityClass); @SuppressWarnings("unchecked") final Manager<E> manager = (Manager<E>) managersByEntity.get(entityClass); if (manager == null) { throw new SpeedmentException( "No manager exists for " + entityClass ); } return manager; } ManagerComponentImpl(); @Override void put(Manager<ENTITY> manager); @Override @SuppressWarnings("unchecked") Manager<E> managerOf(Class<E> entityClass); @Override Stream<Manager<?>> stream();  }
@Test void managerOf() { assertThrows(NullPointerException.class, () -> instance.managerOf(null)); assertThrows(SpeedmentException.class, () -> instance.managerOf(Integer.class)); final Manager<String> manager = new MockStringManager(); instance.put(manager); assertDoesNotThrow(() -> instance.managerOf(manager.getEntityClass())); }