use of org.kie.workbench.common.command.client.impl.CommandResultImpl 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