Search in sources :

Example 1 with Settings

use of org.drools.scenariosimulation.api.model.Settings in project drools by kiegroup.

the class AbstractScenarioRunnerTest method setup.

@Before
public void setup() {
    settingsLocal = new Settings();
    scenarioRunnerDTOLocal = getScenarioRunnerDTO();
    abstractScenarioRunnerLocal = spy(new AbstractScenarioRunner(kieContainerMock, scenarioRunnerDTOLocal, ExpressionEvaluatorFactory.create(this.getClass().getClassLoader(), ScenarioSimulationModel.Type.RULE)) {

        @Override
        protected AbstractRunnerHelper newRunnerHelper() {
            return null;
        }
    });
}
Also used : Settings(org.drools.scenariosimulation.api.model.Settings) Before(org.junit.Before)

Example 2 with Settings

use of org.drools.scenariosimulation.api.model.Settings in project drools by kiegroup.

the class ScenarioJunitActivatorTest method setup.

@Before
public void setup() throws Exception {
    simulationLocal = new Simulation();
    settingsLocal = new Settings();
    settingsLocal.setSkipFromBuild(true);
    when(xmlReaderMock.unmarshal(any())).thenReturn(scenarioSimulationModelMock);
    when(scenarioSimulationModelMock.getSimulation()).thenReturn(simulationLocal);
    when(scenarioSimulationModelMock.getSettings()).thenReturn(settingsLocal);
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) Settings(org.drools.scenariosimulation.api.model.Settings) Before(org.junit.Before)

Example 3 with Settings

use of org.drools.scenariosimulation.api.model.Settings in project drools by kiegroup.

the class RuleScenarioRunnerHelperTest method setup.

@Before
public void setup() {
    when(kieContainerMock.getClassLoader()).thenReturn(classLoader);
    simulation = new Simulation();
    background = new Background();
    settings = new Settings();
    settings.setType(ScenarioSimulationModel.Type.RULE);
    personFactIdentifier = FactIdentifier.create("Fact 1", Person.class.getCanonicalName());
    firstNameGivenExpressionIdentifier = ExpressionIdentifier.create("First Name Given", FactMappingType.GIVEN);
    firstNameGivenFactMapping = simulation.getScesimModelDescriptor().addFactMapping(personFactIdentifier, firstNameGivenExpressionIdentifier);
    firstNameGivenFactMapping.addExpressionElement("Fact 1", String.class.getCanonicalName());
    firstNameGivenFactMapping.addExpressionElement("firstName", String.class.getCanonicalName());
    disputeFactIdentifier = FactIdentifier.create("Fact 2", Dispute.class.getCanonicalName());
    amountGivenExpressionIdentifier = ExpressionIdentifier.create("Amount Given", FactMappingType.GIVEN);
    amountNameGivenFactMapping = simulation.getScesimModelDescriptor().addFactMapping(disputeFactIdentifier, amountGivenExpressionIdentifier);
    amountNameGivenFactMapping.addExpressionElement("Fact 2", Double.class.getCanonicalName());
    amountNameGivenFactMapping.addExpressionElement("amount", Double.class.getCanonicalName());
    firstNameExpectedExpressionIdentifier = ExpressionIdentifier.create("First Name Expected", FactMappingType.EXPECT);
    firstNameExpectedFactMapping = simulation.getScesimModelDescriptor().addFactMapping(personFactIdentifier, firstNameExpectedExpressionIdentifier);
    firstNameExpectedFactMapping.addExpressionElement("Fact 1", String.class.getCanonicalName());
    firstNameExpectedFactMapping.addExpressionElement("firstName", String.class.getCanonicalName());
    amountExpectedExpressionIdentifier = ExpressionIdentifier.create("Amount Expected", FactMappingType.EXPECT);
    amountNameExpectedFactMapping = simulation.getScesimModelDescriptor().addFactMapping(disputeFactIdentifier, amountExpectedExpressionIdentifier);
    amountNameExpectedFactMapping.addExpressionElement("Fact 2", Double.class.getCanonicalName());
    amountNameExpectedFactMapping.addExpressionElement("amount", Double.class.getCanonicalName());
    expressionGivenExpressionIdentifier = ExpressionIdentifier.create("directMapping", FactMappingType.GIVEN);
    disputeExpressionGivenFactMapping = simulation.getScesimModelDescriptor().addFactMapping(disputeFactIdentifier, expressionGivenExpressionIdentifier);
    disputeExpressionGivenFactMapping.setFactMappingValueType(FactMappingValueType.EXPRESSION);
    disputeExpressionGivenFactMapping.addExpressionElement("Dispute", Dispute.class.getCanonicalName());
    scenario1 = simulation.addData();
    scenario1.setDescription(TEST_DESCRIPTION);
    scenario1.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, NAME);
    scenario1.addMappingValue(personFactIdentifier, firstNameExpectedExpressionIdentifier, NAME);
    scenario2 = simulation.addData();
    scenario2.setDescription(TEST_DESCRIPTION);
    scenario2.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, NAME);
    scenario2.addMappingValue(personFactIdentifier, firstNameExpectedExpressionIdentifier, NAME);
    scenario2.addMappingValue(disputeFactIdentifier, amountGivenExpressionIdentifier, AMOUNT);
    amountNameExpectedFactMappingValue = scenario2.addMappingValue(disputeFactIdentifier, amountExpectedExpressionIdentifier, AMOUNT);
    backgroundFirstNameGivenFactMapping = background.getScesimModelDescriptor().addFactMapping(personFactIdentifier, firstNameGivenExpressionIdentifier);
    backgroundFirstNameGivenFactMapping.addExpressionElement("Person", String.class.getCanonicalName());
    backgroundFirstNameGivenFactMapping.addExpressionElement("firstName", String.class.getCanonicalName());
    backgroundAmountNameGivenFactMapping = background.getScesimModelDescriptor().addFactMapping(disputeFactIdentifier, amountGivenExpressionIdentifier);
    backgroundAmountNameGivenFactMapping.addExpressionElement("Dispute", Double.class.getCanonicalName());
    backgroundAmountNameGivenFactMapping.addExpressionElement("amount", Double.class.getCanonicalName());
    backgroundData1 = background.addData();
    backgroundData1.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, NAME);
    backgroundData1.addMappingValue(disputeFactIdentifier, amountGivenExpressionIdentifier, AMOUNT);
    backgroundData2 = background.addData();
    backgroundData2.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, NAME);
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) Background(org.drools.scenariosimulation.api.model.Background) Dispute(org.drools.scenariosimulation.backend.model.Dispute) Settings(org.drools.scenariosimulation.api.model.Settings) Before(org.junit.Before)

