use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImplTest method checkLoad.
@Test
public void checkLoad() {
final Path path = mock(Path.class);
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("");
final GuidedDecisionTableEditorGraphModel model = service.load(path);
verify(ioService, times(1)).readAllString(any(org.uberfire.java.nio.file.Path.class));
assertNotNull(model);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class BaseGuidedDecisionTableEditorPresenterTest method checkOnValidateWithoutErrors.
@Test
public void checkOnValidateWithoutErrors() {
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);
when(dtService.validate(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn(Collections.emptyList());
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, times(1)).fire(any(NotificationEvent.class));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnStartupLoadGraphEntries.
@Test
public void checkOnStartupLoadGraphEntries() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(INITIAL_HASH_CODE);
final Path dtPath = mock(Path.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtGraphPath, dtGraphPlaceRequest, 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);
// Fake building of Graph Model from Editor to control hashCode
doReturn(makeDecisionTableGraphContent(EDITOR_HASH_CODE).getModel()).when(presenter).buildModelFromEditor();
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
verify(view, times(1)).showLoading();
verify(presenter, times(1)).loadDocumentGraph(eq(dtGraphPath));
verify(dtService, times(1)).loadContent(eq(dtPath));
verify(modeller, times(1)).addDecisionTable(dtObservablePathCaptor.capture(), dtPathPlaceRequestCaptor.capture(), eq(dtContent), any(Boolean.class), eq(null), eq(null));
final ObservablePath dtObservablePath = dtObservablePathCaptor.getValue();
final PathPlaceRequest dtPathPlaceRequest = dtPathPlaceRequestCaptor.getValue();
assertNotNull(dtObservablePath);
assertNotNull(dtPathPlaceRequest);
assertEquals(dtPath.toURI(), dtObservablePath.toURI());
assertEquals(dtPath.toURI(), dtPathPlaceRequest.getPath().toURI());
assertEquals(EDITOR_HASH_CODE, (int) presenter.originalGraphHash);
verify(presenter, times(1)).registerDocument(eq(dtPresenter));
verify(view, times(1)).hideBusyIndicator();
verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
final DecisionTableSelectedEvent dtSelectedEvent = dtSelectedEventCaptor.getValue();
assertNotNull(dtSelectedEvent);
assertTrue(dtSelectedEvent.getPresenter().isPresent());
assertEquals(dtPresenter, dtSelectedEvent.getPresenter().get());
verify(modellerGridPanel).setFocus(eq(true));
verify(lockManager, never()).acquireLock();
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkInitNewDocumentFromRegisteredDocumentMenu.
@Test
@SuppressWarnings("unchecked")
public void checkInitNewDocumentFromRegisteredDocumentMenu() {
verify(registeredDocumentsMenuBuilder, times(1)).setNewDocumentCommand(newDocumentCommandCaptor.capture());
final Command newDocumentCommand = newDocumentCommandCaptor.getValue();
assertNotNull(newDocumentCommand);
newDocumentCommand.execute();
verify(presenter, times(1)).onNewDocument();
verify(helper, times(1)).createNewGuidedDecisionTable(eq(activePackageResourcesPath), eq(""), eq(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY), eq(GuidedDecisionTable52.HitPolicy.NONE), eq(view), onSaveSuccessCallbackCaptor.capture());
final Path dtPath = mock(Path.class);
final RemoteCallback<Path> onSaveSuccessCallback = onSaveSuccessCallbackCaptor.getValue();
assertNotNull(onSaveSuccessCallback);
doNothing().when(presenter).onOpenDocumentsInEditor(any(List.class));
onSaveSuccessCallback.callback(dtPath);
verify(presenter, times(1)).onOpenDocumentsInEditor(dtPathsCaptor.capture());
final List<Path> dtPaths = dtPathsCaptor.getValue();
assertNotNull(dtPaths);
assertEquals(1, dtPaths.size());
assertEquals(dtPath, dtPaths.get(0));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorRenameHelperTest method testRDSLRFile.
@Test
public void testRDSLRFile() {
final Path pathSource = mock(Path.class);
final Path pathDestination = mock(Path.class);
when(pathSource.toURI()).thenReturn("default://p0/src/main/resources/MyFile.rdslr");
when(pathDestination.toURI()).thenReturn("default://p0/src/main/resources/MyNewFile.rdslr");
when(pathDestination.getFileName()).thenReturn("MyNewFile.rdslr");
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn(dslr);
helper.postProcess(pathSource, pathDestination);
final ArgumentCaptor<String> drlArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), drlArgumentCaptor.capture(), any(CommentedOption.class));
final String newDrl = drlArgumentCaptor.getValue();
assertNotNull(newDrl);
assertTrue(newDrl.contains("MyNewFile"));
}
Aggregations