use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkBuildModelFromEditor.
@Test
public void checkBuildModelFromEditor() {
final ObservablePath dtPath1 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter1 = makeDecisionTable(dtPath1, dtPath1, dtPlaceRequest1, dtContent1);
final ObservablePath dtPath2 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest2 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent2 = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
when(dtPresenter1.getView().getX()).thenReturn(100.0);
when(dtPresenter1.getView().getY()).thenReturn(110.0);
when(dtPresenter2.getView().getX()).thenReturn(200.0);
when(dtPresenter2.getView().getY()).thenReturn(220.0);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter1);
add(dtPresenter2);
}
});
final GuidedDecisionTableEditorGraphModel model = presenter.buildModelFromEditor();
assertNotNull(model);
assertNotNull(model.getEntries());
assertEquals(2, model.getEntries().size());
assertContains(model.getEntries(), dtPath1, 100.0, 110.0);
assertContains(model.getEntries(), dtPath2, 200.0, 220.0);
}
use of org.uberfire.mvp.PlaceRequest in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnStartupBasicInitialisation.
@Test
public void checkOnStartupBasicInitialisation() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(INITIAL_HASH_CODE);
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(dtGraphPath.getFileName()).thenReturn("filename");
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
assertEquals(dtGraphPath, presenter.editorPath);
assertEquals(dtGraphPlaceRequest, presenter.editorPlaceRequest);
assertEquals(INITIAL_HASH_CODE, (int) presenter.originalGraphHash);
verify(presenter, times(1)).initialiseEditor(eq(dtGraphPath), eq(dtGraphPlaceRequest));
verify(presenter, times(1)).initialiseVersionManager();
verify(presenter, times(1)).addFileChangeListeners(eq(dtGraphPath));
verify(lockManager, times(1)).init(lockTargetCaptor.capture());
final LockTarget lockTarget = lockTargetCaptor.getValue();
assertNotNull(lockTarget);
assertEquals(dtGraphPath, lockTarget.getPath());
assertEquals(dtGraphPlaceRequest, lockTarget.getPlace());
assertNotNull(lockTarget.getTitle());
}
use of org.uberfire.mvp.PlaceRequest 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.mvp.PlaceRequest 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.mvp.PlaceRequest in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnDelete.
@Test
public void checkOnDelete() {
final PlaceRequest placeRequest = mock(PlaceRequest.class);
presenter.editorPlaceRequest = placeRequest;
presenter.onDelete();
final ArgumentCaptor<Scheduler.ScheduledCommand> commandCaptor = ArgumentCaptor.forClass(Scheduler.ScheduledCommand.class);
verify(presenter, times(1)).scheduleClosure(commandCaptor.capture());
final Scheduler.ScheduledCommand command = commandCaptor.getValue();
assertNotNull(command);
command.execute();
verify(placeManager, times(1)).forceClosePlace(eq(placeRequest));
}
Aggregations