use of org.eclipse.che.api.project.shared.dto.event.FileWatcherEventType.DELETED in project che by eclipse.
the class FileTreeWatcherMassiveIoOperationTest method watchesUpdatesFilesInTree.
@Test
public void watchesUpdatesFilesInTree() throws Exception {
fileWatcherTestTree.createTree("", 7, 5);
Thread.sleep(100);
FileWatcherNotificationHandler notificationListener = aNotificationListener();
fileTreeWatcher = new FileTreeWatcher(testDirectory, newHashSet(), notificationListener);
fileTreeWatcher.startup();
Thread.sleep(5000);
List<String> updated = fileWatcherTestTree.findAllFilesInTree("").stream().filter(path -> path.hashCode() % 2 == 0).collect(Collectors.toList());
for (String file : updated) {
fileWatcherTestTree.updateFile(file);
}
Thread.sleep(5000);
verify(notificationListener, never()).errorOccurred(eq(testDirectory), any(Throwable.class));
verify(notificationListener, never()).handleFileWatcherEvent(eq(CREATED), eq(testDirectory), anyString(), anyBoolean());
verify(notificationListener, never()).handleFileWatcherEvent(eq(DELETED), eq(testDirectory), anyString(), anyBoolean());
ArgumentCaptor<String> updatedEvents = ArgumentCaptor.forClass(String.class);
verify(notificationListener, times(updated.size())).handleFileWatcherEvent(eq(MODIFIED), eq(testDirectory), updatedEvents.capture(), anyBoolean());
assertThatCollectionsContainsSameItemsOrFailWithDiff(updatedEvents.getAllValues(), updated);
}
use of org.eclipse.che.api.project.shared.dto.event.FileWatcherEventType.DELETED in project che by eclipse.
the class ProjectTreeTracker method getDeleteOperation.
private Consumer<String> getDeleteOperation(String endpointId) {
return it -> {
timers.add(it);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
if (timers.contains(it)) {
timers.remove(it);
ProjectTreeStateUpdateDto params = newDto(ProjectTreeStateUpdateDto.class).withPath(it).withType(DELETED);
transmitter.transmitOneToNone(endpointId, OUTGOING_METHOD, params);
}
}
}, 1_000L);
};
}
Aggregations