use of org.drools.workbench.screens.globals.model.GlobalsModel 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.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class GlobalsEditorServiceImpl method constructContent.
@Override
protected GlobalsEditorContent constructContent(Path path, Overview overview) {
// De-serialize model
final GlobalsModel model = load(path);
final ModuleDataModelOracle oracle = dataModelService.getModuleDataModel(path);
final String[] fullyQualifiedClassNames = new String[oracle.getModuleModelFields().size()];
oracle.getModuleModelFields().keySet().toArray(fullyQualifiedClassNames);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GlobalsEditorContent(model, overview, Arrays.asList(fullyQualifiedClassNames));
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class GlobalsEditorServiceTest method testSaveAndRename.
@Test
public void testSaveAndRename() throws Exception {
final GlobalsEditorServiceImpl service = (GlobalsEditorServiceImpl) globalsEditorService;
final Path path = mock(Path.class);
final String newFileName = "newFileName";
final Metadata metadata = mock(Metadata.class);
final GlobalsModel content = mock(GlobalsModel.class);
final String comment = "comment";
service.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class GlobalsPersistenceTest method testMarshalling.
@Test
public void testMarshalling() {
final GlobalsModel model = new GlobalsModel();
final String expected = "global java.lang.String myString;\n";
model.getGlobals().add(new Global("myString", "java.lang.String"));
final String actual = GlobalsPersistence.getInstance().marshal(model);
assertNotNull(actual);
assertEquals(expected, actual);
}
use of org.drools.workbench.screens.globals.model.GlobalsModel in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverter method makeGlobalsModel.
private GlobalsModel makeGlobalsModel(final List<Import> imports, final List<Global> globals, final ConversionResult result) {
final GlobalsModel model = new GlobalsModel();
for (Global global : globals) {
if (global.getClassName().contains(".")) {
model.getGlobals().add(new org.drools.workbench.screens.globals.model.Global(global.getIdentifier(), global.getClassName()));
} else {
boolean mapped = false;
for (Import imp : imports) {
if (imp.getClassName().contains(".")) {
final String fullyQualifiedClassName = imp.getClassName();
final String leafClassName = fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1);
if (global.getClassName().equals(leafClassName)) {
model.getGlobals().add(new org.drools.workbench.screens.globals.model.Global(global.getIdentifier(), fullyQualifiedClassName));
mapped = true;
break;
}
}
}
if (!mapped) {
result.addMessage("Unable to determine Fully Qualified Class Name for Global '" + global.getIdentifier() + "'. Skipping.", ConversionMessageType.ERROR);
}
}
}
return model;
}
Aggregations