use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class DMNSimulationSettingsCreationStrategyTest method getFactModelTuple.
private FactModelTuple getFactModelTuple(boolean hasInput, boolean hasOutput) throws IOException {
SortedMap<String, FactModelTree> visibleFacts = new TreeMap<>();
SortedMap<String, FactModelTree> hiddenFacts = new TreeMap<>();
if (hasInput) {
for (InputDataNode input : dmnModelLocal.getInputs()) {
DMNType type = input.getType();
visibleFacts.put(input.getName(), createFactModelTree(input.getName(), input.getName(), type, hiddenFacts, FactModelTree.Type.INPUT));
}
}
if (hasOutput) {
for (DecisionNode decision : dmnModelLocal.getDecisions()) {
DMNType type = decision.getResultType();
visibleFacts.put(decision.getName(), createFactModelTree(decision.getName(), decision.getName(), type, hiddenFacts, DECISION));
}
}
return new FactModelTuple(visibleFacts, hiddenFacts);
}
use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class DMNSimulationSettingsCreationStrategyTest method addToScenarioRecursive.
@Test
public void addToScenarioRecursive() {
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("recursiveProperty", "recursive");
String propertyType = String.class.getCanonicalName();
String propertyName = "simpleProperty";
factModelTree.addSimpleProperty(propertyName, new FactModelTree.PropertyTypeName(propertyType));
hiddenFacts.put("recursive", factModelTree);
dmnSimulationCreationStrategy.addFactMapping(factMappingExtractorMock, factModelTree, new ArrayList<>(), hiddenFacts);
verify(factMappingExtractorMock, times(1)).getFactMapping(eq(factModelTree), eq(propertyName), eq(Arrays.asList("myFact", "recursiveProperty")), eq(propertyType));
verify(factMappingExtractorMock, times(2)).getFactMapping(any(), any(), any(), any());
}
use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class DMNSimulationSettingsCreationStrategyTest method createFactModelTree.
private FactModelTree createFactModelTree(String name, String path, DMNType type, SortedMap<String, FactModelTree> hiddenFacts, FactModelTree.Type fmType) {
Map<String, FactModelTree.PropertyTypeName> simpleFields = new HashMap<>();
if (!type.isComposite()) {
simpleFields.put(VALUE, new FactModelTree.PropertyTypeName(type.getName()));
FactModelTree simpleFactModelTree = new FactModelTree(name, "", simpleFields, new HashMap<>(), fmType);
simpleFactModelTree.setSimple(true);
return simpleFactModelTree;
}
FactModelTree factModelTree = new FactModelTree(name, "", simpleFields, new HashMap<>(), fmType);
for (Map.Entry<String, DMNType> entry : type.getFields().entrySet()) {
if (!entry.getValue().isComposite()) {
FactModelTree.PropertyTypeName propertyTypeName = entry.getValue().getBaseType() != null ? new FactModelTree.PropertyTypeName(entry.getValue().getName(), entry.getValue().getBaseType().getName()) : new FactModelTree.PropertyTypeName(entry.getValue().getName());
simpleFields.put(entry.getKey(), propertyTypeName);
} else {
String expandableId = path + "." + entry.getKey();
factModelTree.addExpandableProperty(entry.getKey(), expandableId);
hiddenFacts.put(expandableId, createFactModelTree(entry.getKey(), expandableId, entry.getValue(), hiddenFacts, FactModelTree.Type.UNDEFINED));
}
}
return factModelTree;
}
use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class BusinessCentralDMODataManagementStrategy method fieldCompletionsCallbackMethod.
/**
* Actual code of the <b>fieldCompletionsCallback</b>; isolated for testing
* @param factName
* @param superTypeMap
* @param result
* @param aggregatorCallback
*/
protected void fieldCompletionsCallbackMethod(String factName, Map<String, String> superTypeMap, ModelField[] result, Callback<FactModelTree> aggregatorCallback) {
FactModelTree toSend = getFactModelTree(factName, superTypeMap, result);
aggregatorCallback.callback(toSend);
}
use of org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree in project drools-wb by kiegroup.
the class AbstractTestToolsTest method getDataObjectFactTreeMap.
protected SortedMap<String, FactModelTree> getDataObjectFactTreeMap() {
SortedMap<String, FactModelTree> toReturn = new TreeMap<>();
IntStream.range(0, 3).forEach(id -> {
String key = getRandomString();
FactModelTree value = new FactModelTree(key, FACT_PACKAGE, getMockSimpleProperties(), new HashMap<>());
toReturn.put(key, value);
if (id == 1) {
value.addSimpleProperty(getRandomString(), getRandomType());
}
if (id == 2) {
value.addSimpleProperty(getRandomString(), getRandomType());
// Recursion
value.addSimpleProperty(getRandomString(), getRandomType());
}
});
return toReturn;
}
Aggregations