Search in sources :

Example 21 with FactModelTree

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

the class ListGroupItemPresenter method onToggleRowExpansion.

@Override
public void onToggleRowExpansion(ListGroupItemView listGroupItemView, boolean currentlyShown) {
    if (disabled.get()) {
        return;
    }
    if (currentlyShown) {
        listGroupItemView.closeRow();
    } else {
        if (listGroupItemView.isToExpand()) {
            FactModelTree factModelTree = testToolsPresenter.getFactModelTreeFromFactTypeMap(listGroupItemView.getFactType()).orElseGet(() -> testToolsPresenter.getFactModelTreeFromHiddenMap(listGroupItemView.getFactType()));
            if (factModelTree != null) {
                populateListGroupItemView(listGroupItemView, listGroupItemView.getParentPath(), listGroupItemView.getFactName(), factModelTree);
                listGroupItemView.setToExpand(false);
            }
        }
        listGroupItemView.expandRow();
    }
}
Also used : FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)

Example 22 with FactModelTree

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

the class DMNTypeServiceImplTest method createTopLevelFactModelTreeSimpleCollection.

@Test
public void createTopLevelFactModelTreeSimpleCollection() throws WrongDMNTypeException {
    // Single property collection retrieve
    DMNType simpleCollectionString = getSimpleCollection();
    TreeMap<String, FactModelTree> hiddenFactSimpleCollection = new TreeMap<>();
    FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", IMPORTED_PREFIX, simpleCollectionString, hiddenFactSimpleCollection, FactModelTree.Type.INPUT);
    assertNotNull(retrieved);
    assertEquals("testPath", retrieved.getFactName());
    assertEquals(1, retrieved.getSimpleProperties().size());
    assertTrue(retrieved.getSimpleProperties().containsKey(VALUE));
    assertEquals("java.util.List", retrieved.getSimpleProperties().get(VALUE).getTypeName());
    assertFalse(retrieved.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent());
    assertEquals("java.util.List", retrieved.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize());
    assertTrue(retrieved.getExpandableProperties().isEmpty());
    assertEquals(1, retrieved.getGenericTypesMap().size());
    assertTrue(retrieved.getGenericTypesMap().containsKey(VALUE));
    assertNotNull(retrieved.getGenericTypesMap().get(VALUE));
    assertEquals(1, retrieved.getGenericTypesMap().get(VALUE).size());
    assertEquals(simpleCollectionString.getName(), retrieved.getGenericTypesMap().get(VALUE).get(0));
    assertEquals(IMPORTED_PREFIX, retrieved.getImportPrefix());
}
Also used : TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) DMNType(org.kie.dmn.api.core.DMNType) Test(org.junit.Test)

Example 23 with FactModelTree

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

the class DMNTypeServiceImplTest method createTopLevelFactModelTreeSimpleNoCollection.

@Test
public void createTopLevelFactModelTreeSimpleNoCollection() throws WrongDMNTypeException {
    // Single property retrieve
    DMNType simpleString = getSimpleNoCollection();
    FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", IMPORTED_PREFIX, simpleString, new TreeMap<>(), FactModelTree.Type.INPUT);
    assertNotNull(retrieved);
    assertEquals("testPath", retrieved.getFactName());
    assertEquals(1, retrieved.getSimpleProperties().size());
    assertTrue(retrieved.getSimpleProperties().containsKey(VALUE));
    assertEquals(simpleString.getName(), retrieved.getSimpleProperties().get(VALUE).getTypeName());
    assertFalse(retrieved.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent());
    assertEquals(simpleString.getName(), retrieved.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize());
    assertTrue(retrieved.getExpandableProperties().isEmpty());
    assertTrue(retrieved.getGenericTypesMap().isEmpty());
    assertEquals(IMPORTED_PREFIX, retrieved.getImportPrefix());
}
Also used : FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) DMNType(org.kie.dmn.api.core.DMNType) Test(org.junit.Test)

Example 24 with FactModelTree

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

