use of org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.EnableTestToolsCommand in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandler method onEvent.
@Override
public void onEvent(EnableTestToolsEvent event) {
context.getStatus().setFilterTerm(event.getFilterTerm());
context.getStatus().setPropertyNameElements(event.getPropertyNameElements());
context.getStatus().setNotEqualsSearch(event.isNotEqualsSearch());
commonExecution(new EnableTestToolsCommand(), false);
}
use of org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.EnableTestToolsCommand in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandlerTest method commonExecution.
@Test
public void commonExecution() {
when(scenarioCommandManagerMock.execute(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock))).thenReturn(CommandResultBuilder.SUCCESS);
scenarioSimulationEventHandler.commonExecution(appendRowCommandMock, true);
assertEquals(simulationMock, scenarioSimulationContextLocal.getStatus().getSimulation());
verify(scenarioCommandRegistryManagerMock, times(1)).register(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock));
//
reset(scenarioCommandRegistryManagerMock);
CommandResult<ScenarioSimulationViolation> status = new CommandResultImpl<>(CommandResult.Type.ERROR, Collections.singletonList(new ScenarioSimulationViolation("FAKE ERROR")));
when(scenarioCommandManagerMock.execute(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock))).thenReturn(status);
scenarioSimulationEventHandler.commonExecution(appendRowCommandMock, true);
assertEquals(simulationMock, scenarioSimulationContextLocal.getStatus().getSimulation());
verify(scenarioCommandRegistryManagerMock, never()).register(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock));
//
reset(scenarioCommandRegistryManagerMock);
when(scenarioCommandManagerMock.execute(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock))).thenReturn(CommandResultBuilder.SUCCESS);
EnableTestToolsCommand enableTestToolsCommandMock = mock(EnableTestToolsCommand.class);
scenarioSimulationEventHandler.commonExecution(enableTestToolsCommandMock, true);
verify(scenarioCommandRegistryManagerMock, never()).register(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock));
}
Aggregations