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));
}
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);
}
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));
}
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));
}
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());
}
Aggregations