use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.
the class ScenarioSimulationServiceImpl method constructContent.
@Override
protected ScenarioSimulationModelContent constructContent(final Path path, final Overview overview) {
final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
final Set<String> consumedFQCNs = new HashSet<>();
// Get FQCN's used by Globals
consumedFQCNs.addAll(oracle.getPackageGlobals().values());
// Get FQCN's of collections defined in project settings
// they can be used in From Collect expressions
consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toSet()));
DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new ScenarioSimulationModelContent(load(path), overview, dataModel);
}
use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.
the class ScenarioSimulationServiceImplLoadContentTest method loadContent.
@Test
public void loadContent() {
final ScenarioSimulationModelContent scenarioSimulationModelContent = serviceSpy.loadContent(path);
assertNotNull(scenarioSimulationModelContent);
assertNotNull(scenarioSimulationModelContent.getDataModel());
assertNotNull(scenarioSimulationModelContent.getModel());
assertNotNull(scenarioSimulationModelContent.getOverview());
verify(serviceSpy, times(1)).constructContent(eq(path), isA(Overview.class));
verify(dmnTypeServiceMock, times(1)).initializeNameAndNamespace(isA(Settings.class), eq(path), any());
verify(resourceOpenedEvent).fire(any(ResourceOpenedEvent.class));
}
use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.
the class AbstractDMODataManagementStrategyTest method setup.
@Before
public void setup() {
super.setup();
factTypes = new ArrayList<>();
visibleFactsLocal = new TreeMap<>();
hiddenFactsLocal = new TreeMap<>();
factModelTupleLocal = new FactModelTuple(visibleFactsLocal, hiddenFactsLocal);
factModelTreeHolderlocal = new AbstractDataManagementStrategy.ResultHolder();
factModelTreeHolderlocal.setFactModelTuple(factModelTupleLocal);
abstractDMODataManagementStrategySpy = spy(new AbstractDMODataManagementStrategy() {
@Override
public void manageScenarioSimulationModelContent(ObservablePath currentPath, ScenarioSimulationModelContent toManage) {
}
@Override
public boolean isADataType(String value) {
return false;
}
@Override
protected String getFQCNByFactName(String factName) {
return FULL_CLASS_NAME;
}
@Override
protected String getParametricFieldType(String factName, String propertyName) {
return PARAMETRIC_FIELD_TYPE;
}
@Override
protected List<String> getFactTypes() {
return factTypes;
}
@Override
protected void getSuperType(String factType, Callback<String> callback) {
// Do Nothing
}
@Override
protected boolean skipPopulateTestTools() {
return false;
}
@Override
protected void manageDataObjects(List<String> dataObjectsTypes, Map<String, String> superTypeMap, TestToolsView.Presenter testToolsPresenter, int expectedElements, SortedMap<String, FactModelTree> dataObjectsFieldsMap, ScenarioSimulationContext context, List<String> simpleJavaTypes, GridWidget gridWidget) {
}
{
this.model = modelLocal;
this.factModelTreeHolder = factModelTreeHolderlocal;
}
});
}
use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.
the class AbstractScenarioSimulationEditorTest method setup.
public void setup() {
super.setup();
// Mock FileMenuBuilder usage since we cannot use FileMenuBuilderImpl either
when(fileMenuBuilderMock.addSave(any(MenuItem.class))).thenReturn(fileMenuBuilderMock);
when(fileMenuBuilderMock.addCopy(any(ObservablePath.class), any(DefaultFileNameValidator.class))).thenReturn(fileMenuBuilderMock);
when(fileMenuBuilderMock.addRename(any(Command.class))).thenReturn(fileMenuBuilderMock);
when(fileMenuBuilderMock.addDelete(any(ObservablePath.class))).thenReturn(fileMenuBuilderMock);
when(fileMenuBuilderMock.addValidate(any(Command.class))).thenReturn(fileMenuBuilderMock);
when(fileMenuBuilderMock.addNewTopLevelMenu(any(MenuItem.class))).thenReturn(fileMenuBuilderMock);
when(versionRecordManagerMock.getCurrentPath()).thenReturn(observablePathMock);
when(versionRecordManagerMock.getPathToLatest()).thenReturn(observablePathMock);
when(workbenchContextMock.getActiveWorkspaceProject()).thenReturn(Optional.empty());
when(gridContextMenuMock.getView()).thenReturn(gridContextMenuViewMock);
when(headerGivenContextMenuMock.getView()).thenReturn(headerContextMenuViewMock);
this.modelLocal = new ScenarioSimulationModel();
modelLocal.setSimulation(getSimulation());
modelLocal.setSettings(settingsLocal);
settingsLocal.setType(ScenarioSimulationModel.Type.RULE);
settingsLocal.setDmoSession(null);
modelLocal.setBackground(backgroundLocal);
this.content = new ScenarioSimulationModelContent(modelLocal, overviewMock, packageDataModelOracleBaselinePayload);
when(packageDataModelOracleBaselinePayload.getPackageName()).thenReturn(TestProperties.FACT_PACKAGE);
when(scenarioSimulationServiceMock.loadContent(observablePathMock)).thenReturn(content);
}
use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.
the class AbstractDMNDataManagementStrategyTest method manageScenarioSimulationModelContent.
@Test
public void manageScenarioSimulationModelContent() {
final ScenarioSimulationModelContent contentMock = Mockito.spy(content);
abstractDMNDataManagementStrategySpy.manageScenarioSimulationModelContent(observablePathMock, contentMock);
verify(observablePathMock, times(1)).getOriginal();
verify(contentMock, times(1)).getModel();
}
Aggregations