use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnValidateWithErrors.
@Test
@SuppressWarnings("unchecked")
public void checkOnValidateWithErrors() {
final ObservablePath path = mock(ObservablePath.class);
final PlaceRequest placeRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent content = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(path, path, placeRequest, content);
final List<ValidationMessage> validationMessages = new ArrayList<ValidationMessage>() {
{
add(new ValidationMessage());
}
};
when(dtService.validate(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn(validationMessages);
doNothing().when(presenter).showValidationPopup(any(List.class));
presenter.onValidate(dtPresenter);
final ArgumentCaptor<GuidedDecisionTable52> modelCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
verify(dtService, times(1)).validate(eq(path), modelCaptor.capture());
assertNotNull(modelCaptor.getValue());
assertEquals(dtPresenter.getModel(), modelCaptor.getValue());
verify(notification, never()).fire(any(NotificationEvent.class));
verify(presenter, times(1)).showValidationPopup(eq(validationMessages));
}
use of org.uberfire.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method testOnDecisionTableSelectedWhenPresenterIsNotNull.
@Test
public void testOnDecisionTableSelectedWhenPresenterIsNotNull() {
final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
final Overview overview = mock(Overview.class);
final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
final GuidedDecisionTable52 model = new GuidedDecisionTable52();
final GuidedDecisionTablePresenter.Access access = new GuidedDecisionTablePresenter.Access();
final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
final ObservablePath path = mock(ObservablePath.class);
doNothing().when(presenter).initialiseKieEditorTabs(dtPresenter, overview, oracle, model.getImports(), false);
doNothing().when(presenter).initialiseEditorTabsWhenNoDocuments();
doReturn(true).when(modeller).isDecisionTableAvailable(dtPresenter);
doReturn(Optional.of(dtPresenter)).when(modeller).getActiveDecisionTable();
doReturn(overview).when(dtPresenter).getOverview();
doReturn(oracle).when(dtPresenter).getDataModelOracle();
doReturn(model).when(dtPresenter).getModel();
doReturn(access).when(dtPresenter).getAccess();
doReturn(path).when(dtPresenter).getLatestPath();
presenter.registerDocument(dtPresenter);
presenter.onDecisionTableSelected(event);
verify(presenter, never()).initialiseEditorTabsWhenNoDocuments();
verify(presenter).addColumnsTab();
verify(presenter).enableColumnsTab(dtPresenter);
}
use of org.uberfire.backend.vfs.ObservablePath 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.backend.vfs.ObservablePath in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method testLoadDocumentGraphEmptyModel.
@Test
public void testLoadDocumentGraphEmptyModel() throws Exception {
final ObservablePath documentPath = mock(ObservablePath.class);
final Overview overview = mock(Overview.class);
final GuidedDecisionTableEditorGraphModel graphModel = mock(GuidedDecisionTableEditorGraphModel.class);
final GuidedDecisionTableEditorGraphContent graphContent = mock(GuidedDecisionTableEditorGraphContent.class);
when(documentPath.getFileName()).thenReturn("GDT");
when(versionRecordManager.getCurrentPath()).thenReturn(documentPath);
when(dtGraphService.loadContent(documentPath)).thenReturn(graphContent);
when(versionRecordManager.getPathToLatest()).thenReturn(documentPath);
when(graphContent.getOverview()).thenReturn(overview);
when(graphContent.getModel()).thenReturn(graphModel);
presenter.loadDocumentGraph(documentPath);
verify(view).showLoading();
verify(view).hideBusyIndicator();
verify(view).refreshTitle(startsWith("GDT"));
// initialise when no documents
verify(editMenuItem).setEnabled(false);
verify(viewMenuItem).setEnabled(false);
verify(insertMenuItem).setEnabled(false);
verify(radarMenuItem).setEnabled(false);
verify(kieEditorWrapperView).clear();
verify(kieEditorWrapperView).addMainEditorPage(view);
verify(kieEditorWrapperView).addOverviewPage(eq(overviewWidget), any(com.google.gwt.user.client.Command.class));
verify(overviewWidget).setContent(overview, documentPath);
}
use of org.uberfire.backend.vfs.ObservablePath 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());
}
Aggregations