public WorkflowContext(IRuntimeWorkflowEngine workflowEngine, WorkflowEngineBuilder workflowEngineBuilder,
                        IWorkflowInstance workflowInstance, WorkflowConfiguration workflowConfiguration, JsonState workflowExecutionState)
 {
     _workflowEngineBuilder = workflowEngineBuilder;
     WorkflowEngine         = workflowEngine;
     WorkflowInstance       = workflowInstance;
     WorkflowConfiguration  = workflowConfiguration;
     WorkflowExecutionState = workflowExecutionState ?? new JsonState();
 }
 public WorkflowEngine(WorkflowEngineBuilder workflowEngineBuilder)
 {
     Id = Guid.NewGuid();
     WorkflowEngineBuilder    = workflowEngineBuilder;
     _messageProcessorLazy    = new Lazy <IMessageProcessor>(() => new MessageProcessor(this), LazyThreadSafetyMode.ExecutionAndPublication);
     _eventProcessorLazy      = new Lazy <IEventProcessor>(() => new EventProcessor(this), LazyThreadSafetyMode.ExecutionAndPublication);
     _stateProcessorLazy      = new Lazy <IStateProcessor>(() => new StateProcessor(this), LazyThreadSafetyMode.ExecutionAndPublication);
     _transitionProcessorLazy = new Lazy <ITransitionProcessor>(() => new TransitionProcessor(this), LazyThreadSafetyMode.ExecutionAndPublication);
 }
Example #3
0
        public IWorkflowEngine CreateWorkflowEngine()
        {
            var workflowStore         = _workflowStoreFactory.Create();
            var workflowEngineBuilder = new WorkflowEngineBuilder();

            workflowEngineBuilder
            .WithActivityFactory(_activityFactory)
            .WithEventHandlerFactory(_eventHandlerFactory)
            .WithDomainStore(_workflowDomainStore)
            .WithMessageTransportFactoryProvider(_workflowMessageTransportFactoryProvider)
            .WithWorkflowRuntimeConfigurationFactory(_workflowRuntimeConfigurationFactory)
            .WithWorkflowStore(workflowStore);
            return(new WorkflowEngine(workflowEngineBuilder));
        }
        public void SetUp()
        {
            _workflowInstance                        = new Mock <IWorkflowInstance>();
            _runtimeWorkflowEngine                   = new Mock <IRuntimeWorkflowEngine>();
            _endpointConfiguration                   = new Mock <IEndpointConfiguration>();
            _workflowMessageTransport                = new Mock <IWorkflowMessageTransport>();
            _workflowMessageTransportFactory         = new Mock <IWorkflowMessageTransportFactory>();
            _workflowMessageTransportFactoryProvider = new Mock <IWorkflowMessageTransportFactoryProvider>();
            _workflowEngineBuilder                   = new WorkflowEngineBuilder().WithMessageTransportFactoryProvider(_workflowMessageTransportFactoryProvider.Object);

            _endpointConfiguration.Setup(f => f.Code).Returns("rabbit.mq");
            _endpointConfiguration.Setup(f => f.Address).Returns(new Uri("rabbitmq://localhost/address"));

            var workflowId = Guid.NewGuid();

            _workflowInstance.Setup(f => f.Id).Returns(workflowId);
            _workflowConfiguration = new WorkflowConfiguration(workflowId, "unit.test", "unit.test", "Unit Test", new Version(0, 0, 1))
            {
                RuntimeConfiguration = new WorkflowRuntimeConfiguration(workflowId, "unit.test", "unit.test")
                {
                    EndpointConfiguration  = _endpointConfiguration.Object,
                    EndpointConfigurations = new[] { new KeyValuePair <string, IEndpointConfiguration>("remote.*", _endpointConfiguration.Object) }
                }
            };

            _eventResponseWorkflowMessage = new EventResponseWorkflowMessage {
                EventExecutionResult = new EventExecutionResult(EventExecutionStatus.Completed)
            };
            _workflowMessageTransport
            .Setup(f => f.Request <IEventRequestWorkflowMessage, IEventResponseWorkflowMessage>(
                       It.IsAny <IEndpointConfiguration>(), It.IsAny <IEventRequestWorkflowMessage>(), It.IsAny <CancellationToken>()))
            .Returns <IEndpointConfiguration, IWorkflowMessage, CancellationToken>((epc, wm, ct) => Task.FromResult(_eventResponseWorkflowMessage));

            _workflowMessageTransportFactoryProvider
            .Setup(f => f.CreateMessageTransportFactory(It.IsAny <EndpointConfigurationType>()))
            .Returns <EndpointConfigurationType>(uri => _workflowMessageTransportFactory.Object);

            _workflowMessageTransportFactory
            .Setup(f => f.CreateMessageTransport(It.IsAny <Uri>()))
            .Returns <Uri>(uri => _workflowMessageTransport.Object);

            _event                 = new StatefulEvent("remote.{sign-event01}", workflowId, new JsonState());
            _workflowContext       = new WorkflowContext(_runtimeWorkflowEngine.Object, _workflowEngineBuilder, _workflowInstance.Object, _workflowConfiguration);
            _eventExecutionContext = new EventExecutionContext(_workflowContext, _event,
                                                               new EventConfiguration(EventTypeConfiguration.Application, _event.Code, string.Empty),
                                                               new StateEventConfiguration());
        }
        public void Setup()
        {
            _workflowInstance                        = new Mock <IWorkflowInstance>();
            _runtimeWorkflowEngine                   = new Mock <IRuntimeWorkflowEngine>();
            _endpointConfiguration                   = new Mock <IEndpointConfiguration>();
            _workflowMessageTransport                = new Mock <IWorkflowMessageTransport>();
            _workflowMessageTransportFactory         = new Mock <IWorkflowMessageTransportFactory>();
            _workflowMessageTransportFactoryProvider = new Mock <IWorkflowMessageTransportFactoryProvider>();
            _workflowEngineBuilder                   = new WorkflowEngineBuilder().WithMessageTransportFactoryProvider(_workflowMessageTransportFactoryProvider.Object);

            _endpointConfiguration.Setup(f => f.Code).Returns("activity");
            _endpointConfiguration.Setup(f => f.Address).Returns(new Uri("rabbitmq://localhost/Diadem.Workflow.Core.Model:IActivityRequestWorkflowMessage"));

            var workflowId = Guid.NewGuid();

            _workflowInstance.Setup(f => f.Id).Returns(workflowId);
            _workflowConfiguration = new WorkflowConfiguration(workflowId, "unit.test", "unit.test", "Unit Test", new Version(0, 0, 1))
            {
                RuntimeConfiguration = new WorkflowRuntimeConfiguration(workflowId, "unit.test", "unit.test")
                {
                    EndpointConfiguration  = _endpointConfiguration.Object,
                    EndpointConfigurations = new[] { new KeyValuePair <string, IEndpointConfiguration>("remote.activity.*", _endpointConfiguration.Object) }
                }
            };

            _activityResponseWorkflowMessage = new ActivityResponseWorkflowMessage {
                ActivityExecutionResult = new ActivityExecutionResult(ActivityExecutionStatus.Completed)
            };
            _workflowMessageTransport
            .Setup(f => f.Request <IActivityRequestWorkflowMessage, IActivityResponseWorkflowMessage>(
                       It.IsAny <IEndpointConfiguration>(), It.IsAny <IActivityRequestWorkflowMessage>(), It.IsAny <CancellationToken>()))
            .Returns <IEndpointConfiguration, IActivityRequestWorkflowMessage, CancellationToken>((epc, wm, ct) => Task.FromResult(_activityResponseWorkflowMessage));

            _workflowMessageTransportFactoryProvider
            .Setup(f => f.CreateMessageTransportFactory(It.IsAny <EndpointConfigurationType>()))
            .Returns <EndpointConfigurationType>(uri => _workflowMessageTransportFactory.Object);

            _workflowMessageTransportFactory
            .Setup(f => f.CreateMessageTransport(It.IsAny <Uri>()))
            .Returns <Uri>(uri => _workflowMessageTransport.Object);

            _workflowContext          = new WorkflowContext(_runtimeWorkflowEngine.Object, _workflowEngineBuilder, _workflowInstance.Object, _workflowConfiguration);
            _stateExecutionContext    = new StateExecutionContext(_workflowContext, new StateConfiguration());
            _activityExecutionContext = new ActivityExecutionContext(_stateExecutionContext, new ActivityConfiguration());
        }
