use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnOpenDocumentsInEditor.
@Test
public void checkOnOpenDocumentsInEditor() {
final Path dtPath1 = PathFactory.newPath("file1", "file1Url");
final Path dtPath2 = PathFactory.newPath("file2", "file2Url");
final List<Path> dtPaths = new ArrayList<Path>() {
{
add(dtPath1);
add(dtPath2);
}
};
final ObservablePath dtPath = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
presenter.onOpenDocumentsInEditor(dtPaths);
verify(dtService, times(2)).loadContent(dtPathCaptor.capture());
final List<Path> dtLoadedPaths = dtPathCaptor.getAllValues();
assertNotNull(dtLoadedPaths);
assertEquals(2, dtLoadedPaths.size());
assertContains(dtLoadedPaths, dtPath1);
assertContains(dtLoadedPaths, dtPath2);
}
use of org.uberfire.backend.vfs.ObservablePath 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.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkReload.
@Test
public void checkReload() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PathPlaceRequest dtGraphPlaceRequest = mock(PathPlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
final ObservablePath dtPath = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
final GuidedDecisionTableGraphEntry dtGraphEntry = new GuidedDecisionTableGraphEntry(dtPath, dtPath);
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
when(dtPath.toURI()).thenReturn("dtPath");
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtService.loadContent(eq(dtPath))).thenReturn(dtContent);
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
verify(presenter, times(1)).loadDocumentGraph(dtGraphPath);
presenter.reload();
verify(presenter, times(1)).deregisterDocument(eq(dtPresenter));
verify(presenter, times(2)).loadDocumentGraph(dtGraphPath);
verify(modeller, times(1)).releaseDecisionTables();
verify(modellerView, times(1)).clear();
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method getPresenter.
@Override
protected GuidedDecisionTableGraphEditorPresenter getPresenter() {
return new GuidedDecisionTableGraphEditorPresenter(view, dtServiceCaller, dtGraphServiceCaller, moduleServiceCaller, graphSaveAndRenameServiceCaller, notification, saveInProgressEvent, decisionTableSelectedEvent, validationPopup, dtGraphResourceType, editMenuBuilder, viewMenuBuilder, insertMenuBuilder, radarMenuBuilder, modeller, helper, beanManager, placeManager, lockManager, columnsPage, saveAndRenameCommandBuilder, alertsButtonMenuItemBuilder) {
{
workbenchContext = GuidedDecisionTableGraphEditorPresenterTest.this.workbenchContext;
projectController = GuidedDecisionTableGraphEditorPresenterTest.this.projectController;
}
@Override
protected Command getSaveAndRenameCommand() {
return mock(Command.class);
}
@Override
PathPlaceRequest getPathPlaceRequest(final Path path) {
// Avoid use of IOC.getBeanManager().lookupBean(..) in PathPlaceRequest for Unit Tests
final PathPlaceRequest pathPlaceRequest = new PathPlaceRequest(path) {
@Override
protected ObservablePath createObservablePath(final Path path) {
final ObservablePath op = new ObservablePathImpl().wrap(path);
return op;
}
};
return pathPlaceRequest;
}
};
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnDecisionTableSelected.
private void checkOnDecisionTableSelected(final ParameterizedCommand<PlaceRequest> setup, final Command assertion) {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
final ObservablePath dtPath = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
final GuidedDecisionTableGraphEntry dtGraphEntry = new GuidedDecisionTableGraphEntry(dtPath, dtPath);
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
when(dtPath.toURI()).thenReturn("dtPath");
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtService.loadContent(eq(dtPath))).thenReturn(dtContent);
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
setup.execute(dtGraphPlaceRequest);
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
presenter.onDecisionTableSelected(event);
assertion.execute();
}
Aggregations