Esempio n. 1
0
        public async Task ShouldSendRequestWithFetchVariablesAsList()
        {
            // given
            var expectedRequest = new CreateProcessInstanceWithResultRequest
            {
                Request = new CreateProcessInstanceRequest
                {
                    BpmnProcessId = "process",
                    Version       = -1,
                    Variables     = "{\"foo\":1}"
                },
                RequestTimeout = 20 * 1000,
                FetchVariables = { "foo", "bar" }
            };

            // when
            await ZeebeClient.NewCreateProcessInstanceCommand()
            .BpmnProcessId("process")
            .LatestVersion()
            .Variables("{\"foo\":1}")
            .WithResult()
            .FetchVariables(new List <string> {
                "foo", "bar"
            })
            .Send();

            // then
            var request = TestService.Requests[typeof(CreateProcessInstanceWithResultRequest)][0];

            Assert.AreEqual(expectedRequest, request);
        }
Esempio n. 2
0
        public async Task ShouldSendRequestWithVersionAsExpected()
        {
            // given
            var expectedRequest = new CreateProcessInstanceWithResultRequest
            {
                Request = new CreateProcessInstanceRequest
                {
                    BpmnProcessId = "process",
                    Version       = 1
                },
                RequestTimeout = 20 * 1000
            };

            // when
            await ZeebeClient.NewCreateProcessInstanceCommand()
            .BpmnProcessId("process")
            .Version(1)
            .WithResult()
            .Send();

            // then
            var request = TestService.Requests[typeof(CreateProcessInstanceWithResultRequest)][0];

            Assert.AreEqual(expectedRequest, request);
        }
Esempio n. 3
0
        public async Task ShouldReceiveResponseAsExpected()
        {
            // given
            var expectedResponse = new CreateProcessInstanceWithResultResponse
            {
                BpmnProcessId        = "process",
                Version              = 1,
                ProcessDefinitionKey = 2,
                ProcessInstanceKey   = 121,
                Variables            = "{\"foo\":\"bar\"}",
            };

            TestService.AddRequestHandler(typeof(CreateProcessInstanceWithResultRequest), request => expectedResponse);

            // when
            var processInstanceResponse = await ZeebeClient.NewCreateProcessInstanceCommand()
                                          .BpmnProcessId("process")
                                          .LatestVersion()
                                          .WithResult()
                                          .Send();

            // then
            Assert.AreEqual(2, processInstanceResponse.ProcessDefinitionKey);
            Assert.AreEqual(1, processInstanceResponse.Version);
            Assert.AreEqual(121, processInstanceResponse.ProcessInstanceKey);
            Assert.AreEqual("process", processInstanceResponse.BpmnProcessId);
            Assert.AreEqual("{\"foo\":\"bar\"}", processInstanceResponse.Variables);
        }
Esempio n. 4
0
        public async Task ShouldSendRequestWithVariablesAsExpected()
        {
            // given
            var expectedRequest = new CreateProcessInstanceWithResultRequest
            {
                Request = new CreateProcessInstanceRequest
                {
                    ProcessDefinitionKey = 1,
                    Variables            = "{\"foo\":1}"
                },
                RequestTimeout = 20 * 1000
            };

            // when
            await ZeebeClient.NewCreateProcessInstanceCommand()
            .ProcessDefinitionKey(1)
            .Variables("{\"foo\":1}")
            .WithResult()
            .Send();

            // then
            var request = TestService.Requests[typeof(CreateProcessInstanceWithResultRequest)][0];

            Assert.AreEqual(expectedRequest, request);
        }
        public void ShouldCancelRequest()
        {
            // given

            // when
            var task = ZeebeClient.NewCreateProcessInstanceCommand()
                       .BpmnProcessId("process")
                       .LatestVersion()
                       .Send(new CancellationTokenSource(TimeSpan.Zero).Token);
            var aggregateException = Assert.Throws <AggregateException>(() => task.Wait());
            var rpcException       = (RpcException)aggregateException.InnerExceptions[0];

            // then
            Assert.AreEqual(Grpc.Core.StatusCode.Cancelled, rpcException.Status.StatusCode);
        }
        public async Task ShouldSendRequestWithProcessDefinitionKeyAsExpected()
        {
            // given
            var expectedRequest = new CreateProcessInstanceRequest
            {
                ProcessDefinitionKey = 1
            };

            // when
            await ZeebeClient.NewCreateProcessInstanceCommand()
            .ProcessDefinitionKey(1)
            .Send();

            // then
            var request = TestService.Requests[typeof(CreateProcessInstanceRequest)][0];

            Assert.AreEqual(expectedRequest, request);
        }
        public async Task ShouldSendRequestAsExpected()
        {
            // given
            var expectedRequest = new CreateProcessInstanceRequest
            {
                BpmnProcessId = "process",
                Version       = -1
            };

            // when
            await ZeebeClient.NewCreateProcessInstanceCommand()
            .BpmnProcessId("process")
            .LatestVersion()
            .Send();

            // then
            var request = TestService.Requests[typeof(CreateProcessInstanceRequest)][0];

            Assert.AreEqual(expectedRequest, request);
        }
Esempio n. 8
0
        public void ShouldCancelRequest()
        {
            // given
            TestService.AddRequestHandler(typeof(CreateProcessInstanceWithResultRequest),
                                          request =>
            {
                new EventWaitHandle(false, EventResetMode.AutoReset).WaitOne();
                return(null);
            });

            // when
            var task = ZeebeClient.NewCreateProcessInstanceCommand()
                       .BpmnProcessId("process")
                       .LatestVersion()
                       .WithResult()
                       .Send(new CancellationTokenSource(TimeSpan.Zero).Token);
            var aggregateException = Assert.Throws <AggregateException>(() => task.Wait(TimeSpan.FromSeconds(15)));
            var rpcException       = (RpcException)aggregateException.InnerExceptions[0];

            // then
            Assert.AreEqual(Grpc.Core.StatusCode.Cancelled, rpcException.Status.StatusCode);
        }
Esempio n. 9
0
        public async Task ShouldSendRequestWithRequestTimeoutAsExpected()
        {
            // given
            var expectedRequest = new CreateProcessInstanceWithResultRequest
            {
                Request = new CreateProcessInstanceRequest
                {
                    ProcessDefinitionKey = 1
                },
                RequestTimeout = 123 * 1000
            };

            // when
            await ZeebeClient.NewCreateProcessInstanceCommand()
            .ProcessDefinitionKey(1)
            .WithResult()
            .Send(TimeSpan.FromSeconds(123));

            // then
            var request = TestService.Requests[typeof(CreateProcessInstanceWithResultRequest)][0];

            Assert.AreEqual(expectedRequest, request);
        }