Search in sources :

Example 1 with FactModelTuple

use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple in project drools-wb by kiegroup.

the class AbstractDMODataManagementStrategyTest method setup.

@Before
public void setup() {
    super.setup();
    factTypes = new ArrayList<>();
    visibleFactsLocal = new TreeMap<>();
    hiddenFactsLocal = new TreeMap<>();
    factModelTupleLocal = new FactModelTuple(visibleFactsLocal, hiddenFactsLocal);
    factModelTreeHolderlocal = new AbstractDataManagementStrategy.ResultHolder();
    factModelTreeHolderlocal.setFactModelTuple(factModelTupleLocal);
    abstractDMODataManagementStrategySpy = spy(new AbstractDMODataManagementStrategy() {

        @Override
        public void manageScenarioSimulationModelContent(ObservablePath currentPath, ScenarioSimulationModelContent toManage) {
        }

        @Override
        public boolean isADataType(String value) {
            return false;
        }

        @Override
        protected String getFQCNByFactName(String factName) {
            return FULL_CLASS_NAME;
        }

        @Override
        protected String getParametricFieldType(String factName, String propertyName) {
            return PARAMETRIC_FIELD_TYPE;
        }

        @Override
        protected List<String> getFactTypes() {
            return factTypes;
        }

        @Override
        protected void getSuperType(String factType, Callback<String> callback) {
        // Do Nothing
        }

        @Override
        protected boolean skipPopulateTestTools() {
            return false;
        }

        @Override
        protected void manageDataObjects(List<String> dataObjectsTypes, Map<String, String> superTypeMap, TestToolsView.Presenter testToolsPresenter, int expectedElements, SortedMap<String, FactModelTree> dataObjectsFieldsMap, ScenarioSimulationContext context, List<String> simpleJavaTypes, GridWidget gridWidget) {
        }

        {
            this.model = modelLocal;
            this.factModelTreeHolder = factModelTreeHolderlocal;
        }
    });
}
Also used : ScenarioSimulationContext(org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext) GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) Callback(org.uberfire.client.callbacks.Callback) SortedMap(java.util.SortedMap) ArrayList(java.util.ArrayList) List(java.util.List) ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Before(org.junit.Before)

Example 2 with FactModelTuple

use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple in project drools-wb by kiegroup.

the class BusinessCentralDMODataManagementStrategyTest method populateTestToolsWithFactTuple.

@Test
public void populateTestToolsWithFactTuple() {
    final FactModelTuple factModelTupleMock = mock(FactModelTuple.class);
    factModelTreeHolderlocal.setFactModelTuple(factModelTupleMock);
    doNothing().when(businessCentralDmoDataManagementStrategySpy).storeData(eq(factModelTupleMock), eq(testToolsPresenterMock), eq(scenarioSimulationContextLocal), eq(GridWidget.SIMULATION));
    businessCentralDmoDataManagementStrategySpy.populateTestTools(testToolsPresenterMock, scenarioSimulationContextLocal, GridWidget.SIMULATION);
    verify(businessCentralDmoDataManagementStrategySpy, times(1)).storeData(eq(factModelTupleMock), eq(testToolsPresenterMock), eq(scenarioSimulationContextLocal), eq(GridWidget.SIMULATION));
}
Also used : FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 3 with FactModelTuple

use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple in project drools-wb by kiegroup.

the class BusinessCentralDMODataManagementStrategyTest method setup.

@Before
public void setup() {
    super.setup();
    factModelTupleLocal = new FactModelTuple(new TreeMap<>(), new TreeMap<>());
    factModelTreeHolderlocal = new BusinessCentralDMODataManagementStrategy.ResultHolder();
    factModelTreeHolderlocal.setFactModelTuple(factModelTupleLocal);
    when(oracleMock.getFQCNByFactName(TestProperties.FACT_NAME)).thenReturn(TestProperties.FULL_CLASS_NAME);
    when(oracleFactoryMock.makeAsyncPackageDataModelOracle(observablePathMock, modelLocal, content.getDataModel())).thenReturn(oracleMock);
    this.businessCentralDmoDataManagementStrategySpy = spy(new BusinessCentralDMODataManagementStrategy(oracleFactoryMock) {

        {
            this.oracle = oracleMock;
            this.factModelTreeHolder = factModelTreeHolderlocal;
        }
    });
}
Also used : FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) TreeMap(java.util.TreeMap) Before(org.junit.Before)

Example 4 with FactModelTuple

use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple in project drools-wb by kiegroup.

the class DMNSimulationSettingsCreationStrategyTest method createBackground.

