Search in sources :

Example 16 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class BaseGuidedDecisionTablePresenterTest method makeDecisionTable.

protected GuidedDecisionTableView.Presenter makeDecisionTable(final Path originalPath, final ObservablePath path, final PlaceRequest placeRequest, final GuidedDecisionTableEditorContent content) {
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final Overview overview = mock(Overview.class);
    final GuidedDecisionTablePresenter.Access access = new GuidedDecisionTablePresenter.Access();
    when(dtService.loadContent(eq(path))).thenReturn(content);
    when(modeller.addDecisionTable(eq(path), eq(placeRequest), eq(content), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
    when(path.getOriginal()).thenReturn(originalPath);
    when(dtPresenter.getLatestPath()).thenReturn(path);
    when(dtPresenter.getCurrentPath()).thenReturn(path);
    when(dtPresenter.getPlaceRequest()).thenReturn(placeRequest);
    when(dtPresenter.getModel()).thenReturn(content.getModel());
    when(dtPresenter.getDataModelOracle()).thenReturn(oracle);
    when(dtPresenter.getOverview()).thenReturn(overview);
    when(dtPresenter.getAccess()).thenReturn(access);
    when(dtPresenter.getView()).thenReturn(mock(GuidedDecisionTableView.class));
    when(overview.getMetadata()).thenReturn(mock(Metadata.class));
    return dtPresenter;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)

Example 17 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class BaseGuidedDecisionTableEditorPresenterTest method testActivateDocument.

@Test
public void testActivateDocument() {
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final Overview overview = mock(Overview.class);
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final Imports imports = mock(Imports.class);
    final GuidedDecisionTablePresenter.Access access = mock(GuidedDecisionTablePresenter.Access.class);
    final MultiPageEditor pageEditor = mock(MultiPageEditor.class);
    final boolean isEditable = true;
    doReturn(overview).when(dtPresenter).getOverview();
    doReturn(oracle).when(dtPresenter).getDataModelOracle();
    doReturn(model).when(dtPresenter).getModel();
    doReturn(imports).when(model).getImports();
    doReturn(access).when(dtPresenter).getAccess();
    doReturn(isEditable).when(access).isEditable();
    doReturn(pageEditor).when(presenter).getKieEditorWrapperMultiPage();
    doNothing().when(presenter).activateDocument(any(), any(), any(), any(), anyBoolean());
    presenter.activateDocument(dtPresenter);
    verify(dtPresenter).activate();
    verify(presenter).enableMenus(true);
    verify(presenter).addColumnsTab();
    verify(presenter).enableColumnsTab(dtPresenter);
    verify(presenter).activateDocument(dtPresenter, overview, oracle, imports, !isEditable);
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) Overview(org.guvnor.common.services.shared.metadata.model.Overview) MultiPageEditor(org.uberfire.client.workbench.widgets.multipage.MultiPageEditor) Imports(org.kie.soup.project.datamodel.imports.Imports) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Test(org.junit.Test)

Example 18 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method testGetMetadataSupplier.

@Test
public void testGetMetadataSupplier() {
    final GuidedDecisionTableView.Presenter document = mock(GuidedDecisionTableView.Presenter.class);
    final Overview overview = mock(Overview.class);
    final Metadata expectedMetadata = mock(Metadata.class);
    doReturn(document).when(presenter).getActiveDocument();
    doReturn(overview).when(document).getOverview();
    doReturn(expectedMetadata).when(overview).getMetadata();
    final Metadata actualMetadata = presenter.getMetadataSupplier().get();
    assertEquals(expectedMetadata, actualMetadata);
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Test(org.junit.Test)

Example 19 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedRuleEditorServiceImplTest method checkConstructContentPopulateProjectCollectionTypesAndDSLSentences.

@Test
public void checkConstructContentPopulateProjectCollectionTypesAndDSLSentences() throws Exception {
    final Path path = mock(Path.class);
    final Overview overview = mock(Overview.class);
    final ModuleDataModelOracle projectDataModelOracle = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addClass(List.class).addClass(Set.class).addClass(Collection.class).addClass(Integer.class).build();
    final PackageDataModelOracle oracle = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator()).setModuleOracle(projectDataModelOracle).addExtension(DSLActionSentence.INSTANCE, Collections.singletonList(dslSentence)).addExtension(DSLConditionSentence.INSTANCE, Collections.singletonList(dslSentence)).build();
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/rule.rdrl");
    when(dataModelService.getDataModel(any())).thenReturn(oracle);
    final GuidedEditorContent content = service.constructContent(path, overview);
    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"));
    assertTrue(content.getDataModel().getPackageElements(DSLActionSentence.INSTANCE).contains(dslSentence));
    assertTrue(content.getDataModel().getPackageElements(DSLConditionSentence.INSTANCE).contains(dslSentence));
}
Also used : Path(org.uberfire.backend.vfs.Path) Set(java.util.Set) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) GuidedEditorContent(org.drools.workbench.screens.guided.rule.model.GuidedEditorContent) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Overview(org.guvnor.common.services.shared.metadata.model.Overview) Test(org.junit.Test)

Example 20 with Overview

use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.

the class GuidedRuleTemplateEditorServiceImpl method constructContent.

@Override
protected GuidedTemplateEditorContent constructContent(Path path, Overview overview) {
    final TemplateModel model = load(path);
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    // Get FQCN's used by model
    final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(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);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new GuidedTemplateEditorContent(model, overview, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Level(org.guvnor.common.services.shared.message.Level) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) GuidedRuleTemplateResourceTypeDefinition(org.drools.workbench.screens.guided.template.type.GuidedRuleTemplateResourceTypeDefinition) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) ExceptionUtilities(org.guvnor.common.services.backend.exceptions.ExceptionUtilities) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) GuidedRuleTemplateEditorService(org.drools.workbench.screens.guided.template.service.GuidedRuleTemplateEditorService) Overview(org.guvnor.common.services.shared.metadata.model.Overview) Service(org.jboss.errai.bus.server.annotations.Service) SafeSessionInfo(org.guvnor.common.services.backend.config.SafeSessionInfo) SessionInfo(org.uberfire.rpc.SessionInfo) Named(javax.inject.Named) KieService(org.kie.workbench.common.services.backend.service.KieService) RenameService(org.uberfire.ext.editor.commons.service.RenameService) Path(org.uberfire.backend.vfs.Path) DeleteService(org.uberfire.ext.editor.commons.service.DeleteService) Event(javax.enterprise.event.Event) DataModelService(org.kie.workbench.common.services.datamodel.backend.server.service.DataModelService) SaveAndRenameServiceImpl(org.uberfire.ext.editor.commons.backend.service.SaveAndRenameServiceImpl) DataModelOracleUtilities(org.kie.workbench.common.services.datamodel.backend.server.DataModelOracleUtilities) Set(java.util.Set) Collectors(java.util.stream.Collectors) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) RuleTemplateModelXMLPersistenceImpl(org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl) GenericValidator(org.guvnor.common.services.backend.validation.GenericValidator) List(java.util.List) GuidedTemplateEditorContent(org.drools.workbench.screens.guided.template.model.GuidedTemplateEditorContent) GuidedRuleModelVisitor(org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor) PostConstruct(javax.annotation.PostConstruct) IOService(org.uberfire.io.IOService) ApplicationScoped(javax.enterprise.context.ApplicationScoped) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) CopyService(org.uberfire.ext.editor.commons.service.CopyService) GuidedTemplateEditorContent(org.drools.workbench.screens.guided.template.model.GuidedTemplateEditorContent) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) GuidedRuleModelVisitor(org.drools.workbench.screens.guided.rule.backend.server.GuidedRuleModelVisitor) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent)

Aggregations

Overview (org.guvnor.common.services.shared.metadata.model.Overview)20 Test (org.junit.Test)11 Path (org.uberfire.backend.vfs.Path)11 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)8 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)8 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)8 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)7 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)6 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)6 ObservablePath (org.uberfire.backend.vfs.ObservablePath)6 Set (java.util.Set)5 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)5 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)5 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 PostConstruct (javax.annotation.PostConstruct)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Event (javax.enterprise.event.Event)3