Esempio n. 1
0
        public void SaveProcessManagerAndPublishCommands_absorbs_command_publisher_exception_handler_exception()
        {
            // Arrange
            var processManager = new FooProcessManager();
            CancellationToken cancellationToken = CancellationToken.None;
            ICommandPublisher commandPublisher  = Mock.Of <ICommandPublisher>();

            Mock.Get(commandPublisher)
            .Setup(x => x.FlushCommands(processManager.Id, cancellationToken))
            .ThrowsAsync(new InvalidOperationException());

            var sut = new SqlProcessManagerDataContext <FooProcessManager>(
                new FooProcessManagerDbContext(),
                new JsonMessageSerializer(),
                commandPublisher,
                new DelegatingCommandPublisherExceptionHandler(
                    context =>
            {
                context.Handled = true;
                throw new InvalidOperationException();
            }));

            // Act
            Func <Task> action = () =>
                                 sut.SaveProcessManagerAndPublishCommands(processManager, cancellationToken: cancellationToken);

            // Assert
            action.ShouldNotThrow();
        }
Esempio n. 2
0
 public OefeningController(ILogger <OefeningController> logger, IOefeningRepository oefeningRepository, IPrestatieRepository prestatieRepository, ICommandPublisher commandPublisher)
 {
     _logger              = logger;
     _oefeningRepository  = oefeningRepository;
     _prestatieRepository = prestatieRepository;
     _commandPublisher    = commandPublisher;
 }
Esempio n. 3
0
        public void given_command_publisher_fails_SaveProcessManagerAndPublishCommands_invokes_exception_handler()
        {
            // Arrange
            var processManager = new FooProcessManager();
            CancellationToken cancellationToken = CancellationToken.None;
            Exception         exception         = new InvalidOperationException();
            ICommandPublisher commandPublisher  = Mock.Of <ICommandPublisher>();

            Mock.Get(commandPublisher)
            .Setup(x => x.FlushCommands(processManager.Id, cancellationToken))
            .ThrowsAsync(exception);

            ICommandPublisherExceptionHandler commandPublisherExceptionHandler = Mock.Of <ICommandPublisherExceptionHandler>();

            var sut = new SqlProcessManagerDataContext <FooProcessManager>(
                new FooProcessManagerDbContext(),
                new JsonMessageSerializer(),
                commandPublisher,
                commandPublisherExceptionHandler);

            // Act
            Func <Task> action = () =>
                                 sut.SaveProcessManagerAndPublishCommands(processManager, cancellationToken: cancellationToken);

            // Assert
            action.ShouldThrow <InvalidOperationException>().Which.Should().BeSameAs(exception);
            Mock.Get(commandPublisherExceptionHandler).Verify(
                x =>
                x.Handle(It.Is <CommandPublisherExceptionContext>(
                             p =>
                             p.ProcessManagerType == typeof(FooProcessManager) &&
                             p.ProcessManagerId == processManager.Id &&
                             p.Exception == exception)),
                Times.Once());
        }
Esempio n. 4
0
        public void given_command_publisher_exception_handled_SaveProcessManagerAndPublishCommands_does_not_throw()
        {
            // Arrange
            var processManager = new FooProcessManager();
            CancellationToken cancellationToken = CancellationToken.None;
            Exception         exception         = new InvalidOperationException();
            ICommandPublisher commandPublisher  = Mock.Of <ICommandPublisher>();

            Mock.Get(commandPublisher)
            .Setup(x => x.FlushCommands(processManager.Id, cancellationToken))
            .ThrowsAsync(exception);

            var sut = new SqlProcessManagerDataContext <FooProcessManager>(
                new FooProcessManagerDbContext(),
                new JsonMessageSerializer(),
                commandPublisher,
                new DelegatingCommandPublisherExceptionHandler(
                    context =>
                    context.Handled =
                        context.ProcessManagerType == typeof(FooProcessManager) &&
                        context.ProcessManagerId == processManager.Id &&
                        context.Exception == exception));

            // Act
            Func <Task> action = () =>
                                 sut.SaveProcessManagerAndPublishCommands(processManager, cancellationToken: cancellationToken);

            // Assert
            action.ShouldNotThrow();
        }
