Search in sources :

Example 1 with FactModelTree

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

the class AbstractDMODataManagementStrategyTest method getFactModelTree.

@Test
public void getFactModelTree() {
    Map<String, FactModelTree.PropertyTypeName> simpleProperties = getSimplePropertiesInner();
    final ModelField[] modelFields = getModelFieldsInner(simpleProperties);
    final FactModelTree retrieved = abstractDMODataManagementStrategySpy.getFactModelTree(FACT_NAME, Collections.emptyMap(), modelFields);
    assertNotNull(retrieved);
    assertEquals(FACT_NAME, retrieved.getFactName());
    assertEquals(FULL_PACKAGE, retrieved.getFullPackage());
    assertFalse(retrieved.getSimpleProperties().isEmpty());
    retrieved.getSimpleProperties().entrySet().forEach(entry -> {
        assertFalse(entry.getValue().getBaseTypeName().isPresent());
        assertEquals(entry.getValue().getTypeName(), entry.getValue().getPropertyTypeNameToVisualize());
    });
}
Also used : ModelField(org.kie.soup.project.datamodel.oracle.ModelField) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 2 with FactModelTree

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

the class TestToolsPresenterTest method setup.

@Before
public void setup() {
    super.setup();
    final String firstKey = dataObjectFactTreeMap.firstKey();
    final FactModelTree factModelTree = dataObjectFactTreeMap.get(firstKey);
    final String firstPropertyKey = (String) new ArrayList(factModelTree.getSimpleProperties().keySet()).get(0);
    final FactModelTree.PropertyTypeName firstPropertyClass = factModelTree.getSimpleProperties().get(firstPropertyKey);
    when(selectedListGroupItemViewMock.getActualClassName()).thenReturn(firstKey);
    when(selectedFieldItemViewMock.getFullPath()).thenReturn(Arrays.asList(firstKey));
    when(selectedFieldItemViewMock.getFieldName()).thenReturn(firstPropertyKey);
    when(selectedFieldItemViewMock.getClassName()).thenReturn(firstPropertyClass.getTypeName());
    when(listGroupItemPresenterMock.getDivElement(FACT_NAME, FACT_MODEL_TREE)).thenReturn(divItemContainerMock);
    this.testToolsPresenterSpy = spy(new TestToolsPresenter(testToolsViewMock, listGroupItemPresenterMock) {

        {
            this.dataObjectFieldsMap = dataObjectFactTreeMap;
            this.simpleJavaTypeFieldsMap = simpleJavaTypeTreeMap;
            this.instanceFieldsMap = instanceFactTreeMap;
            this.simpleJavaInstanceFieldsMap = simpleJavaInstanceFactTreeMap;
            this.eventBus = eventBusMock;
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) Before(org.junit.Before)

Example 3 with FactModelTree

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

the class TestToolsPresenterTest method updateInstanceIsAssignedStatus_Present.

@Test
public void updateInstanceIsAssignedStatus_Present() {
    String instance = "CHECK_INSTANCE";
    FactModelTree factModel = new FactModelTree(instance, FACT_PACKAGE, getMockSimpleProperties(), new HashMap<>());
    dataObjectFactTreeMap.put(instance, factModel);
    testToolsPresenterSpy.updateInstanceIsAssignedStatus(instance);
    verify(listGroupItemPresenterMock, times(1)).setInstanceAssigned(eq(instance), eq(true));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) Test(org.junit.Test)

Example 4 with FactModelTree

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

the class AbstractSelectedColumnCommandTest method navigateComplexObject3Levels.

protected void navigateComplexObject3Levels() {
    FactModelTree book = new FactModelTree("Book", "com.Book", new HashMap<>(), new HashMap<>());
    book.addExpandableProperty("author", "Author");
    FactModelTree author = new FactModelTree("Author", "com.Author", new HashMap<>(), new HashMap<>());
    author.addExpandableProperty("firstBook", "Book");
    SortedMap<String, FactModelTree> sortedMap = spy(new TreeMap<>());
    sortedMap.put("Book", book);
    sortedMap.put("Author", author);
    List<String> elements = Arrays.asList("Book", "author", "firstBook", "topics");
    FactModelTree target = ((AbstractSelectedColumnCommand) commandSpy).navigateComplexObject(book, elements, sortedMap);
    assertEquals(target, book);
    verify(sortedMap, times(1)).get("Author");
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)

Example 5 with FactModelTree

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

the class AbstractSelectedColumnCommandTest method navigateComplexObject.

/* This test is usable ONLY by <code>SetPropertyCommandTest</code> subclass */
protected void navigateComplexObject() {
    FactModelTree book = new FactModelTree("Book", "com.Book", new HashMap<>(), new HashMap<>());
    book.addExpandableProperty("author", "Author");
    FactModelTree author = new FactModelTree("Author", "com.Author", new HashMap<>(), new HashMap<>());
    SortedMap<String, FactModelTree> sortedMap = spy(new TreeMap<>());
    sortedMap.put("Book", book);
    sortedMap.put("Author", author);
    List<String> elements = Arrays.asList("Book", "author", "currentlyPrinted");
    FactModelTree target = ((AbstractSelectedColumnCommand) commandSpy).navigateComplexObject(book, elements, sortedMap);
    assertEquals(target, author);
    verify(sortedMap, times(1)).get("Author");
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)

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