Пример #1
0
        public void ManualResumptionActivity_Execute_SuspensionID_IsNullOrWhiteSpace_FailWithMessage()
        {
            //------------Setup for test--------------------------
            var workflowName       = "workflowName";
            var url                = "http://localhost:3142/secure/WorkflowResume";
            var resourceId         = Guid.NewGuid();
            var nextNodeId         = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env                = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = workflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            var manualResumptionActivity = new ManualResumptionActivity(config, new Mock <IPersistenceExecution>().Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = false,
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, dataObject.Environment.AllErrors.Count);
            var errors = dataObject.Environment.AllErrors.ToList();

            Assert.AreEqual("Failed", manualResumptionActivity.Response);
            Assert.AreEqual(errors[0], "<InnerError>SuspensionID must not be null or empty.</InnerError>");
        }
Пример #2
0
        public void ManualResumptionActivity_Execute_PersistenceNotConfigured_FailWithMessage()
        {
            //------------Setup for test--------------------------
            var resourceId         = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var mockStateNotifier  = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var env = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);
            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = "workflowName",
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = "url",
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };
            var config = new PersistenceSettings
            {
                Enable = false
            };

            var manualResumptionActivity = new ManualResumptionActivity(config, new Mock <IPersistenceExecution>().Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = false,
                SuspensionId           = "321"
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, dataObject.Environment.AllErrors.Count);
            var errors = dataObject.Environment.AllErrors.ToList();

            Assert.AreEqual("Failed", manualResumptionActivity.Response);
            Assert.AreEqual(errors[0], "<InnerError>Could not find persistence config. Please configure in Persistence Settings.</InnerError>");
        }
Пример #3
0
        public void ManualResumptionActivity_Execute_OverrideInputVariables_NonVariableInput_True_Success()
        {
            //------------Setup for test--------------------------
            var activity         = CreateWorkflowNoVariable();
            var activityFunction = new ActivityFunc <string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler     = activity,
            };
            var workflowName       = "workflowName";
            var url                = "http://localhost:3142/secure/WorkflowResume";
            var resourceId         = Guid.NewGuid();
            var nextNodeId         = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env                = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "1234", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = workflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            var suspensionId           = "321";
            var overrideInputVariables = true;
            var overrideEnvironment    = env.ToJson();
            var mockResumeJob          = new Mock <IPersistenceExecution>();

            mockResumeJob.Setup(o => o.ResumeJob(dataObject, suspensionId, overrideInputVariables, overrideEnvironment)).Verifiable();
            var manualResumptionActivity = new ManualResumptionActivity(config, mockResumeJob.Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = overrideInputVariables,
                SuspensionId           = suspensionId,
                OverrideDataFunc       = activityFunction,
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, dataObject.Environment.AllErrors.Count);
            mockResumeJob.Verify(o => o.ResumeJob(dataObject, suspensionId, overrideInputVariables, overrideEnvironment), Times.Once);
        }
Пример #4
0
        public void ManualResumptionActivity_Execute_OverrideInputVariables_ResumeInputVarNames_Equals_SuspendJsonInput()
        {
            //------------Setup for test--------------------------
            var activity         = CreateWorkflow();
            var activityFunction = new ActivityFunc <string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler     = activity,
            };
            const string WorkflowName       = "workflowName";
            const string Url                = "http://localhost:3142/secure/WorkflowResume";
            var          resourceId         = Guid.NewGuid();
            var          nextNodeId         = Guid.NewGuid();
            var          workflowInstanceId = Guid.NewGuid();

            const string ExpectedEnv = "{\"Environment\":{\"scalars\":{\"Input1\":\"ResumeInput1\",\"Input2\":\"ResumeInput2\",\"SuspendId\":966},\"record_sets\":{},\"json_objects\":{\"obj\":{\"x\":\"4\",\"y\":\"5\",\"z\":\"6\"}}},\"Errors\":[],\"AllErrors\":[]}";

            var overrideEnv = CreateExecutionEnvironment();

            overrideEnv.FromJson(ExpectedEnv);

            var          startActivityId     = Guid.NewGuid();
            const string SuspendedEnv        = "{\"Environment\":{\"scalars\":{\"Input1\":\"Input1\",\"Input2\":\"Input2\"},\"record_sets\":{},\"json_objects\":{\"obj\":{\"x\":\"1\",\"y\":\"2\",\"z\":\"3\"}}},\"Errors\":[],\"AllErrors\":[]}";
            var          mockPersistedValues = new Mock <IPersistedValues>();

            mockPersistedValues.Setup(o => o.SuspendedEnvironment).Returns(SuspendedEnv);
            mockPersistedValues.Setup(o => o.StartActivityId).Returns(startActivityId);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = WorkflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = Url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = overrideEnv,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            const string SuspensionId           = "321";
            const bool   OverrideInputVariables = true;

            var resumeObject = dataObject;

            resumeObject.StartActivityId = startActivityId;
            resumeObject.Environment     = dataObject.Environment;

            var mockResumeJob           = new Mock <IPersistenceExecution>();
            var mockExecutionLogPublish = new Mock <IExecutionLogPublisher>();

            mockResumeJob.Setup(o => o.ResumeJob(dataObject, SuspensionId, OverrideInputVariables, SuspendedEnv)).Verifiable();
            mockResumeJob.Setup(o => o.GetPersistedValues(SuspensionId)).Returns(mockPersistedValues.Object).Verifiable();
            mockResumeJob.Setup(o => o.ManualResumeWithOverrideJob(resumeObject, SuspensionId)).Returns(startActivityId.ToString()).Verifiable();
            var manualResumptionActivity = new ManualResumptionActivity(config, mockResumeJob.Object, mockExecutionLogPublish.Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = OverrideInputVariables,
                SuspensionId           = SuspensionId,
                OverrideDataFunc       = activityFunction,
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, dataObject.Environment.AllErrors.Count);
            Assert.AreNotEqual(overrideEnv.ToJson(), SuspendedEnv);
            Assert.AreEqual(overrideEnv.ToJson(), ExpectedEnv);
        }