Esempio n. 5
0
 public GroupController(
     IGroupService groupService,
     IGroupMemberService groupMemberService,
     IMediaHelper mediaHelper,
     IGroupLinkProvider groupLinkProvider,
     IUserService userService,
     IGroupMediaService groupMediaService,
     IIntranetUserService <IGroupMember> intranetUserService,
     IProfileLinkProvider profileLinkProvider,
     UmbracoHelper umbracoHelper,
     IDocumentTypeAliasProvider documentTypeAliasProvider,
     IImageHelper imageHelper,
     IGroupPermissionsService groupPermissionsService,
     ICommandPublisher commandPublisher)
     : base(
         groupService,
         groupMemberService,
         mediaHelper,
         groupMediaService,
         intranetUserService,
         profileLinkProvider,
         groupLinkProvider,
         imageHelper,
         commandPublisher)
 {
     _intranetUserService       = intranetUserService;
     _umbracoHelper             = umbracoHelper;
     _documentTypeAliasProvider = documentTypeAliasProvider;
     _groupPermissionsService   = groupPermissionsService;
 }
        private static ReactiveCommand FireCommands(
            ICommandPublisher bus,
            IEnumerable <Func <Command> > commands,
            IObservable <bool> canExecute = null,
            IScheduler scheduler          = null,
            string userErrorMsg           = null,
            TimeSpan?responseTimeout      = null,
            TimeSpan?ackTimeout           = null)
        {
            if (scheduler == null)
            {
                scheduler = RxApp.MainThreadScheduler;
            }
            Func <object, Task> task = async _ => await Task.Run(() =>
            {
                foreach (var func in commands)
                {
                    bus.Send(func(), userErrorMsg, responseTimeout, ackTimeout);
                }
            });

            var cmd = ReactiveCommand.CreateFromTask(task, canExecute, scheduler);

            cmd.ThrownExceptions
#pragma warning disable CS0618 // Type or member is obsolete
            .SelectMany(ex => UserError.Throw(userErrorMsg, ex))
#pragma warning restore CS0618 // Type or member is obsolete
            .ObserveOn(MainThreadScheduler).Subscribe(result =>
            {
                //This will return the recovery option returned from the registered user error handler
                //right now this is a simple message box in the view code behind
                /* n.b. this forces evaluation/execution of the select many  */
            });
            return(cmd);
        }
Esempio n. 7
0
 public VideoConverter(
     ICommandPublisher commandPublisher,
     IApplicationSettings applicationSettings)
 {
     _commandPublisher    = commandPublisher;
     _applicationSettings = applicationSettings;
 }
Esempio n. 8
0
 public MentionService(
     ICommandPublisher commandPublisher,
     IIntranetUserContentProvider intranetUserContentProvider)
 {
     _commandPublisher            = commandPublisher;
     _intranetUserContentProvider = intranetUserContentProvider;
 }
Esempio n. 9
0
 public AccountsController(
     IUserRepository repo,
     UserManager <SensateUser> userManager,
     IEmailSender emailer,
     IOptions <UserAccountSettings> options,
     IPasswordResetTokenRepository tokens,
     IChangeEmailTokenRepository emailTokens,
     IChangePhoneNumberTokenRepository phoneTokens,
     IUserTokenRepository tokenRepository,
     ITextSendService text,
     IUserService userService,
     ICommandPublisher publisher,
     IOptions <TextServiceSettings> text_opts,
     IWebHostEnvironment env,
     IHttpContextAccessor ctx,
     ILogger <AccountsController> logger
     ) : base(repo, ctx)
 {
     this.m_userService  = userService;
     this._logger        = logger;
     this._manager       = userManager;
     this._mailer        = emailer;
     this._passwd_tokens = tokens;
     this._email_tokens  = emailTokens;
     this._env           = env;
     this._tokens        = tokenRepository;
     this._phonetokens   = phoneTokens;
     this._settings      = options.Value;
     this._text          = text;
     this.m_publisher    = publisher;
     this._text_settings = text_opts.Value;
 }
