Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoryCleanupJobScheduled() throws java.text.ParseException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testHistoryCleanupJobScheduled()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl standaloneInMemProcessEngineConfiguration = (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)org.camunda.bpm.engine.ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
            ProcessEngineConfigurationImpl standaloneInMemProcessEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();

            standaloneInMemProcessEngineConfiguration.HistoryCleanupBatchWindowStartTime = "23:00";
            standaloneInMemProcessEngineConfiguration.HistoryCleanupBatchWindowEndTime   = "01:00";
            standaloneInMemProcessEngineConfiguration.JdbcUrl = "jdbc:h2:mem:camunda" + this.GetType().Name + "testHistoryCleanupJobScheduled";

            ProcessEngine engine = standaloneInMemProcessEngineConfiguration.buildProcessEngine();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.camunda.bpm.engine.runtime.Job> historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
            IList <Job> historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();

            assertFalse(historyCleanupJobs.Count == 0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration = (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) engine.getProcessEngineConfiguration();
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)engine.ProcessEngineConfiguration;

            foreach (Job historyCleanupJob in historyCleanupJobs)
            {
                assertEquals(processEngineConfiguration.BatchWindowManager.getCurrentOrNextBatchWindow(ClockUtil.CurrentTime, processEngineConfiguration).Start, historyCleanupJob.Duedate);
            }

            closeProcessEngine(engine);
        }
Exemple #2
0
        public virtual ProcessEngine bootstrapEngine(string configurationResource)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(configurationResource);

            configureEngine(processEngineConfiguration);
            return(processEngineConfiguration.buildProcessEngine());
        }