Пример #5
0
        public void ManualResumptionActivity_Execute_GetSuspendedEnvironment_Error_ManualResumptionSuspensionEnvBlank()
        {
            //------------Setup for test--------------------------
            const string WorkflowName       = "workflowName";
            const string Url                = "http://localhost:3142/secure/WorkflowResume";
            var          resourceId         = Guid.NewGuid();
            var          nextNodeId         = Guid.NewGuid();
            var          workflowInstanceId = Guid.NewGuid();
            var          env                = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = WorkflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = Url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            const string SuspensionId = "321";

            var mockResumeJob           = new Mock <IPersistenceExecution>();
            var mockExecutionLogPublish = new Mock <IExecutionLogPublisher>();

            mockResumeJob.Setup(o => o.GetPersistedValues(SuspensionId)).Returns(new Mock <IPersistedValues>().Object).Verifiable();
            var manualResumptionActivity = new ManualResumptionActivity(config, mockResumeJob.Object, mockExecutionLogPublish.Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = true,
                SuspensionId           = SuspensionId
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, env.AllErrors.Count);
            Assert.AreEqual(ErrorResource.ManualResumptionSuspensionEnvBlank, env.AllErrors.First());
            Assert.AreEqual("", manualResumptionActivity.Response);
            mockResumeJob.Verify(o => o.GetPersistedValues(SuspensionId), Times.Once);
        }
Пример #6
0
        public void ManualResumptionActivity_Execute_OverrideInputVariables_InnerActivity_True_Success()
        {
            //------------Setup for test--------------------------
            var activity         = CreateSequenceActivity();
            var activityFunction = new ActivityFunc <string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler     = activity,
            };
            const string WorkflowName       = "workflowName";
            const string Url                = "http://localhost:3142/secure/WorkflowResume";
            var          resourceId         = Guid.NewGuid();
            var          nextNodeId         = Guid.NewGuid();
            var          workflowInstanceId = Guid.NewGuid();
            var          env                = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = WorkflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = Url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            const string SuspensionId           = "321";
            const bool   OverrideInputVariables = true;
            var          environment            = env.ToJson();
            var          startActivityId        = Guid.NewGuid();

            var mockPersistedValues = new Mock <IPersistedValues>();

            mockPersistedValues.Setup(o => o.SuspendedEnvironment).Returns(environment);
            mockPersistedValues.Setup(o => o.StartActivityId).Returns(startActivityId);

            var mockResumeJob           = new Mock <IPersistenceExecution>();
            var mockExecutionLogPublish = new Mock <IExecutionLogPublisher>();

            mockResumeJob.Setup(o => o.ResumeJob(dataObject, SuspensionId, OverrideInputVariables, environment)).Verifiable();
            mockResumeJob.Setup(o => o.GetPersistedValues(SuspensionId)).Returns(mockPersistedValues.Object).Verifiable();
            mockResumeJob.Setup(o => o.ManualResumeWithOverrideJob(It.IsAny <IDSFDataObject>(), SuspensionId)).Returns(GlobalConstants.Success).Verifiable();
            var manualResumptionActivity = new ManualResumptionActivity(config, mockResumeJob.Object, mockExecutionLogPublish.Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = OverrideInputVariables,
                SuspensionId           = SuspensionId,
                OverrideDataFunc       = activityFunction,
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(GlobalConstants.Success, manualResumptionActivity.Response);
            mockResumeJob.Verify(o => o.ResumeJob(dataObject, SuspensionId, OverrideInputVariables, environment), Times.Never);
            mockResumeJob.Verify(o => o.GetPersistedValues(SuspensionId), Times.Once);
            mockResumeJob.Verify(o => o.ManualResumeWithOverrideJob(It.IsAny <IDSFDataObject>(), SuspensionId), Times.Once);
        }