Esempio n. 10
0
 /// <summary>
 /// Instantiate a new instance of the <see cref="AuthenticationService"/> class.
 /// </summary>
 public AuthenticationService(IEventStore <Guid> eventStore, ILogger logger, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper <Guid> authenticationTokenHelper, IQueryFactory queryFactory, ICredentialRepository credentialRepository, IAuthenticationHashHelper authenticationHashHelper, ICommandPublisher <Guid> commandPublisher)
     : base(eventStore, logger, correlationIdHelper, authenticationTokenHelper)
 {
     CredentialRepository     = credentialRepository;
     QueryFactory             = queryFactory;
     AuthenticationHashHelper = authenticationHashHelper;
     CommandPublisher         = commandPublisher;
 }
 //private readonly IDbContextOptions<PolisContext> _context;
 public PolisEventListener(IDataMapper mapper, ICommandPublisher commandPublisher, IEventPublisher eventPublisher)
 {
     this.mapper       = mapper;
     _commandPublisher = commandPublisher;
     _eventPublisher   = eventPublisher;
     mapper.Print();
     //_context = context;
 }
        /// <summary>
        /// Instantiate a replay command publisher used
        /// </summary>
        public ReplayCommandPublisher(IMicroserviceReplayHost host, ICommandPublisher commandPublisher, ILoggerFactory loggerFactory = null)
        {
            loggerFactory ??= new NullLoggerFactory();

            Host             = host;
            CommandPublisher = commandPublisher;
            Logger           = loggerFactory.CreateLogger <ReplayCommandPublisher>();
        }
Esempio n. 13
0
 /// <summary>
 /// Instantiate a new instance of the <see cref="ConversationService"/> class.
 /// </summary>
 public ConversationService(IEventStore <Guid> eventStore, ILogger logger, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper <Guid> authenticationTokenHelper, IConversationSummaryRepository conversationSummaryRepository, IQueryFactory queryFactory, IMessageRepository messageRepository, ICommandPublisher <Guid> commandPublisher)
     : base(eventStore, logger, correlationIdHelper, authenticationTokenHelper)
 {
     ConversationSummaryRepository = conversationSummaryRepository;
     QueryFactory      = queryFactory;
     MessageRepository = messageRepository;
     CommandPublisher  = commandPublisher;
 }
Esempio n. 14
0
 public EventDispatcher(ReadOnlyDictionary <Type, IReadOnlyCollection <object> > domainEventHandlers,
                        ReadOnlyDictionary <Type, IReadOnlyCollection <object> > integrationEventHandlers,
                        ICommandPublisher commandPublisher)
 {
     _domainEventHandlers      = domainEventHandlers;
     _integrationEventHandlers = integrationEventHandlers;
     _commandPublisher         = commandPublisher;
 }
Esempio n. 15
0
 /// <summary>
 /// Instantiates a new instance of <see cref="SagaRepository{TAuthenticationToken}"/>
 /// </summary>
 public SagaRepository(IAggregateFactory sagaFactory, IEventStore <TAuthenticationToken> eventStore, IEventPublisher <TAuthenticationToken> publisher, ICommandPublisher <TAuthenticationToken> commandPublisher, ICorrelationIdHelper correlationIdHelper)
 {
     EventStore          = eventStore;
     Publisher           = publisher;
     CorrelationIdHelper = correlationIdHelper;
     CommandPublisher    = commandPublisher;
     SagaFactory         = sagaFactory;
 }