Example #6
0
        protected WorkflowEngineBuildResult BuildWorkflowEngine(bool mockWorkflowStore, bool nested, IActivity activity, ICodeEventHandler eventHandler)
        {
            var activityFactoryMock = BuildActivityFactory(activity);
            var eventHandlerFactory = BuildEventHandlerFactory(eventHandler);
            var domainStore         = BuildDomainStore(nested);
            var workflowStore       = BuildWorkflowStore(mockWorkflowStore, nested);
            var workflowMessageBus  = BuildWorkflowMessageTransportFactoryProvider();
            var workflowRuntimeConfigurationFactory = BuildWorkflowRuntimeConfigurationFactory();

            var workflowEngineBuilder = new WorkflowEngineBuilder();

            workflowEngineBuilder
            .WithActivityFactory(activityFactoryMock)
            .WithEventHandlerFactory(eventHandlerFactory)
            .WithDomainStore(domainStore)
            .WithMessageTransportFactoryProvider(workflowMessageBus)
            .WithWorkflowRuntimeConfigurationFactory(workflowRuntimeConfigurationFactory)
            .WithWorkflowStore(workflowStore);
            return(new WorkflowEngineBuildResult(workflowEngineBuilder, new WorkflowEngine(workflowEngineBuilder)));
        }
Example #7
0
 public WorkflowEngineBuildResult(WorkflowEngineBuilder workflowEngineBuilder, IWorkflowEngine workflowEngine)
 {
     WorkflowEngineBuilder = workflowEngineBuilder;
     WorkflowEngine        = workflowEngine;
 }