.getCommandExecutorSchemaOperations() .execute(new Command<Object>() { public Object execute(CommandContext commandContext) {
@Test public void readLevelFullfromDB() throws Exception { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_FULL); // init the db with level=full processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); HistoryLevel historyLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(historyLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_FULL)); }
@Test public void useDefaultLevelAudit() throws Exception { ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); // init the db with level=auto -> audit processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); // the history Level has been overwritten with audit assertThat(config.getHistoryLevel(), CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); // and this is written to the database HistoryLevel databaseLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(databaseLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }
@Test public void usesDefaultValueAuditWhenNoValueIsConfigured() { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); ProcessEngineImpl processEngine = buildEngine(config); final Integer level = config.getCommandExecutorSchemaOperations().execute(new Command<Integer>() { @Override public Integer execute(CommandContext commandContext) { return HistoryLevelSetupCommand.databaseHistoryLevel(commandContext); } }); assertThat(level, equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT.getId())); assertThat(processEngine.getProcessEngineConfiguration().getHistoryLevel(), equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }
@Test public void schemaCreatedByUserAndDatabaseSchemaUpdateFalse() { processEngineImpl = createProcessEngineImpl("false", false); // simulate manual schema creation by user TestHelper.createSchema(processEngineImpl.getProcessEngineConfiguration()); // let the engine do their schema operations thing processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new SchemaOperationsProcessEngineBuild()); processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new HistoryLevelSetupCommand()); assertHistoryLevel(); }
@Test public void schemaCreatedByUserAndDatabaseSchemaUpdateTrue() { processEngineImpl = createProcessEngineImpl("true", false); // simulate manual schema creation by user TestHelper.createSchema(processEngineImpl.getProcessEngineConfiguration()); // let the engine do their schema operations thing processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new SchemaOperationsProcessEngineBuild()); processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new HistoryLevelSetupCommand()); assertHistoryLevel(); }
@Bean public CommandExecutor commandExecutorSchemaOperations() { return processEngineConfigurationImpl.getCommandExecutorSchemaOperations(); } }
@Bean public CommandExecutor commandExecutorSchemaOperations() { return processEngineConfigurationImpl.getCommandExecutorSchemaOperations(); } }
@Test public void failWhenExistingHistoryLevelIsNotRegistered() { // init the db with custom level HistoryLevel customLevel = new HistoryLevel() { @Override public int getId() { return 99; } @Override public String getName() { return "custom"; } @Override public boolean isHistoryEventProduced(HistoryEventType eventType, Object entity) { return false; } }; ProcessEngineConfigurationImpl config = config("true", "custom"); config.setCustomHistoryLevels(Arrays.asList(customLevel)); processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); thrown.expect(ProcessEngineException.class); thrown.expectMessage("The configured history level with id='99' is not registered in this config."); config.getCommandExecutorSchemaOperations().execute( new DetermineHistoryLevelCmd(Collections.<HistoryLevel>emptyList())); }
@Test public void disabledDmn() { processEngineImpl = createProcessEngineImpl(false); // simulate manual schema creation by user TestHelper.createSchema(processEngineImpl.getProcessEngineConfiguration()); // let the engine do their schema operations thing processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new SchemaOperationsProcessEngineBuild()); }
/** * @return a command executor for the processEngine */ public CommandExecutor getCommandExecutor() { return ((ProcessEngineImpl) getProcessEngine()).getProcessEngineConfiguration().getCommandExecutorSchemaOperations(); }
this.jobExecutor = processEngineConfiguration.getJobExecutor(); this.commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired(); commandExecutorSchemaOperations = processEngineConfiguration.getCommandExecutorSchemaOperations(); this.sessionFactories = processEngineConfiguration.getSessionFactories(); this.historyLevel = processEngineConfiguration.getHistoryLevel();
this.jobExecutor = processEngineConfiguration.getJobExecutor(); this.commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired(); commandExecutorSchemaOperations = processEngineConfiguration.getCommandExecutorSchemaOperations(); this.sessionFactories = processEngineConfiguration.getSessionFactories(); this.historyLevel = processEngineConfiguration.getHistoryLevel();
@Test public void readLevelFullfromDB() throws Exception { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_FULL); // init the db with level=full processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); HistoryLevel historyLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(historyLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_FULL)); }
@Test public void useDefaultLevelAudit() throws Exception { ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); // init the db with level=auto -> audit processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); // the history Level has been overwritten with audit assertThat(config.getHistoryLevel(), CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); // and this is written to the database HistoryLevel databaseLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(databaseLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }
@Test public void usesDefaultValueAuditWhenNoValueIsConfigured() { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); ProcessEngineImpl processEngine = buildEngine(config); final Integer level = config.getCommandExecutorSchemaOperations().execute(new Command<Integer>() { @Override public Integer execute(CommandContext commandContext) { return HistoryLevelSetupCommand.databaseHistoryLevel(commandContext); } }); assertThat(level, equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT.getId())); assertThat(processEngine.getProcessEngineConfiguration().getHistoryLevel(), equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }
@Test public void schemaCreatedByUserAndDatabaseSchemaUpdateFalse() { processEngineImpl = createProcessEngineImpl("false", false); // simulate manual schema creation by user TestHelper.createSchema(processEngineImpl.getProcessEngineConfiguration()); // let the engine do their schema operations thing processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new SchemaOperationsProcessEngineBuild()); processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new HistoryLevelSetupCommand()); assertHistoryLevel(); }
@Test public void schemaCreatedByUserAndDatabaseSchemaUpdateTrue() { processEngineImpl = createProcessEngineImpl("true", false); // simulate manual schema creation by user TestHelper.createSchema(processEngineImpl.getProcessEngineConfiguration()); // let the engine do their schema operations thing processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new SchemaOperationsProcessEngineBuild()); processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new HistoryLevelSetupCommand()); assertHistoryLevel(); }
@Test public void failWhenExistingHistoryLevelIsNotRegistered() { // init the db with custom level HistoryLevel customLevel = new HistoryLevel() { @Override public int getId() { return 99; } @Override public String getName() { return "custom"; } @Override public boolean isHistoryEventProduced(HistoryEventType eventType, Object entity) { return false; } }; ProcessEngineConfigurationImpl config = config("true", "custom"); config.setCustomHistoryLevels(Arrays.asList(customLevel)); processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); thrown.expect(ProcessEngineException.class); thrown.expectMessage("The configured history level with id='99' is not registered in this config."); config.getCommandExecutorSchemaOperations().execute( new DetermineHistoryLevelCmd(Collections.<HistoryLevel>emptyList())); }
@Test public void disabledDmn() { processEngineImpl = createProcessEngineImpl(false); // simulate manual schema creation by user TestHelper.createSchema(processEngineImpl.getProcessEngineConfiguration()); // let the engine do their schema operations thing processEngineImpl.getProcessEngineConfiguration() .getCommandExecutorSchemaOperations() .execute(new SchemaOperationsProcessEngineBuild()); }