Esempio n. 16
0
        static async Task ImportDataIntoSystemFromFile(ICommandPublisher commandPublisher, Guid klantId, string filePath)
        {
            var lines      = File.ReadAllLines(filePath);
            var exporter   = new TextDataExporter();
            var oefeningen = exporter.ReadAllOefeningenWithPrestatiesFromLines(lines);

            var importer = new DataImporter(commandPublisher);
            await importer.ImportOefeningenIntoSystem(oefeningen.ToList(), klantId);
        }
Esempio n. 17
0
 public ConversationsController(ILogger logger, ICorrelationIdHelper correlationIdHelper, IConfigurationManager configurationManager, IAuthenticationTokenHelper <Guid> authenticationTokenHelper, IQueryFactory queryFactory, IConversationSummaryRepository conversationSummaryRepository, IMessageRepository messageRepository, IAuthenticationHelper authenticationHelper, ICommandPublisher <Guid> commandPublisher)
     : base(logger, correlationIdHelper, configurationManager, authenticationTokenHelper)
 {
     QueryFactory = queryFactory;
     ConversationSummaryRepository = conversationSummaryRepository;
     MessageRepository             = messageRepository;
     AuthenticationHelper          = authenticationHelper;
     CommandPublisher = commandPublisher;
 }
Esempio n. 18
0
 public LikesController(
     IActivitiesServiceFactory activitiesServiceFactory,
     IIntranetUserService <IIntranetUser> intranetUserService,
     ILikesService likesService,
     IContextTypeProvider contextTypeProvider,
     ICommandPublisher commandPublisher)
     : base(activitiesServiceFactory, intranetUserService, likesService, contextTypeProvider, commandPublisher)
 {
 }
 public ApiKeysController(IUserRepository users, IApiKeyRepository keys,
                          ILogger <ApiKeysController> logger,
                          ICommandPublisher publisher,
                          IHttpContextAccessor ctx) : base(users, ctx)
 {
     this._keys       = keys;
     this.m_logger    = logger;
     this.m_publisher = publisher;
 }
 public AccountController(ICommandPublisher commandPublisher,
                          ILoggerFactory loggerFactory,
                          IJwtHelper jwtHelper,
                          IKlantDataMapper klantDataMapper)
 {
     _commandPublisher = commandPublisher;
     _logger           = loggerFactory.CreateLogger <AccountController>();
     _jwtHelper        = jwtHelper;
     _klantDataMapper  = klantDataMapper;
 }
Esempio n. 21
0
 public CommentsController(
     ICommentsService commentsService,
     IIntranetUserService <IIntranetUser> intranetUserService,
     IProfileLinkProvider profileLinkProvider,
     IContextTypeProvider contextTypeProvider,
     ICommandPublisher commandPublisher,
     IActivitiesServiceFactory activitiesServiceFactory)
     : base(commentsService, intranetUserService, profileLinkProvider, contextTypeProvider, commandPublisher, activitiesServiceFactory)
 {
 }
Esempio n. 22
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AkkaSaga{TAuthenticationToken}"/>
 /// </summary>
 protected AkkaSaga(ISagaUnitOfWork <TAuthenticationToken> unitOfWork, ILogger logger, IAkkaSagaRepository <TAuthenticationToken> repository, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICommandPublisher <TAuthenticationToken> commandPublisher)
 {
     UnitOfWork                = unitOfWork;
     Logger                    = logger;
     Repository                = repository;
     CorrelationIdHelper       = correlationIdHelper;
     AuthenticationTokenHelper = authenticationTokenHelper;
     CommandPublisher          = commandPublisher;
     Changes                   = new ReadOnlyCollection <ISagaEvent <TAuthenticationToken> >(new List <ISagaEvent <TAuthenticationToken> >());
 }
Esempio n. 23
0
 public static ReactiveCommand BuildFireCommand(
     this ICommandPublisher bus,
     Func <Command> commandFunc,
     IScheduler scheduler     = null,
     string userErrorMsg      = null,
     TimeSpan?responseTimeout = null,
     TimeSpan?ackTimeout      = null)
 {
     return(FireCommands(bus, new[] { commandFunc }, null, scheduler, userErrorMsg, responseTimeout, ackTimeout));
 }
