Filters already handled content change events.
Inheritance: SyncEventHandler
        public void DoesNotFilterChangeEventsOfNotExistingObjects() {
            string remoteId = "remoteId";
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(Mock.Of<IMetaDataStorage>(), Mock.Of<ISession>());
            var contentChangeEvent = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Updated, remoteId);

            Assert.That(filter.Handle(contentChangeEvent), Is.False);
        }
        public void DoesNotFilterChangeEventsOfExistingButDifferentObjects() {
            string remoteId = "remoteId";
            string oldToken = "oldToken";
            string newToken = "newToken";
            var session = new Mock<ISession>();
            var storage = new Mock<IMetaDataStorage>();
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage.Object, session.Object);
            var mappedObject = Mock.Of<IMappedObject>(
                o =>
                o.LastChangeToken == oldToken &&
                o.RemoteObjectId == remoteId);
            storage.Setup(s => s.GetObjectByRemoteId(It.Is<string>(id => id == remoteId))).Returns(mappedObject);
            var remoteObject = Mock.Of<ICmisObject>(
                o =>
                o.ChangeToken == newToken);
            session.Setup(s => s.GetObject(It.Is<string>(id => id == remoteId), It.IsAny<IOperationContext>())).Returns(remoteObject);
            var contentChangeEvent = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Updated, remoteId);

            Assert.That(filter.Handle(contentChangeEvent), Is.False);
        }
 public void PriorityIsFilterPriority() {
     var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(Mock.Of<IMetaDataStorage>(), Mock.Of<ISession>());
     Assert.That(filter.Priority, Is.EqualTo(EventHandlerPriorities.FILTER));
 }
        public void DoesNotHandleUnknownEvents() {
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(Mock.Of<IMetaDataStorage>(), Mock.Of<ISession>());

            Assert.That(filter.Handle(Mock.Of<ISyncEvent>()), Is.False);
        }
        public void FilterIgnoresFileChangedEventsIfChangeLogTokenIsEqualButParentIdIsDifferent() {
            string remoteId = "remoteId";
            string changeToken = "Token";
            var session = new Mock<ISession>();
            var storage = new Mock<IMetaDataStorage>();
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage.Object, session.Object);
            var mappedObject = Mock.Of<IMappedObject>(
                o =>
                o.LastChangeToken == changeToken &&
                o.RemoteObjectId == remoteId &&
                o.ParentId == "oldParent");
            storage.Setup(s => s.GetObjectByRemoteId(It.Is<string>(id => id == remoteId))).Returns(mappedObject);
            var remoteDocument = Mock.Of<IDocument>(
                o =>
                o.ChangeToken == changeToken);
            Mock.Get(remoteDocument).SetupParent(Mock.Of<IFolder>(f => f.Id == "newParent"));
            session.Setup(s => s.GetObject(It.Is<string>(id => id == remoteId), It.IsAny<IOperationContext>())).Returns(remoteDocument);
            var contentChangeEvent = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Updated, remoteId);

            Assert.That(filter.Handle(contentChangeEvent), Is.False);
        }
        public void FiltersChangeEventsIfChangeLogTokenIsEqualToLocalObject() {
            string remoteId = "remoteId";
            string changeToken = "Token";
            string parentId = "parentId";
            var session = new Mock<ISession>();
            var storage = new Mock<IMetaDataStorage>();
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage.Object, session.Object);
            var mappedObject = Mock.Of<IMappedObject>(
                o =>
                o.LastChangeToken == changeToken &&
                o.RemoteObjectId == remoteId &&
                o.ParentId == parentId);
            storage.Setup(s => s.GetObjectByRemoteId(It.Is<string>(id => id == remoteId))).Returns(mappedObject);
            var remoteObject = Mock.Of<IFolder>(
                o =>
                o.ChangeToken == changeToken &&
                o.ParentId == parentId);
            session.Setup(s => s.GetObject(It.Is<string>(id => id == remoteId), It.IsAny<IOperationContext>())).Returns(remoteObject);
            var contentChangeEvent = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Updated, remoteId);

            Assert.That(filter.Handle(contentChangeEvent), Is.True);
        }
        public void FilterIgnoresDeletedEventsOfLocalExistingObjects() {
            string remoteId = "remoteId";
            var storage = new Mock<IMetaDataStorage>();
            storage.Setup(s => s.GetObjectByRemoteId(It.Is<string>(id => id == remoteId))).Returns(Mock.Of<IMappedObject>());
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage.Object, Mock.Of<ISession>());
            var contentChangeEvent = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Deleted, remoteId);

            Assert.That(filter.Handle(contentChangeEvent), Is.False);
        }
        public void FilterHandlesDeletedEventsOfNonLocalExistingObjects() {
            var filter = new IgnoreAlreadyHandledContentChangeEventsFilter(Mock.Of<IMetaDataStorage>(), Mock.Of<ISession>());
            var contentChangeEvent = new ContentChangeEvent(DotCMIS.Enums.ChangeType.Deleted, "remoteId");

            Assert.That(filter.Handle(contentChangeEvent), Is.True);
        }
        private SingleStepEventQueue CreateQueue(Mock<ISession> session, IMetaDataStorage storage, ObservableHandler observer, IFileSystemInfoFactory fsFactory = null) {
            var manager = new SyncEventManager();
            SingleStepEventQueue queue = new SingleStepEventQueue(manager);

            manager.AddEventHandler(observer);

            var connectionScheduler = new ConnectionScheduler(new RepoInfo(), queue, Mock.Of<ISessionFactory>(), Mock.Of<IAuthenticationProvider>());
            manager.AddEventHandler(connectionScheduler);

            var changes = new ContentChanges(session.Object, storage, queue, this.maxNumberOfContentChanges, this.isPropertyChangesSupported);
            manager.AddEventHandler(changes);

            var transformer = new ContentChangeEventTransformer(queue, storage, fsFactory);
            manager.AddEventHandler(transformer);

            var ccaccumulator = new ContentChangeEventAccumulator(session.Object, queue);
            manager.AddEventHandler(ccaccumulator);

            var remoteFetcher = new RemoteObjectFetcher(session.Object, storage);
            manager.AddEventHandler(remoteFetcher);

            var localFetcher = new LocalObjectFetcher(storage.Matcher, fsFactory);
            manager.AddEventHandler(localFetcher);

            var watcher = new Strategy.WatcherConsumer(queue);
            manager.AddEventHandler(watcher);

            var localDetection = new LocalSituationDetection();
            var remoteDetection = new RemoteSituationDetection();
            var transmissionManager = new TransmissionManager();
            var activityAggregator = new ActivityListenerAggregator(Mock.Of<IActivityListener>(), transmissionManager);

            var ignoreFolderFilter = new IgnoredFoldersFilter();
            var ignoreFolderNameFilter = new IgnoredFolderNameFilter();
            var ignoreFileNamesFilter = new IgnoredFileNamesFilter();
            var invalidFolderNameFilter = new InvalidFolderNameFilter();
            var filterAggregator = new FilterAggregator(ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, ignoreFolderFilter);

            var syncMechanism = new SyncMechanism(localDetection, remoteDetection, queue, session.Object, storage, Mock.Of<IFileTransmissionStorage>(), activityAggregator, filterAggregator);
            manager.AddEventHandler(syncMechanism);

            var remoteFolder = MockSessionUtil.CreateCmisFolder();
            remoteFolder.Setup(r => r.Path).Returns(this.remoteRoot);
            var localFolder = new Mock<IDirectoryInfo>();
            localFolder.Setup(f => f.FullName).Returns(this.localRoot);
            var generator = new CrawlEventGenerator(storage, fsFactory);
            var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage);
            var treeBuilder = new DescendantsTreeBuilder(storage, remoteFolder.Object, localFolder.Object, filterAggregator, ignoreStorage);
            var notifier = new CrawlEventNotifier(queue);
            var crawler = new DescendantsCrawler(queue, treeBuilder, generator, notifier, Mock.Of<IActivityListener>());
            manager.AddEventHandler(crawler);

            var permissionDenied = new GenericHandleDublicatedEventsFilter<PermissionDeniedEvent, ConfigChangedEvent>();
            manager.AddEventHandler(permissionDenied);

            var alreadyAddedFilter = new IgnoreAlreadyHandledFsEventsFilter(storage, fsFactory);
            manager.AddEventHandler(alreadyAddedFilter);

            var ignoreContentChangesFilter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage, session.Object);
            manager.AddEventHandler(ignoreContentChangesFilter);

            var delayRetryAndNextSyncEventHandler = new DelayRetryAndNextSyncEventHandler(queue);
            manager.AddEventHandler(delayRetryAndNextSyncEventHandler);

            /* This is not implemented yet
            var failedOperationsFilder = new FailedOperationsFilter(queue);
            manager.AddEventHandler(failedOperationsFilder);
            */

            var reportingFilter = new ReportingFilter(queue, ignoreFolderFilter, ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, new SymlinkFilter());
            manager.AddEventHandler(reportingFilter);

            var debugHandler = new DebugLoggingHandler();
            manager.AddEventHandler(debugHandler);

            var movedOrRenamed = new RemoteObjectMovedOrRenamedAccumulator(queue, storage, fsFactory);
            manager.AddEventHandler(movedOrRenamed);

            return queue;
        }