Example 4 with Settings

use of org.drools.scenariosimulation.api.model.Settings in project drools-wb by kiegroup.

the class SettingsPresenterTest method setup.

@Before
public void setup() {
    super.setup();
    Settings settings = new Settings();
    settings.setRuleFlowGroup(RULE_FLOW_GROUP);
    settings.setDmoSession(DMO_SESSION);
    settings.setDmnFilePath(DMN_FILE_PATH);
    settings.setDmnNamespace(DMN_NAMESPACE);
    settings.setDmnName(DMN_NAME);
    settings.setStateless(STATELESS);
    settings.setSkipFromBuild(SKIP_FROM_BUILD);
    // spy after initialization to avoid double counting
    settingsSpy = spy(settings);
    KieAssetsDropdownItem item = new KieAssetsDropdownItem("DMNFile", "", DMN_FILE_PATH, null);
    when(settingsScenarioSimulationDropdownMock.getValue()).thenReturn(Optional.of(item));
    this.settingsPresenterSpy = spy(new SettingsPresenter(settingsScenarioSimulationDropdownMock, settingsViewMock) {

        {
            this.settingsScenarioSimulationDropdown = settingsScenarioSimulationDropdownMock;
            this.saveCommand = saveCommandMock;
            this.eventBus = eventBusMock;
        }
    });
}
Also used : Settings(org.drools.scenariosimulation.api.model.Settings) KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem) Before(org.junit.Before)

Example 5 with Settings

use of org.drools.scenariosimulation.api.model.Settings in project drools-wb by kiegroup.

the class ScenarioSimulationEventHandlerTest method onUpdateSettingDataEventChangedValue.

@Test
public void onUpdateSettingDataEventChangedValue() {
    Predicate<Settings> predicateMock = mock(Predicate.class);
    when(predicateMock.test(eq(settingsLocal))).thenReturn(true);
    Consumer<Settings> consumerMock = mock(Consumer.class);
    UpdateSettingsDataEvent event = new UpdateSettingsDataEvent(consumerMock, predicateMock);
    scenarioSimulationEventHandler.onEvent(event);
    verify(predicateMock, times(1)).test(eq(settingsLocal));
    verify(scenarioSimulationEventHandler, times(1)).commonExecution(isA(UpdateSettingsDataCommand.class), eq(false));
    verify(scenarioSimulationEditorPresenterMock, times(1)).unpublishTestResultsAlerts();
}
Also used : UpdateSettingsDataCommand(org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.UpdateSettingsDataCommand) UpdateSettingsDataEvent(org.drools.workbench.screens.scenariosimulation.client.events.UpdateSettingsDataEvent) Settings(org.drools.scenariosimulation.api.model.Settings) Test(org.junit.Test) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)

Aggregations

Settings (org.drools.scenariosimulation.api.model.Settings)29 Test (org.junit.Test)11 Before (org.junit.Before)10 Simulation (org.drools.scenariosimulation.api.model.Simulation)9 Background (org.drools.scenariosimulation.api.model.Background)7 Path (org.uberfire.backend.vfs.Path)6 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)4 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)2 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)2 Scenario (org.drools.scenariosimulation.api.model.Scenario)2 ScenarioWithIndex (org.drools.scenariosimulation.api.model.ScenarioWithIndex)2 ScenarioRunnerData (org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerData)2 ScenarioSimulationViolation (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationViolation)2 UpdateSettingsDataCommand (org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.UpdateSettingsDataCommand)2 UpdateSettingsDataEvent (org.drools.workbench.screens.scenariosimulation.client.events.UpdateSettingsDataEvent)2 TestResultMessage (org.guvnor.common.services.shared.test.TestResultMessage)2