Esempio n. 24
0
 /// <summary>
 /// Creates a ReactiveCommand that will send the specified Command on the bus when executed. The ReactiveCommand's CanExecute will always be true.
 /// </summary>
 /// <param name="bus"></param>
 /// <param name="commands"></param>
 /// <param name="scheduler"></param>
 /// <param name="userErrorMsg"></param>
 /// <param name="responseTimeout"></param>
 /// <param name="ackTimeout"></param>
 /// <returns></returns>
 public static ReactiveCommand <Unit, Unit> BuildSendCommands(
     this ICommandPublisher bus,
     IEnumerable <Func <Command> > commands,
     IScheduler scheduler     = null,
     string userErrorMsg      = null,
     TimeSpan?responseTimeout = null,
     TimeSpan?ackTimeout      = null)
 {
     return(SendCommands(bus, commands, null, scheduler, userErrorMsg, responseTimeout, ackTimeout));
 }
 public TriggersController(IHttpContextAccessor ctx,
                           ISensorRepository sensors,
                           ISensorLinkRepository links,
                           ITriggerAdministrationRepository triggers,
                           ICommandPublisher publisher,
                           IApiKeyRepository keys) : base(ctx, sensors, links, keys)
 {
     this.m_triggers = triggers;
     this.m_mqtt     = publisher;
 }
Esempio n. 26
0
        public PublishService(ICommandPublisher commandPublisher, IOptions <QueueNames> options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _commandPublisher = commandPublisher ?? throw new ArgumentNullException(nameof(commandPublisher));
            _queueNames       = options.Value;
        }
Esempio n. 27
0
 public AkkaCommandBus(IBusHelper busHelper, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, IDependencyResolver dependencyResolver, ILogger logger, ICommandPublisher <TAuthenticationToken> commandPublisher, ICommandReceiver <TAuthenticationToken> commandReceiver)
 {
     Logger    = logger;
     BusHelper = busHelper;
     AuthenticationTokenHelper = authenticationTokenHelper;
     CorrelationIdHelper       = correlationIdHelper;
     DependencyResolver        = dependencyResolver;
     EventWaits       = new ConcurrentDictionary <Guid, IList <IEvent <TAuthenticationToken> > >();
     CommandPublisher = commandPublisher;
     CommandReceiver  = commandReceiver;
 }
Esempio n. 28
0
 public SqlProcessManagerDataContext(
     ProcessManagerDbContext dbContext,
     IMessageSerializer serializer,
     ICommandPublisher commandPublisher)
     : this(
         dbContext,
         serializer,
         commandPublisher,
         DefaultCommandPublisherExceptionHandler.Instance)
 {
 }
Esempio n. 29
0
 public SqlProcessManagerDataContext(
     ProcessManagerDbContext dbContext,
     IMessageSerializer serializer,
     ICommandPublisher commandPublisher,
     ICommandPublisherExceptionHandler commandPublisherExceptionHandler)
 {
     _dbContext        = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _serializer       = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _commandPublisher = commandPublisher ?? throw new ArgumentNullException(nameof(commandPublisher));
     _commandPublisherExceptionHandler = commandPublisherExceptionHandler ?? throw new ArgumentNullException(nameof(commandPublisherExceptionHandler));
 }
        public BestellingListener(IBestellingDatamapper datamapper, IKlantDatamapper klantDatamapper,
                                  ICommandPublisher commandPublisher,
                                  IEventPublisher eventPublisher)

        {
            _datamapper       = datamapper;
            _klantDatamapper  = klantDatamapper;
            _commandPublisher = commandPublisher;
            _eventPublisher   = eventPublisher;
            _logger           = NijnLogger.CreateLogger <BestellingListener>();
        }
Esempio n. 31
0
 public DeviceController(NetworkDeviceViewBuilder deviceViews, NetworkDeviceService service, ICommandPublisher publisher)
 {
     _deviceViews = deviceViews;
     _service = service;
     _publisher = publisher;
 }