ScenarioSimulationKogitoStateControlManager { public void initialize(final ScenarioCommandRegistryManager scenarioCommandRegistryManager, final ScenarioSimulationContext scenarioSimulationContext) { if (isEnvelopeAvailable()) { stateControlSupplier.get().setUndoCommand(() -> scenarioCommandRegistryManager.undo(scenarioSimulationContext)); stateControlSupplier.get().setRedoCommand(() -> scenarioCommandRegistryManager.redo(scenarioSimulationContext)); } } @Inject  ScenarioSimulationKogitoStateControlManager(); void initialize(final ScenarioCommandRegistryManager scenarioCommandRegistryManager,
                           final ScenarioSimulationContext scenarioSimulationContext);  }
@Test public void initialize_EnvelopeAvailable() { scenarioSimulationKogitoStateControlManagerSpy.initialize(scenarioCommandRegistryManagerMock, scenarioSimulationContextMock); verify(stateControlSpy, times(1)).setUndoCommand(stateControlUndoCommandCaptor.capture()); verify(stateControlSpy, times(1)).setRedoCommand(stateControlRedoCommandCaptor.capture()); stateControlUndoCommandCaptor.getValue().execute(); verify(scenarioCommandRegistryManagerMock, times(1)).undo(eq(scenarioSimulationContextMock)); stateControlRedoCommandCaptor.getValue().execute(); verify(scenarioCommandRegistryManagerMock, times(1)).redo(eq(scenarioSimulationContextMock)); }
@Test public void initialize_EnvelopeNotAvailable() { envelopeAvailableBoolean = false; scenarioSimulationKogitoStateControlManagerSpy.initialize(scenarioCommandRegistryManagerMock, scenarioSimulationContextMock); verify(stateControlSpy, never()).setUndoCommand(any()); verify(stateControlSpy, never()).setRedoCommand(any()); }