use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method testGetContentSupplier.
@Test
public void testGetContentSupplier() {
final GuidedDecisionTableView.Presenter presenter = mock(GuidedDecisionTableView.Presenter.class);
final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
final Overview overview = mock(Overview.class);
final ObservablePath currentPath = mock(ObservablePath.class);
final ObservablePath latestPath = mock(ObservablePath.class);
doReturn(model).when(presenter).getModel();
doReturn(overview).when(presenter).getOverview();
doReturn(currentPath).when(presenter).getCurrentPath();
doReturn(latestPath).when(presenter).getLatestPath();
doReturn(asSet(presenter)).when(this.presenter).getAvailableDecisionTables();
final List<GuidedDecisionTableEditorContent> content = this.presenter.getContentSupplier().get();
final GuidedDecisionTableEditorContent firstContent = content.get(0);
assertEquals(1, content.size());
assertEquals(model, firstContent.getModel());
assertEquals(overview, firstContent.getOverview());
assertEquals(currentPath, firstContent.getCurrentPath());
assertEquals(latestPath, firstContent.getLatestPath());
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImpl method constructContent.
@Override
protected GuidedEditorContent constructContent(Path path, Overview overview) {
final RuleModel 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 GuidedEditorContent(model, overview, dataModel);
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImplTest method checkConstructContentPopulateProjectCollectionTypes.
@Test
public void checkConstructContentPopulateProjectCollectionTypes() {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/rule.template");
when(dataModelService.getDataModel(any())).thenReturn(oracle);
when(oracle.getPackageGlobals()).thenReturn(new HashMap<String, String>() {
{
put("number", "java.lang.Number");
put("collection", "java.util.Collection");
}
});
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 GuidedTemplateEditorContent 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"));
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImplTest method checkConstructContent.
@Test
public void checkConstructContent() {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview);
verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));
assertNotNull(content.getModel());
assertEquals(overview, content.getOverview());
}
use of org.guvnor.common.services.shared.metadata.model.Overview in project drools-wb by kiegroup.
the class BaseGuidedDecisionTablePresenterTest method makeDecisionTableContent.
protected GuidedDecisionTableEditorContent makeDecisionTableContent(final int hashCode) {
final GuidedDecisionTable52 model = new GuidedDecisionTable52() {
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object o) {
return super.equals(o);
}
};
final Overview overview = mock(Overview.class);
final Metadata metadata = mock(Metadata.class);
when(overview.getMetadata()).thenReturn(metadata);
return new GuidedDecisionTableEditorContent(model, Collections.<PortableWorkDefinition>emptySet(), overview, mock(PackageDataModelOracleBaselinePayload.class));
}
Aggregations