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