use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class ScenarioEditorPresenterTest method setUp.
@Before
public void setUp() throws Exception {
final AsyncPackageDataModelOracleFactory modelOracleFactory = mock(AsyncPackageDataModelOracleFactory.class);
fakeService = new CallerMock<>(service);
editor = spy(new ScenarioEditorPresenter(view, user, importsWidget, fakeService, new CallerMock<>(testService), new TestScenarioResourceType(new Others()), modelOracleFactory, settingsPage, auditPage) {
{
kieView = ScenarioEditorPresenterTest.this.kieView;
versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
overviewWidget = ScenarioEditorPresenterTest.this.overviewWidget;
notification = makeNotificationEvent();
fileMenuBuilder = ScenarioEditorPresenterTest.this.fileMenuBuilder;
projectController = ScenarioEditorPresenterTest.this.projectController;
workbenchContext = ScenarioEditorPresenterTest.this.workbenchContext;
versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
alertsButtonMenuItemBuilder = ScenarioEditorPresenterTest.this.alertsButtonMenuItemBuilder;
}
@Override
protected Command getSaveAndRename() {
return mock(Command.class);
}
});
scenarioRunResult = new Scenario();
scenario = new Scenario();
overview = new Overview();
when(user.getIdentifier()).thenReturn("userName");
when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
final TestScenarioModelContent testScenarioModelContent = new TestScenarioModelContent(scenario, overview, "org.test", new PackageDataModelOracleBaselinePayload());
when(service.loadContent(any(Path.class))).thenReturn(testScenarioModelContent);
final TestScenarioResult result = new TestScenarioResult(scenarioRunResult, Collections.EMPTY_SET);
when(service.runScenario(eq("userName"), any(Path.class), eq(scenario))).thenReturn(result);
final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
when(modelOracleFactory.makeAsyncPackageDataModelOracle(any(Path.class), any(HasImports.class), any(PackageDataModelOracleBaselinePayload.class))).thenReturn(dmo);
when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GlobalsEditorPresenterTest method loadContent.
@Test
public void loadContent() {
presenter.loadContent();
verify(view, times(1)).showLoading();
verify(globalsEditorService, times(1)).loadContent(any(Path.class));
when(versionRecordManager.getCurrentPath()).thenReturn(mock(ObservablePath.class));
// Emulate the globals being successfully loaded
GlobalsEditorContent globalsEditorContent = mock(GlobalsEditorContent.class);
Overview overview = mock(Overview.class);
when(overview.getMetadata()).thenReturn(mock(Metadata.class));
when(globalsEditorContent.getOverview()).thenReturn(overview);
GlobalsModel globalsModel = mock(GlobalsModel.class);
when(globalsEditorContent.getModel()).thenReturn(globalsModel);
presenter.getModelSuccessCallback().callback(globalsEditorContent);
verify(view, times(1)).setContent(anyListOf(Global.class), anyListOf(String.class), anyBoolean(), anyBoolean());
verify(view, times(1)).hideBusyIndicator();
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method constructContent.
@Override
protected GuidedDecisionTableEditorContent constructContent(Path path, Overview overview) {
final GuidedDecisionTable52 model = load(path);
final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
// Get FQCN's used by model
final GuidedDecisionTableModelVisitor visitor = new GuidedDecisionTableModelVisitor(model);
final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
// 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(entry -> entry.getValue()).map(entry -> entry.getKey()).collect(Collectors.toSet()));
DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
final Set<PortableWorkDefinition> workItemDefinitions = workItemsService.loadWorkItemDefinitions(path);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dataModel);
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImplTest method checkConstructContent.
@Test
public void checkConstructContent() {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
when(oracle.getModuleCollectionTypes()).thenReturn(new HashMap<String, Boolean>() {
{
put("java.util.List", true);
put("java.util.Set", true);
put("java.util.Collection", true);
put("java.util.UnknownCollection", false);
}
});
final Set<PortableWorkDefinition> workItemDefinitions = new HashSet<>();
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable.gdst");
when(dataModelService.getDataModel(eq(path))).thenReturn(oracle);
when(workItemsService.loadWorkItemDefinitions(eq(path))).thenReturn(workItemDefinitions);
final GuidedDecisionTableEditorContent content = service.constructContent(path, overview);
verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
assertNotNull(content.getModel());
assertNotNull(content.getDataModel());
assertNotNull(content.getWorkItemDefinitions());
assertEquals(overview, content.getOverview());
assertEquals(3, content.getDataModel().getCollectionTypes().size());
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Collection"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.List"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Set"));
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class BaseGuidedDecisionTablePresenterTest method setupPresenter.
protected GuidedDecisionTablePresenter setupPresenter() {
final GuidedDecisionTablePresenter wrapped = new GuidedDecisionTablePresenter(identity, resourceType, ruleNameServiceCaller, decisionTableSelectedEvent, decisionTableColumnSelectedEvent, decisionTableSelectionsChangedEvent, refreshAttributesPanelEvent, refreshMetaDataPanelEvent, refreshConditionsPanelEvent, refreshActionsPanelEvent, refreshMenusEvent, notificationEvent, gridWidgetCellFactory, gridWidgetColumnFactory, oracleFactory, synchronizer, beanManager, lockManager, linkManager, clipboard, decisionTableAnalyzerProvider, enumLoaderUtilities, pluginHandler, authorizationManager, sessionInfo) {
@Override
void initialiseLockManager() {
// Do nothing for tests
}
@Override
GuidedDecisionTableRenderer makeViewRenderer() {
return renderer;
}
@Override
GuidedDecisionTableView makeView(final Set<PortableWorkDefinition> workItemDefinitions) {
return view;
}
@Override
void initialiseAuditLog() {
// Do nothing for tests
}
@Override
List<BaseColumnConverter> getConverters() {
final List<BaseColumnConverter> converters = new ArrayList<BaseColumnConverter>();
converters.add(new ActionInsertFactColumnConverter());
converters.add(new ActionRetractFactColumnConverter());
converters.add(new ActionSetFieldColumnConverter());
converters.add(new ActionWorkItemExecuteColumnConverter());
converters.add(new ActionWorkItemInsertFactColumnConverter());
converters.add(new ActionWorkItemSetFieldColumnConverter());
converters.add(new AttributeColumnConverter());
converters.add(new BRLActionVariableColumnConverter());
converters.add(new BRLConditionVariableColumnConverter());
converters.add(new ConditionColumnConverter());
converters.add(new DescriptionColumnConverter());
converters.add(new LimitedEntryColumnConverter());
converters.add(new MetaDataColumnConverter());
converters.add(new RowNumberColumnConverter());
return converters;
}
@Override
List<Synchronizer<? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData>> getSynchronizers() {
final List<Synchronizer<? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData, ? extends Synchronizer.MetaData>> synchronizers = new ArrayList<>();
synchronizers.add(new ActionColumnSynchronizer());
synchronizers.add(new ActionInsertFactColumnSynchronizer());
synchronizers.add(new ActionRetractFactColumnSynchronizer());
synchronizers.add(new ActionSetFieldColumnSynchronizer());
synchronizers.add(new ActionWorkItemExecuteColumnSynchronizer());
synchronizers.add(new ActionWorkItemInsertFactColumnSynchronizer());
synchronizers.add(new ActionWorkItemSetFieldColumnSynchronizer());
synchronizers.add(new AttributeColumnSynchronizer());
synchronizers.add(new BRLActionColumnSynchronizer());
synchronizers.add(new BRLConditionColumnSynchronizer());
synchronizers.add(new ConditionColumnSynchronizer());
synchronizers.add(new LimitedEntryBRLActionColumnSynchronizer());
synchronizers.add(new LimitedEntryBRLConditionColumnSynchronizer());
synchronizers.add(new MetaDataColumnSynchronizer());
synchronizers.add(new RowSynchronizer());
return synchronizers;
}
};
GuidedDecisionTablePresenter presenter = spy(wrapped);
model = new GuidedDecisionTable52();
final PackageDataModelOracleBaselinePayload dmoBaseline = mock(PackageDataModelOracleBaselinePayload.class);
final Set<PortableWorkDefinition> workItemDefinitions = Collections.emptySet();
final Overview overview = mock(Overview.class);
dtContent = new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dmoBaseline);
when(oracleFactory.makeAsyncPackageDataModelOracle(any(Path.class), any(GuidedDecisionTable52.class), eq(dmoBaseline))).thenReturn(oracle);
when(view.getLayer()).thenReturn(gridLayer);
when(modellerPresenter.getView()).thenReturn(modellerView);
when(modellerView.getGridLayerView()).thenReturn(gridLayer);
when(presenter.getModellerPresenter()).thenReturn(modellerPresenter);
presenter.setContent(dtPath, dtPlaceRequest, dtContent, modellerPresenter, false);
return presenter;
}
Aggregations