use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.
the class DetermineHistoryLevelCmdTest method failWhenExistingHistoryLevelIsNotRegistered.
@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()));
}
use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.
the class DetermineHistoryLevelCmdTest method readLevelFullfromDB.
@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));
}
use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.
the class HistoryLevelSetupCommand method execute.
public Void execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
checkStartupLockExists(commandContext);
HistoryLevel databaseHistoryLevel = new DetermineHistoryLevelCmd(processEngineConfiguration.getHistoryLevels()).execute(commandContext);
determineAutoHistoryLevel(processEngineConfiguration, databaseHistoryLevel);
HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel();
if (databaseHistoryLevel == null) {
commandContext.getPropertyManager().acquireExclusiveLockForStartup();
databaseHistoryLevel = new DetermineHistoryLevelCmd(processEngineConfiguration.getHistoryLevels()).execute(commandContext);
if (databaseHistoryLevel == null) {
LOG.noHistoryLevelPropertyFound();
dbCreateHistoryLevel(commandContext);
}
} else {
if (configuredHistoryLevel.getId() != databaseHistoryLevel.getId()) {
throw new ProcessEngineException("historyLevel mismatch: configuration says " + configuredHistoryLevel + " and database says " + databaseHistoryLevel);
}
}
return null;
}
use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.
the class DetermineHistoryLevelCmdTest method useDefaultLevelAudit.
@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));
}
Aggregations