Example #1
0
        public virtual void testBuiltinFunctionMapperRegistration()
        {
            // given a process engine configuration with a custom function mapper
            ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.CreateStandaloneInMemProcessEngineConfiguration().SetJdbcUrl("jdbc:h2:mem:camunda" + this.GetType().Name);

            CustomExpressionManager customExpressionManager = new CustomExpressionManager();

            Assert.True(customExpressionManager.FunctionMappers.Count == 0);
            config.ExpressionManager = customExpressionManager;

            // when the engine is initialized
            engine = config.BuildProcessEngine();

            // then two default function mappers should be registered
            Assert.AreSame(customExpressionManager, config.ExpressionManager);
            Assert.AreEqual(2, customExpressionManager.FunctionMappers.Count);

            bool commandContextMapperFound = false;
            bool dateTimeMapperFound       = false;

            foreach (FunctionMapper functionMapper in customExpressionManager.FunctionMappers)
            {
                if (functionMapper is CommandContextFunctionMapper)
                {
                    commandContextMapperFound = true;
                }

                if (functionMapper is DateTimeFunctionMapper)
                {
                    dateTimeMapperFound = true;
                }
            }

            Assert.True(commandContextMapperFound && dateTimeMapperFound);
        }
Example #2
0
        public virtual void testFallbackSerializerDoesNotOverrideRegularSerializer()
        {
            // given
            // that the process engine is configured with a serializer for a certain format
            // and a fallback serializer factory for the same format
            ProcessEngineConfigurationImpl engineConfiguration = (new StandaloneInMemProcessEngineConfiguration()).SetJdbcUrl("jdbc:h2:mem:camunda-forceclose").SetProcessEngineName("engine-forceclose") as ProcessEngineConfigurationImpl;

            // Todo: ProcessEngineConfigurationImpl.CustomPreVariableSerializers
            //engineConfiguration.CustomPreVariableSerializers = new (new ExampleConstantSerializer());
            engineConfiguration.FallbackSerializerFactory = new ExampleSerializerFactory();

            processEngine = engineConfiguration.BuildProcessEngine();
            deployOneTaskProcess(processEngine);

            // Todo: ExampleSerializer
            // when setting a variable that no regular serializer can handle
            //IObjectValue objectValue = Engine.Variable.Variables.ObjectValue("foo").SerializationDataFormat(ExampleSerializer.FORMAT).Create();

            //IProcessInstance pi = processEngine.RuntimeService.StartProcessInstanceByKey("oneTaskProcess", Engine.Variable.Variables.CreateVariables().PutValueTyped("var", objectValue));

            //IObjectValue fetchedValue = processEngine.RuntimeService.GetVariableTyped<IObjectValue>(pi.Id, "var", true);

            // then the fallback serializer is used
            //Assert.NotNull(fetchedValue);
            // Todo: ExampleSerializer
            //Assert.AreEqual(ExampleSerializer.FORMAT, fetchedValue.SerializationDataFormat);
            //Assert.AreEqual(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.Value);
        }
        public virtual IProcessEngine BootstrapEngine(string configurationResource)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.CreateProcessEngineConfigurationFromResource(configurationResource);

            ConfigureEngine(processEngineConfiguration);
            return(processEngineConfiguration.BuildProcessEngine());
        }
        protected internal virtual ProcessEngineImpl buildEngine(ProcessEngineConfigurationImpl engineConfiguration)
        {
            ProcessEngineImpl engine = (ProcessEngineImpl)engineConfiguration.BuildProcessEngine();

            processEngines.Add(engine);

            return(engine);
        }
        public virtual void setProcessEngineElProviderByDefault()
        {
            // given a default DMN engine configuration without el provider
            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

            // when the engine is initialized
            engine = processEngineConfiguration.BuildProcessEngine();

            // then the DMN engine should use the process engine el provider
            Assert.AreEqual(typeof(ProcessEngineElProvider), ConfigurationOfDmnEngine.ElProvider.GetType());
        }
        public virtual void ReadLevelFullfromDb()
        {
            ProcessEngineConfigurationImpl config = Config("true", ProcessEngineConfiguration.HistoryFull);

            // init the db with level=full
            _processEngineImpl = (ProcessEngineImpl)config.BuildProcessEngine();

            var historyLevel =
                config.CommandExecutorSchemaOperations.Execute(new DetermineHistoryLevelCmd(config.HistoryLevels));

            Assert.That(historyLevel, Is.EqualTo(HistoryLevelFields.HistoryLevelFull));
        }
        public virtual void UseDefaultLevelAudit()
        {
            ProcessEngineConfigurationImpl config = Config("true", ProcessEngineConfiguration.HistoryAuto);

            // init the db with level=auto -> audit
            _processEngineImpl = (ProcessEngineImpl)config.BuildProcessEngine();
            // the history Level has been overwritten with audit
            Assert.That(config.HistoryLevel, Is.EqualTo(HistoryLevelFields.HistoryLevelAudit));

            // and this is written to the database
            var databaseLevel =
                config.CommandExecutorSchemaOperations.Execute(new DetermineHistoryLevelCmd(config.HistoryLevels));

            Assert.That(databaseLevel, Is.EqualTo(HistoryLevelFields.HistoryLevelAudit));
        }
        public virtual void FailWhenExistingHistoryLevelIsNotRegistered()
        {
            // init the db with custom level
            IHistoryLevel customLevel             = new HistoryLevelAnonymousInnerClass(this);
            ProcessEngineConfigurationImpl config = Config("true", "custom");

            config.SetCustomHistoryLevels(new List <IHistoryLevel> {
                customLevel
            });
            _processEngineImpl = (ProcessEngineImpl)config.BuildProcessEngine();

            //Thrown.Expect(typeof(ProcessEngineException));
            //Thrown.ExpectMessage("The configured history level with id='99' is not registered in this config.");

            config.CommandExecutorSchemaOperations.Execute(new DetermineHistoryLevelCmd(new List <IHistoryLevel>()));
        }
        public virtual void setDefaultInputExpressionLanguage()
        {
            // given a DMN engine configuration with default expression language
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();

            dmnEngineConfiguration.DefaultInputExpressionExpressionLanguage = "groovy";

            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

            processEngineConfiguration.DmnEngineConfiguration = dmnEngineConfiguration;

            // when the engine is initialized
            engine = processEngineConfiguration.BuildProcessEngine();

            // then the default expression language should be set on the DMN engine
            Assert.That(ConfigurationOfDmnEngine.DefaultInputExpressionExpressionLanguage, Is.EqualTo("groovy"));
        }
        public virtual void setDmnEngineConfigurationOverXmlConfiguration()
        {
            // given an embedded DMN engine configuration in XML process engine configuration
            // with default expression language
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.CreateProcessEngineConfigurationFromResource(CONFIGURATION_XML);

            // checks that the configuration is set as on XML
            DefaultDmnEngineConfiguration dmnEngineConfiguration = processEngineConfiguration.DmnEngineConfiguration;

            //Assert.That(dmnEngineConfiguration, Is.EqualTo(notNullValue()));
            Assert.That(dmnEngineConfiguration, Is.Not.Null);
            Assert.That(dmnEngineConfiguration.DefaultInputExpressionExpressionLanguage, Is.EqualTo("groovy"));

            // when the engine is initialized
            engine = processEngineConfiguration.BuildProcessEngine();

            // then the default expression language should be set in the DMN engine
            Assert.That(ConfigurationOfDmnEngine.DefaultInputExpressionExpressionLanguage, Is.EqualTo("groovy"));
        }
        public virtual void setScriptEngineResolver()
        {
            // given a DMN engine configuration with script engine resolver
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            // Todo: mockito-core-1.9.5.jar
            //DmnScriptEngineResolver scriptEngineResolver = mock(typeof(DmnScriptEngineResolver));
            IDmnScriptEngineResolver scriptEngineResolver = null;

            dmnEngineConfiguration.ScriptEngineResolver = scriptEngineResolver;

            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

            processEngineConfiguration.DmnEngineConfiguration = dmnEngineConfiguration;

            // when the engine is initialized
            engine = processEngineConfiguration.BuildProcessEngine();

            // then the script engine resolver should be set on the DMN engine
            Assert.That(ConfigurationOfDmnEngine.ScriptEngineResolver, Is.EqualTo(scriptEngineResolver));
        }
        public virtual void setElProvider()
        {
            // given a DMN engine configuration with el provider
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            // Todo: mockito-core-1.9.5.jar
            //ElProvider elProvider = mock(typeof(ElProvider));
            IELProvider elProvider = null;

            dmnEngineConfiguration.ElProvider = elProvider;

            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

            processEngineConfiguration.DmnEngineConfiguration = dmnEngineConfiguration;

            // when the engine is initialized
            engine = processEngineConfiguration.BuildProcessEngine();

            // then the el provider should be set on the DMN engine
            Assert.That(ConfigurationOfDmnEngine.ElProvider, Is.EqualTo(elProvider));
        }
        public virtual void setCustomPostTableExecutionListener()
        {
            // given a DMN engine configuration with custom listener
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            // Todo: mockito-core-1.9.5.jar
            //DmnDecisionTableEvaluationListener customEvaluationListener = mock(typeof(DmnDecisionTableEvaluationListener));
            IDmnDecisionTableEvaluationListener         customEvaluationListener = null;
            IList <IDmnDecisionTableEvaluationListener> customListeners          = new List <IDmnDecisionTableEvaluationListener>();

            customListeners.Add(customEvaluationListener);
            dmnEngineConfiguration.CustomPostDecisionTableEvaluationListeners = customListeners;

            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

            processEngineConfiguration.DmnEngineConfiguration = dmnEngineConfiguration;

            // when the engine is initialized
            engine = processEngineConfiguration.BuildProcessEngine();

            // then the custom listener should be set on the DMN engine
            //Assert.That(ConfigurationOfDmnEngine.CustomPostDecisionTableEvaluationListeners, hasItem(customEvaluationListener));
            CollectionAssert.Contains(ConfigurationOfDmnEngine.CustomPostDecisionTableEvaluationListeners,
                                      customEvaluationListener);
        }
Example #14
0
        protected internal virtual ProcessEngineConfigurationImpl buildProcessEngine(ProcessEngineConfigurationImpl config)
        {
            processEngine = config.BuildProcessEngine();

            return((ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration);
        }