@Test
public void createBackground() throws Exception {
    FactModelTuple factModelTuple = getFactModelTuple();
    final Path pathMock = mock(Path.class);
    final String dmnFilePath = "test";
    final Background retrieved = dmnSimulationCreationStrategy.createBackground(pathMock, dmnFilePath);
    assertNotNull(retrieved);
    verify(dmnTypeServiceMock, never()).initializeNameAndNamespace(any(Settings.class), eq(pathMock), eq(dmnFilePath));
    assertFalse(retrieved.getScesimModelDescriptor().getUnmodifiableFactMappings().stream().anyMatch(elem -> OTHER.equals(elem.getExpressionIdentifier().getType())));
    assertTrue(retrieved.getScesimModelDescriptor().getUnmodifiableFactMappings().stream().allMatch(elem -> GIVEN.equals(elem.getExpressionIdentifier().getType())));
}
Also used : Path(org.uberfire.backend.vfs.Path) Arrays(java.util.Arrays) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) GIVEN(org.drools.scenariosimulation.api.model.FactMappingType.GIVEN) VALUE(org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE) DMNTypeService(org.drools.workbench.screens.scenariosimulation.service.DMNTypeService) Matchers.eq(org.mockito.Matchers.eq) Map(java.util.Map) ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) Mockito.doReturn(org.mockito.Mockito.doReturn) AbstractDMNTest(org.drools.workbench.screens.scenariosimulation.backend.server.AbstractDMNTest) Settings(org.drools.scenariosimulation.api.model.Settings) Matchers.any(org.mockito.Matchers.any) List(java.util.List) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) Assert.assertFalse(org.junit.Assert.assertFalse) Simulation(org.drools.scenariosimulation.api.model.Simulation) InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) EXPECT(org.drools.scenariosimulation.api.model.FactMappingType.EXPECT) SortedMap(java.util.SortedMap) Mockito.mock(org.mockito.Mockito.mock) DMNType(org.kie.dmn.api.core.DMNType) Mock(org.mockito.Mock) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) RunWith(org.junit.runner.RunWith) FactIdentifier(org.drools.scenariosimulation.api.model.FactIdentifier) HashMap(java.util.HashMap) Mockito.spy(org.mockito.Mockito.spy) Matchers.anyString(org.mockito.Matchers.anyString) ArrayList(java.util.ArrayList) ExpressionIdentifier(org.drools.scenariosimulation.api.model.ExpressionIdentifier) DecisionNode(org.kie.dmn.api.core.ast.DecisionNode) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) DECISION(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree.Type.DECISION) Path(org.uberfire.backend.vfs.Path) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex) Before(org.junit.Before) OTHER(org.drools.scenariosimulation.api.model.FactMappingType.OTHER) Assert.assertNotNull(org.junit.Assert.assertNotNull) Background(org.drools.scenariosimulation.api.model.Background) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) TreeMap(java.util.TreeMap) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Background(org.drools.scenariosimulation.api.model.Background) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) Matchers.anyString(org.mockito.Matchers.anyString) Settings(org.drools.scenariosimulation.api.model.Settings) AbstractDMNTest(org.drools.workbench.screens.scenariosimulation.backend.server.AbstractDMNTest) Test(org.junit.Test)

Example 5 with FactModelTuple

use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple in project drools-wb by kiegroup.

the class DMNSimulationSettingsCreationStrategyTest method getFactModelTuple.

private FactModelTuple getFactModelTuple(boolean hasInput, boolean hasOutput) throws IOException {
    SortedMap<String, FactModelTree> visibleFacts = new TreeMap<>();
    SortedMap<String, FactModelTree> hiddenFacts = new TreeMap<>();
    if (hasInput) {
        for (InputDataNode input : dmnModelLocal.getInputs()) {
            DMNType type = input.getType();
            visibleFacts.put(input.getName(), createFactModelTree(input.getName(), input.getName(), type, hiddenFacts, FactModelTree.Type.INPUT));
        }
    }
    if (hasOutput) {
        for (DecisionNode decision : dmnModelLocal.getDecisions()) {
            DMNType type = decision.getResultType();
            visibleFacts.put(decision.getName(), createFactModelTree(decision.getName(), decision.getName(), type, hiddenFacts, DECISION));
        }
    }
    return new FactModelTuple(visibleFacts, hiddenFacts);
}
Also used : FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) Matchers.anyString(org.mockito.Matchers.anyString) InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) DecisionNode(org.kie.dmn.api.core.ast.DecisionNode) TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) DMNType(org.kie.dmn.api.core.DMNType)

Aggregations

FactModelTuple (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple)17 Test (org.junit.Test)9 TreeMap (java.util.TreeMap)8 FactModelTree (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)7 SortedMap (java.util.SortedMap)6 Path (org.uberfire.backend.vfs.Path)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)5 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)5 HashMap (java.util.HashMap)4 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)4 ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)4 Settings (org.drools.scenariosimulation.api.model.Settings)4 Simulation (org.drools.scenariosimulation.api.model.Simulation)4 VALUE (org.drools.scenariosimulation.api.utils.ConstantsHolder.VALUE)4 Before (org.junit.Before)4 DMNType (org.kie.dmn.api.core.DMNType)4 DecisionNode (org.kie.dmn.api.core.ast.DecisionNode)4 InputDataNode (org.kie.dmn.api.core.ast.InputDataNode)4