Exemple #3
0
        protected internal virtual ProcessEngineImpl buildEngine(ProcessEngineConfigurationImpl engineConfiguration)
        {
            ProcessEngineImpl engine = (ProcessEngineImpl)engineConfiguration.buildProcessEngine();

            processEngines.Add(engine);

            return(engine);
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setProcessEngineScriptEnginesByDefault()
        public virtual void setProcessEngineScriptEnginesByDefault()
        {
            // given a default DMN engine configuration without script engine resolver
            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

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

            // then the DMN engine should use the script engines from the process engine
            assertEquals(processEngineConfiguration.ScriptingEngines, ConfigurationOfDmnEngine.ScriptEngineResolver);
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setProcessEngineElProviderByDefault()
        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
            assertEquals(typeof(ProcessEngineElProvider), ConfigurationOfDmnEngine.ElProvider.GetType());
        }
Exemple #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void setUp() throws Exception
            protected internal virtual void setUp()
            {
                ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/standalone/jpa/camunda.cfg.xml");

                processEngineConfiguration.JavaSerializationFormatEnabled = true;

                cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

                EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory)processEngineConfiguration.SessionFactories[typeof(EntityManagerSession)];

                entityManagerFactory = entityManagerSessionFactory.EntityManagerFactory;
            }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setDefaultInputExpressionLanguage()
        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
            assertThat(ConfigurationOfDmnEngine.DefaultInputExpressionExpressionLanguage, @is("groovy"));
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setDmnEngineConfigurationOverXmlConfiguration()
        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;

            assertThat(dmnEngineConfiguration, @is(notNullValue()));
            assertThat(dmnEngineConfiguration.DefaultInputExpressionExpressionLanguage, @is("groovy"));

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

            // then the default expression language should be set in the DMN engine
            assertThat(ConfigurationOfDmnEngine.DefaultInputExpressionExpressionLanguage, @is("groovy"));
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setElProvider()
        public virtual void setElProvider()
        {
            // given a DMN engine configuration with el provider
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            ElProvider elProvider = mock(typeof(ElProvider));

            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
            assertThat(ConfigurationOfDmnEngine.ElProvider, @is(elProvider));
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setScriptEngineResolver()
        public virtual void setScriptEngineResolver()
        {
            // given a DMN engine configuration with script engine resolver
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            DmnScriptEngineResolver       scriptEngineResolver   = mock(typeof(DmnScriptEngineResolver));

            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
            assertThat(ConfigurationOfDmnEngine.ScriptEngineResolver, @is(scriptEngineResolver));
        }
Exemple #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setFeelEngineFactory()
        public virtual void setFeelEngineFactory()
        {
            // given a DMN engine configuration with feel engine factory
            DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            FeelEngineFactory             feelEngineFactory      = mock(typeof(FeelEngineFactory));

            dmnEngineConfiguration.FeelEngineFactory = feelEngineFactory;

            ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();

            processEngineConfiguration.DmnEngineConfiguration = dmnEngineConfiguration;

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

            // then the feel engine factory should be set on the DMN engine
            assertThat(ConfigurationOfDmnEngine.FeelEngineFactory, @is(feelEngineFactory));
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBatchWindowOneDayOfWeek() throws java.text.ParseException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testBatchWindowOneDayOfWeek()
        {
            ClockUtil.CurrentTime = sdf.parse("2018-05-14T22:00:00");     //monday
            //given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl configuration = (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)org.camunda.bpm.engine.ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
            ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();

            //we have batch window only once per week - Monday afternoon
            configuration.HistoryCleanupBatchWindows[DayOfWeek.Monday] = new BatchWindowConfiguration("18:00", "20:00");
            configuration.JdbcUrl = "jdbc:h2:mem:camunda" + this.GetType().Name + "testBatchWindowOneDayOfWeek";

            //when
            //we're on Monday evening
            //and we bootstrap the engine
            ProcessEngine engine = configuration.buildProcessEngine();

            //then
            //job is scheduled for next week Monday
            IList <Job> historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();

            assertFalse(historyCleanupJobs.Count == 0);
            assertEquals(1, historyCleanupJobs.Count);
            assertEquals(sdf.parse("2018-05-21T18:00:00"), historyCleanupJobs[0].Duedate);     //monday next week
            assertEquals(false, historyCleanupJobs[0].Suspended);

            //when
            //we're on Monday evening next week, right aftre the end of batch window
            ClockUtil.CurrentTime = sdf.parse("2018-05-21T20:00:01");     //monday
            //we force history job to be rescheduled
            engine.ManagementService.executeJob(historyCleanupJobs[0].Id);

            //then
            //job is scheduled for next week Monday
            historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();
            assertFalse(historyCleanupJobs.Count == 0);
            assertEquals(1, historyCleanupJobs.Count);
            assertEquals(sdf.parse("2018-05-28T18:00:00"), historyCleanupJobs[0].Duedate);     //monday next week
            assertEquals(false, historyCleanupJobs[0].Suspended);

            closeProcessEngine(engine);
        }
Exemple #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setCustomPostTableExecutionListener()
        public virtual void setCustomPostTableExecutionListener()
        {
            // given a DMN engine configuration with custom listener
            DefaultDmnEngineConfiguration              dmnEngineConfiguration   = (DefaultDmnEngineConfiguration)DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
            DmnDecisionTableEvaluationListener         customEvaluationListener = mock(typeof(DmnDecisionTableEvaluationListener));
            IList <DmnDecisionTableEvaluationListener> customListeners          = new List <DmnDecisionTableEvaluationListener>();

            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
            assertThat(ConfigurationOfDmnEngine.CustomPostDecisionTableEvaluationListeners, hasItem(customEvaluationListener));
        }
Exemple #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBatchWindow24Hours() throws java.text.ParseException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testBatchWindow24Hours()
        {
            //given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl configuration = (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)org.camunda.bpm.engine.ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
            ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();

            //we have batch window for 24 hours
            configuration.HistoryCleanupBatchWindows[DayOfWeek.Monday] = new BatchWindowConfiguration("06:00", "06:00");
            configuration.JdbcUrl = "jdbc:h2:mem:camunda" + this.GetType().Name + "testBatchWindow24Hours";

            //when
            //we're on Monday early morning
            ClockUtil.CurrentTime = sdf.parse("2018-05-14T05:00:00");     //monday
            //and we bootstrap the engine
            ProcessEngine engine = configuration.buildProcessEngine();

            //then
            //job is scheduled for Monday 06 AM
            IList <Job> historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();

            assertFalse(historyCleanupJobs.Count == 0);
            assertEquals(1, historyCleanupJobs.Count);
            assertEquals(sdf.parse("2018-05-14T06:00:00"), historyCleanupJobs[0].Duedate);
            assertEquals(false, historyCleanupJobs[0].Suspended);

            //when
            //we're on Monday afternoon
            ClockUtil.CurrentTime = sdf.parse("2018-05-14T15:00:00");
            //we force history job to be rescheduled
            engine.ManagementService.executeJob(historyCleanupJobs[0].Id);

            //then
            //job is still within current batch window
            historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();
            assertFalse(historyCleanupJobs.Count == 0);
            assertEquals(1, historyCleanupJobs.Count);
            assertTrue(sdf.parse("2018-05-15T06:00:00").after(historyCleanupJobs[0].Duedate));
            assertEquals(false, historyCleanupJobs[0].Suspended);

            //when
            //we're on Tuesday early morning close to the end of batch window
            ClockUtil.CurrentTime = sdf.parse("2018-05-15T05:59:00");
            //we force history job to be rescheduled
            engine.ManagementService.executeJob(historyCleanupJobs[0].Id);

            //then
            //job is still within current batch window
            historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();
            assertFalse(historyCleanupJobs.Count == 0);
            assertEquals(1, historyCleanupJobs.Count);
            assertTrue(sdf.parse("2018-05-15T06:00:00").after(historyCleanupJobs[0].Duedate));
            assertEquals(false, historyCleanupJobs[0].Suspended);

            //when
            //we're on Tuesday early morning shortly after the end of batch window
            ClockUtil.CurrentTime = sdf.parse("2018-05-15T06:01:00");
            //we force history job to be rescheduled
            engine.ManagementService.executeJob(historyCleanupJobs[0].Id);

            //then
            //job is rescheduled till next Monday
            historyCleanupJobs = engine.HistoryService.findHistoryCleanupJobs();
            assertFalse(historyCleanupJobs.Count == 0);
            assertEquals(1, historyCleanupJobs.Count);
            assertEquals(sdf.parse("2018-05-21T06:00:00"), historyCleanupJobs[0].Duedate);
            assertEquals(false, historyCleanupJobs[0].Suspended);

            closeProcessEngine(engine);
        }