@Test public void testUnitOfWorkStartOnFinishedUnit() { UnitOfWork unit = unitOfWorkManager.newUnitOfWork(); assertThat(unit).isNotNull().isInstanceOf(ManagedUnitOfWork.class); unit.start(); unit.abort(); assertThrows(IllegalStateException.class, () -> unit.start(), "Cannot start already completed unit"); assertThrows(IllegalStateException.class, () -> unit.end(), "Cannot end already completed unit"); assertThrows(IllegalStateException.class, () -> unit.abort(), "Cannot abort already completed unit"); assertThrows(IllegalStateException.class, () -> unit.intercept(null), "Cannot intercept on already completed unit"); }
@Override public UnitOfWork newUnitOfWork() { return new ManagedUnitOfWork(factory.create(eventManager), this::associate, this::dissociate, this::dissociate); }
DefaultUnitOfWorkManager implements UnitOfWorkManager { @Override public UnitOfWork newUnitOfWork() { return new ManagedUnitOfWork(factory.create(eventManager), this::associate, this::dissociate, this::dissociate); } }
DefaultUnitOfWorkManager implements UnitOfWorkManager { @Override public UnitOfWork newUnitOfWork() { return new ManagedUnitOfWork(factory.create(eventManager), this::associate, this::dissociate, this::dissociate); } DefaultUnitOfWorkManager(UnitOfWorkFactory factory);  DefaultUnitOfWorkManager(UnitOfWork fallbackUnitOfWork, UnitOfWorkFactory factory); }
DefaultUnitOfWorkManager implements UnitOfWorkManager { @Override public UnitOfWork newUnitOfWork() { return new ManagedUnitOfWork(factory.create(eventManager), this::associate, this::dissociate, this::dissociate); } DefaultUnitOfWorkManager(UnitOfWorkFactory factory);  DefaultUnitOfWorkManager(UnitOfWork fallbackUnitOfWork, UnitOfWorkFactory factory); @Override UnitOfWork currentUnitOfWork(); @Override UnitOfWork newUnitOfWork(); @Override EventManager eventManager(); }
DefaultUnitOfWorkManager implements UnitOfWorkManager { @Override public UnitOfWork newUnitOfWork() { return new ManagedUnitOfWork(factory.create(eventManager), this::associate, this::dissociate, this::dissociate); } DefaultUnitOfWorkManager(UnitOfWorkFactory factory);  DefaultUnitOfWorkManager(UnitOfWork fallbackUnitOfWork, UnitOfWorkFactory factory); @Override UnitOfWork currentUnitOfWork(); @Override UnitOfWork newUnitOfWork(); @Override EventManager eventManager();  }