Search in sources :

Example 6 with FactModelTree

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

the class BusinessCentralDMODataManagementStrategyTest method aggregatorCallbackMethodWithResultNotAllElements.

@Test
public void aggregatorCallbackMethodWithResultNotAllElements() {
    SortedMap<String, FactModelTree> factTypeFieldsMap = getRandomMap();
    String resultName = "RESULT_NAME";
    FactModelTree resultMock = mock(FactModelTree.class);
    when(resultMock.getFactName()).thenReturn(resultName);
    List<String> simpleJavaTypes = Arrays.asList(getSimpleTypeArray());
    factModelTreeHolderlocal.setFactModelTuple(null);
    businessCentralDmoDataManagementStrategySpy.aggregatorCallbackMethod(testToolsPresenterMock, factTypeFieldsMap.size() + 10, factTypeFieldsMap, scenarioSimulationContextLocal, resultMock, simpleJavaTypes, GridWidget.SIMULATION);
    verify(resultMock, times(1)).getFactName();
    assertTrue(factTypeFieldsMap.containsKey(resultName));
    assertEquals(resultMock, factTypeFieldsMap.get(resultName));
    verify(businessCentralDmoDataManagementStrategySpy, never()).populateFactModelTree(isA(FactModelTree.class), isA(SortedMap.class));
    assertNull(factModelTreeHolderlocal.getFactModelTuple());
    verify(businessCentralDmoDataManagementStrategySpy, never()).storeData(isA(FactModelTuple.class), eq(testToolsPresenterMock), eq(scenarioSimulationContextLocal), eq(GridWidget.SIMULATION));
}
Also used : FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) SortedMap(java.util.SortedMap) Matchers.anyString(org.mockito.Matchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 7 with FactModelTree

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

the class BusinessCentralDMODataManagementStrategyTest method getInstanceMap.

@Test
public void getInstanceMap() {
    FactModelTree toPopulate = getFactModelTreeInner(randomAlphabetic(3));
    final Map<String, FactModelTree.PropertyTypeName> simpleProperties = toPopulate.getSimpleProperties();
    final Collection<FactModelTree.PropertyTypeName> values = simpleProperties.values();
    SortedMap<String, FactModelTree> factTypeFieldsMap = getFactTypeFieldsMapInner(values);
    SortedMap<String, FactModelTree> retrieved = businessCentralDmoDataManagementStrategySpy.getInstanceMap(factTypeFieldsMap);
    assertNotNull(retrieved);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 8 with FactModelTree

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

the class BusinessCentralDMODataManagementStrategyTest method aggregatorCallbackMethodWithResultAllElements.

@Test
public void aggregatorCallbackMethodWithResultAllElements() {
    SortedMap<String, FactModelTree> factTypeFieldsMap = getRandomMap();
    String resultName = "RESULT_NAME";
    FactModelTree resultMock = mock(FactModelTree.class);
    when(resultMock.getFactName()).thenReturn(resultName);
    List<String> simpleJavaTypes = Arrays.asList(getSimpleTypeArray());
    factModelTreeHolderlocal.setFactModelTuple(null);
    businessCentralDmoDataManagementStrategySpy.aggregatorCallbackMethod(testToolsPresenterMock, factTypeFieldsMap.size() + 1, factTypeFieldsMap, scenarioSimulationContextLocal, resultMock, simpleJavaTypes, GridWidget.SIMULATION);
    verify(resultMock, times(1)).getFactName();
    assertTrue(factTypeFieldsMap.containsKey(resultName));
    assertEquals(resultMock, factTypeFieldsMap.get(resultName));
    factTypeFieldsMap.values().forEach(factModelTree -> verify(businessCentralDmoDataManagementStrategySpy, times(1)).populateFactModelTree(eq(factModelTree), eq(factTypeFieldsMap)));
    assertNotNull(factModelTreeHolderlocal.getFactModelTuple());
    verify(businessCentralDmoDataManagementStrategySpy, times(1)).storeData(eq(factModelTreeHolderlocal.getFactModelTuple()), eq(testToolsPresenterMock), eq(scenarioSimulationContextLocal), eq(GridWidget.SIMULATION));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 9 with FactModelTree

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

the class BusinessCentralDMODataManagementStrategyTest method retrieveFactModelTuple.

@Test
public void retrieveFactModelTuple() {
    String factType = "factType";
    Callback<ModelField[]> callbackMock = mock(Callback.class);
    List<String> dataObjectsType = Arrays.asList(factType);
    SortedMap<String, FactModelTree> dataObjectsFieldMap = new TreeMap<>();
    Map<String, String> superTypesMap = Collections.emptyMap();
    List<String> javaSimpleType = new ArrayList<>();
    when(businessCentralDmoDataManagementStrategySpy.fieldCompletionsCallback(eq("factType"), eq(superTypesMap), isA(Callback.class))).thenReturn(callbackMock);
    businessCentralDmoDataManagementStrategySpy.manageDataObjects(dataObjectsType, superTypesMap, testToolsPresenterMock, 1, dataObjectsFieldMap, scenarioSimulationContextLocal, javaSimpleType, gridWidgetMock);
    verify(oracleMock, times(1)).getFieldCompletions(eq(factType), eq(callbackMock));
}
Also used : Callback(org.uberfire.client.callbacks.Callback) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) TreeMap(java.util.TreeMap) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Example 10 with FactModelTree

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

the class DMNSimulationSettingsCreationStrategyTest method addToScenarioMultipleNested.

@Test
public void addToScenarioMultipleNested() {
    FactMapping factMappingMock = mock(FactMapping.class);
    DMNSimulationSettingsCreationStrategy.FactMappingExtractor factMappingExtractorMock = mock(DMNSimulationSettingsCreationStrategy.FactMappingExtractor.class);
    when(factMappingExtractorMock.getFactMapping(any(), anyString(), any(), anyString())).thenReturn(factMappingMock);
    Map<String, FactModelTree> hiddenFacts = new HashMap<>();
    FactModelTree factModelTree = new FactModelTree("myFact", "", new HashMap<>(), Collections.emptyMap());
    factModelTree.addExpandableProperty("nestedProperty", "tNested");
    factModelTree.addExpandableProperty("nestedProperty2", "tNested2");
    FactModelTree nested1 = new FactModelTree("tNested1", "", new HashMap<>(), Collections.emptyMap());
    FactModelTree nested2 = new FactModelTree("tNested2", "", new HashMap<>(), Collections.emptyMap());
    String propertyType = String.class.getCanonicalName();
    String propertyName = "stingProperty";
    nested1.addSimpleProperty(propertyName, new FactModelTree.PropertyTypeName(propertyType));
    String propertyType2 = Boolean.class.getCanonicalName();
    String propertyName2 = "booleanProperty";
    nested2.addSimpleProperty(propertyName2, new FactModelTree.PropertyTypeName(propertyType2));
    hiddenFacts.put("tNested", nested1);
    hiddenFacts.put("tNested2", nested2);
    dmnSimulationCreationStrategy.addFactMapping(factMappingExtractorMock, factModelTree, new ArrayList<>(), hiddenFacts);
    verify(factMappingExtractorMock, times(1)).getFactMapping(eq(nested1), eq(propertyName), eq(Arrays.asList("myFact", "nestedProperty")), eq(propertyType));
    verify(factMappingExtractorMock, times(1)).getFactMapping(eq(nested2), eq(propertyName2), eq(Arrays.asList("myFact", "nestedProperty2")), eq(propertyType2));
    verify(factMappingExtractorMock, times(2)).getFactMapping(any(), any(), any(), any());
}
Also used : FactMapping(org.drools.scenariosimulation.api.model.FactMapping) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) AbstractDMNTest(org.drools.workbench.screens.scenariosimulation.backend.server.AbstractDMNTest) 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