private async Task SyncToPreviewGraph(ContentItem contentItem)
        {
            // sonar can't see that the set value could be used in the event of an exception
            #pragma warning disable S1854
            AllowSyncResult allowSyncResult = AllowSyncResult.Blocked;
            string          message         = $"Unable to sync '{contentItem.DisplayText}' Page to {GraphReplicaSetNames.Preview} graph(s).";

            try
            {
                IMergeGraphSyncer mergeGraphSyncer = _serviceProvider.GetRequiredService <IMergeGraphSyncer>();
                IContentManager   contentManager   = _serviceProvider.GetRequiredService <IContentManager>();
                IAllowSync        allowSync        = await mergeGraphSyncer.SyncToGraphReplicaSetIfAllowed(
                    _graphCluster.GetGraphReplicaSet(GraphReplicaSetNames.Preview), contentItem, contentManager);

                allowSyncResult = allowSync.Result;
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "Unable to sync '{ContentItemDisplayText}' Page to {GraphReplicaSetName} graph(s).",
                                 contentItem.DisplayText, GraphReplicaSetNames.Preview);
            }

            if (allowSyncResult == AllowSyncResult.Blocked)
            {
                _notifier.Add(NotifyType.Error, new LocalizedHtmlString(nameof(DefaultPageLocationsContentHandler), message));
            }
            #pragma warning restore S1854
        }
Пример #2
0
        public async Task DeleteDraft_SyncAllowedMatrix_ReturnsBool(
            AllowSyncResult allowSyncAllowedResult,
            bool expectedSuccess)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(allowSyncAllowedResult);

            bool success = await DeleteOrchestrator.Unpublish(ContentItem);

            Assert.Equal(expectedSuccess, success);
        }
        public async Task Clone_EventGridPublishingHandlerCalled(AllowSyncResult previewAllowSyncResult, int draftSavedCalled)
        {
            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncResult);

            await SyncOrchestrator.Clone(ContentItem);

            A.CallTo(() => EventGridPublishingHandler.Cloned(
                         A <IOrchestrationContext> .That.Matches(ctx => Equals(ctx.ContentItem, ContentItem))))
            .MustHaveHappened(draftSavedCalled, Times.Exactly);
        }
        public async Task Clone_SyncAllowedMatrix_ReturnsBool(
            AllowSyncResult allowSyncAllowedResult,
            bool expectedSuccess)
        {
            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(allowSyncAllowedResult);

            bool success = await SyncOrchestrator.Clone(ContentItem);

            Assert.Equal(expectedSuccess, success);
        }
Пример #5
0
        public async Task DeleteDraft_SyncAllowedMatrix_SyncCalled(
            AllowSyncResult allowSyncAllowedResult,
            bool expectedSyncCalled)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(allowSyncAllowedResult);

            await DeleteOrchestrator.Unpublish(ContentItem);

            A.CallTo(() => PublishedDeleteGraphSyncer.Delete())
            .MustHaveHappened(expectedSyncCalled?1:0, Times.Exactly);
        }
        public async Task Clone_SyncAllowedMatrix_SyncCalled(
            AllowSyncResult allowSyncAllowedResult,
            bool expectedSyncCalled)
        {
            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(allowSyncAllowedResult);

            await SyncOrchestrator.Clone(ContentItem);

            A.CallTo(() => PreviewMergeGraphSyncer.SyncToGraphReplicaSet())
            .MustHaveHappened(expectedSyncCalled?1:0, Times.Exactly);
        }
        public async Task Update_SyncAllowedSyncMatrix_ReturnsBool(
            AllowSyncResult publishedAllowSyncAllowedResult,
            AllowSyncResult previewAllowSyncAllowedResult,
            bool expectedSuccess)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncAllowedResult);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncAllowedResult);

            bool success = await SyncOrchestrator.Update(ContentItem, ContentItem);

            Assert.Equal(expectedSuccess, success);
        }
        public async Task Update_SyncToGraphReplicaSetOnPublishedGraphCalled(
            AllowSyncResult publishedAllowSyncResult,
            AllowSyncResult previewAllowSyncResult,
            int publishedCalled)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncResult);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncResult);

            await SyncOrchestrator.Update(ContentItem, ContentItem);

            A.CallTo(() => PublishedMergeGraphSyncer.SyncToGraphReplicaSet())
            .MustHaveHappened(publishedCalled, Times.Exactly);
        }
Пример #9
0
        public async Task Restore_DeleteCalled(
            AllowSyncResult publishedAllowSyncResult,
            AllowSyncResult previewAllowSyncResult,
            int publishedCalled)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncResult);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncResult);

            await SyncOrchestrator.Restore(ContentItem);

            A.CallTo(() => PublishedDeleteGraphSyncer.Delete())
            .MustHaveHappened(publishedCalled, Times.Exactly);
        }