Search in sources :

Example 1 with EnableTestToolsCommand

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);
}
Also used : EnableTestToolsCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.EnableTestToolsCommand)

Example 2 with EnableTestToolsCommand

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));
}
Also used : EnableTestToolsCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.EnableTestToolsCommand) CommandResultImpl(org.kie.workbench.common.command.client.impl.CommandResultImpl) Test(org.junit.Test) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)

Aggregations

EnableTestToolsCommand (org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.EnableTestToolsCommand)2 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)1 Test (org.junit.Test)1 CommandResultImpl (org.kie.workbench.common.command.client.impl.CommandResultImpl)1