the class DMNTypeServiceImplTest method createTopLevelFactModelTreeRecursiveTypes.

@Test
public void createTopLevelFactModelTreeRecursiveTypes() throws WrongDMNTypeException {
    SortedMap<String, FactModelTree> hiddenFacts = new TreeMap<>();
    FactModelTree person = dmnTypeServiceImpl.createTopLevelFactModelTree("person", IMPORTED_PREFIX, getRecursivePersonComposite(false), hiddenFacts, FactModelTree.Type.DECISION);
    assertNotNull(person);
    assertTrue(person.getExpandableProperties().containsKey("parent"));
    assertEquals("tPerson", person.getExpandableProperties().get("parent"));
    assertTrue(hiddenFacts.containsKey("tPerson"));
    assertEquals(IMPORTED_PREFIX, person.getImportPrefix());
    hiddenFacts = new TreeMap<>();
    FactModelTree personCollection = dmnTypeServiceImpl.createTopLevelFactModelTree("person", IMPORTED_PREFIX, getRecursivePersonComposite(true), hiddenFacts, FactModelTree.Type.DECISION);
    assertNotNull(personCollection);
    assertTrue(personCollection.getGenericTypesMap().containsKey(VALUE));
    assertEquals("tPerson", personCollection.getGenericTypeInfo(VALUE).get(0));
    assertTrue(hiddenFacts.containsKey("tPerson"));
    assertTrue(hiddenFacts.containsKey("tPersonList"));
    assertEquals(IMPORTED_PREFIX, personCollection.getImportPrefix());
}
Also used : TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) Test(org.junit.Test)

Example 25 with FactModelTree

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

the class DMNTypeServiceImplTest method createTopLevelFactModelTreeCompositeNoCollection.

@Test
public void createTopLevelFactModelTreeCompositeNoCollection() throws WrongDMNTypeException {
    // Single property retrieve
    DMNType compositePerson = getSingleCompositeWithSimpleCollection();
    FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", IMPORTED_PREFIX, compositePerson, new TreeMap<>(), FactModelTree.Type.INPUT);
    assertNotNull(retrieved);
    assertEquals("testPath", retrieved.getFactName());
    assertEquals(2, retrieved.getSimpleProperties().size());
    assertTrue(retrieved.getSimpleProperties().containsKey("friends"));
    assertEquals("java.util.List", retrieved.getSimpleProperties().get("friends").getTypeName());
    assertFalse(retrieved.getSimpleProperties().get("friends").getBaseTypeName().isPresent());
    assertEquals("java.util.List", retrieved.getSimpleProperties().get("friends").getPropertyTypeNameToVisualize());
    assertTrue(retrieved.getSimpleProperties().containsKey("name"));
    assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("name").getTypeName());
    assertFalse(retrieved.getSimpleProperties().get("name").getBaseTypeName().isPresent());
    assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("name").getPropertyTypeNameToVisualize());
    // 
    assertEquals(1, retrieved.getGenericTypesMap().size());
    assertTrue(retrieved.getGenericTypesMap().containsKey("friends"));
    assertEquals(compositePerson.getFields().get("friends").getName(), retrieved.getGenericTypesMap().get("friends").get(0));
    // 
    assertEquals(2, retrieved.getExpandableProperties().size());
    assertTrue(retrieved.getExpandableProperties().containsKey(EXPANDABLE_PROPERTY_PHONENUMBERS));
    assertEquals("tPhoneNumber", retrieved.getExpandableProperties().get(EXPANDABLE_PROPERTY_PHONENUMBERS));
    assertTrue(retrieved.getExpandableProperties().containsKey(EXPANDABLE_PROPERTY_DETAILS));
    assertEquals("tDetails", retrieved.getExpandableProperties().get(EXPANDABLE_PROPERTY_DETAILS));
    assertEquals(IMPORTED_PREFIX, retrieved.getImportPrefix());
}
Also used : FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) DMNType(org.kie.dmn.api.core.DMNType) Test(org.junit.Test)

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