use of org.drools.workbench.screens.scenariosimulation.model.SimulationRunResult in project drools-wb by kiegroup.
the class ScenarioSimulationEditorPresenter method refreshModelContent.
protected void refreshModelContent(SimulationRunResult newData) {
view.hideBusyIndicator();
if (this.model == null) {
return;
}
// refresh simulation data
Simulation simulation = this.model.getSimulation();
for (ScenarioWithIndex scenarioWithIndex : newData.getScenarioWithIndex()) {
int index = scenarioWithIndex.getIndex() - 1;
simulation.replaceData(index, scenarioWithIndex.getScesimData());
}
scenarioMainGridWidget.refreshContent(simulation);
context.getStatus().setSimulation(simulation);
// refresh background data
boolean hasBackgroundError = false;
Background background = this.model.getBackground();
for (BackgroundDataWithIndex backgroundDataWithIndex : newData.getBackgroundDataWithIndex()) {
int index = backgroundDataWithIndex.getIndex() - 1;
BackgroundData scesimData = backgroundDataWithIndex.getScesimData();
background.replaceData(index, scesimData);
hasBackgroundError |= scesimData.getUnmodifiableFactMappingValues().stream().anyMatch(elem -> !FactMappingValueStatus.SUCCESS.equals(elem.getStatus()));
}
scenarioBackgroundGridWidget.refreshContent(background);
context.getStatus().setBackground(background);
if (hasBackgroundError) {
sendNotification(ScenarioSimulationEditorConstants.INSTANCE.backgroundErrorNotification(), NotificationEvent.NotificationType.ERROR);
selectBackgroundTab();
}
dataManagementStrategy.setModel(model);
abstractScenarioSimulationDocksHandler.expandTestResultsDock();
scenarioSimulationEditorWrapper.onRefreshedModelContent(newData);
}
use of org.drools.workbench.screens.scenariosimulation.model.SimulationRunResult in project drools-wb by kiegroup.
the class ScenarioSimulationEditorPresenterTest method refreshModelContent.
@Test
public void refreshModelContent() {
when(scenarioSimulationModelMock.getSimulation()).thenReturn(simulationMock);
List<ScenarioWithIndex> scenarioWithIndex = new ArrayList<>();
int scenarioNumber = 1;
int scenarioIndex = scenarioNumber - 1;
Scenario scenario = mock(Scenario.class);
scenarioWithIndex.add(new ScenarioWithIndex(scenarioNumber, scenario));
List<BackgroundDataWithIndex> backgroundDataWithIndex = new ArrayList<>();
BackgroundData backgroundData = mock(BackgroundData.class);
backgroundDataWithIndex.add(new BackgroundDataWithIndex(scenarioNumber, backgroundData));
TestResultMessage testResultMessage = mock(TestResultMessage.class);
SimulationRunResult testRunResult = new SimulationRunResult(scenarioWithIndex, backgroundDataWithIndex, new SimulationRunMetadata(), testResultMessage);
presenterSpy.refreshModelContent(testRunResult);
verify(scenarioSimulationViewMock, times(1)).hideBusyIndicator();
verify(simulationMock, times(1)).replaceData(eq(scenarioIndex), eq(scenario));
assertEquals(scenarioSimulationModelMock, presenterSpy.getModel());
verify(scenarioGridWidgetSpy, times(1)).refreshContent(eq(simulationMock));
assertEquals(scenarioSimulationContextLocal.getStatus().getSimulation(), simulationMock);
verify(backgroundMock, times(1)).replaceData(eq(scenarioIndex), eq(backgroundData));
verify(backgroundGridWidgetSpy, times(1)).refreshContent(eq(backgroundMock));
assertEquals(scenarioSimulationContextLocal.getStatus().getBackground(), backgroundMock);
assertEquals(scenarioSimulationModelMock, presenterSpy.getModel());
verify(abstractScenarioSimulationDocksHandlerMock, times(1)).expandTestResultsDock();
verify(dataManagementStrategyMock, times(1)).setModel(eq(scenarioSimulationModelMock));
verify(scenarioSimulationEditorWrapperMock, times(1)).onRefreshedModelContent(eq(testRunResult));
}
Aggregations