Search in sources :

Example 16 with FactModelTree

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

the class AbstractTestToolsTest method getSimpleJavaTypeFieldsMap.

protected SortedMap<String, FactModelTree> getSimpleJavaTypeFieldsMap() {
    SortedMap<String, FactModelTree> toReturn = new TreeMap<>();
    for (String key : DataManagementStrategy.SIMPLE_CLASSES_MAP.keySet()) {
        Map<String, FactModelTree.PropertyTypeName> simpleProperties = new HashMap<>();
        FactModelTree.PropertyTypeName fullName = new FactModelTree.PropertyTypeName(DataManagementStrategy.SIMPLE_CLASSES_MAP.get(key).getCanonicalName());
        simpleProperties.put(LOWER_CASE_VALUE, fullName);
        String packageName = fullName.getTypeName().substring(0, fullName.getTypeName().lastIndexOf("."));
        FactModelTree value = new FactModelTree(key, packageName, simpleProperties, new HashMap<>());
        toReturn.put(key, value);
    }
    return toReturn;
}
Also used : HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)

Example 17 with FactModelTree

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

the class AbstractDMNDataManagementStrategyTest method isADataType.

@Test
public void isADataType() {
    visibleFactsLocal.clear();
    hiddenFactsLocal.clear();
    commonIsADataType("TEST", false);
    visibleFactsLocal.put("TEST", new FactModelTree());
    commonIsADataType("TOAST", false);
    commonIsADataType("TEST", true);
    visibleFactsLocal.clear();
    hiddenFactsLocal.put("TEST", new FactModelTree());
    commonIsADataType("TOAST", false);
    commonIsADataType("TEST", true);
}
Also used : FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 18 with FactModelTree

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

the class AbstractDataManagementStrategyTest method getSimpleClassFactModelTree.

@Test
public void getSimpleClassFactModelTree() {
    Class[] expectedClazzes = { String.class, Boolean.class, Integer.class, Double.class, Number.class };
    for (Class expectedClazz : expectedClazzes) {
        final FactModelTree retrieved = AbstractDataManagementStrategy.getSimpleClassFactModelTree(expectedClazz.getSimpleName(), expectedClazz.getCanonicalName());
        assertNotNull(retrieved);
        String key = expectedClazz.getSimpleName();
        assertEquals(key, retrieved.getFactName());
        String fullName = expectedClazz.getCanonicalName();
        String packageName = fullName.substring(0, fullName.lastIndexOf("."));
        assertEquals(packageName, retrieved.getFullPackage());
        Map<String, FactModelTree.PropertyTypeName> simpleProperties = retrieved.getSimpleProperties();
        assertNotNull(simpleProperties);
        assertEquals(1, simpleProperties.size());
        assertTrue(simpleProperties.containsKey(TestProperties.LOWER_CASE_VALUE));
        FactModelTree.PropertyTypeName simplePropertyValue = simpleProperties.get(TestProperties.LOWER_CASE_VALUE);
        assertNotNull(simplePropertyValue);
        assertEquals(fullName, simplePropertyValue.getTypeName());
        assertEquals(fullName, simplePropertyValue.getPropertyTypeNameToVisualize());
        assertFalse(simplePropertyValue.getBaseTypeName().isPresent());
    }
}
Also used : FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 19 with FactModelTree

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

the class AbstractDataManagementStrategyTest method getSourceMap.

private SortedMap<String, FactModelTree> getSourceMap() {
    SortedMap<String, FactModelTree> toReturn = new TreeMap<>();
    FactModelTree toPut = new FactModelTree("Void", "package", new HashMap<>(), new HashMap<>());
    toReturn.put("Void", toPut);
    return toReturn;
}
Also used : TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)

Example 20 with FactModelTree

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

the class TestToolsPresenter method onModifyColumn.

@Override
public void onModifyColumn() {
    if (editingColumnEnabled) {
        if (selectedListGroupItemView != null) {
            String className = selectedListGroupItemView.getActualClassName();
            getFactModelTreeFromMaps(className).ifPresent(factModelTree -> eventBus.fireEvent(new SetPropertyHeaderEvent(gridWidget, factModelTree.getFullPackage(), factModelTree.getTypeName(), Collections.unmodifiableList(Arrays.asList(className)), factModelTree.getFullTypeName(), FactMappingValueType.EXPRESSION, factModelTree.getImportPrefix())));
        } else if (selectedFieldItemView != null) {
            String baseClass = selectedFieldItemView.getFullPath().get(0);
            List<String> propertyNameElements = new ArrayList<>(selectedFieldItemView.getFullPath());
            if (!isSimple(baseClass)) {
                propertyNameElements.add(selectedFieldItemView.getFieldName());
            }
            getFactModelTreeFromMaps(baseClass).ifPresent(factModelTree -> eventBus.fireEvent(new SetPropertyHeaderEvent(gridWidget, factModelTree.getFullPackage(), factModelTree.getTypeName(), Collections.unmodifiableList(propertyNameElements), selectedFieldItemView.getClassName(), FactMappingValueType.NOT_EXPRESSION, factModelTree.getImportPrefix())));
        }
    }
}
Also used : IDENTIFIER(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenter.IDENTIFIER) Arrays(java.util.Arrays) EventBus(com.google.gwt.event.shared.EventBus) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) FactMappingValueType(org.drools.scenariosimulation.api.model.FactMappingValueType) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) List(java.util.List) TreeMap(java.util.TreeMap) SetPropertyHeaderEvent(org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent) Map(java.util.Map) Optional(java.util.Optional) ScenarioSimulationEditorConstants(org.drools.workbench.screens.scenariosimulation.client.resources.i18n.ScenarioSimulationEditorConstants) ApplicationScoped(javax.enterprise.context.ApplicationScoped) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) Collections(java.util.Collections) SortedMap(java.util.SortedMap) DEFAULT_PREFERRED_WIDHT(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenter.DEFAULT_PREFERRED_WIDHT) SetPropertyHeaderEvent(org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FactModelTree (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)47 Test (org.junit.Test)19 TreeMap (java.util.TreeMap)16 Matchers.anyString (org.mockito.Matchers.anyString)14 HashMap (java.util.HashMap)10 DMNType (org.kie.dmn.api.core.DMNType)10 ArrayList (java.util.ArrayList)9 AbstractScenarioSimulationEditorTest (org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest)8 FactModelTuple (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple)7 List (java.util.List)6 Map (java.util.Map)6 SortedMap (java.util.SortedMap)6 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)6 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)4 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)3 AbstractScesimModel (org.drools.scenariosimulation.api.model.AbstractScesimModel)3 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)3