use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class SpinProcessEnginePluginTest method testPluginDoesNotRegisterJsonSerializerIfNotPresentInClasspath.
public void testPluginDoesNotRegisterJsonSerializerIfNotPresentInClasspath() throws IOException {
ClassLoader mockClassloader = Mockito.mock(ClassLoader.class);
Mockito.when(mockClassloader.getResources(Mockito.anyString())).thenReturn(Collections.enumeration(Collections.<URL>emptyList()));
DataFormats.loadDataFormats(mockClassloader);
ProcessEngineConfigurationImpl mockConfig = Mockito.mock(ProcessEngineConfigurationImpl.class);
DefaultVariableSerializers serializers = new DefaultVariableSerializers();
Mockito.when(mockConfig.getVariableSerializers()).thenReturn(serializers);
new SpinProcessEnginePlugin().registerSerializers(mockConfig);
assertTrue(serializers.getSerializerByName(JsonValueType.TYPE_NAME) == null);
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class HistoryCleanupRestServiceInteractionTest method testHistoryConfigurationWithinBatchWindow.
@Test
public void testHistoryConfigurationWithinBatchWindow() throws ParseException {
ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class);
Date startDate = HistoryCleanupHelper.parseTimeConfiguration("22:00+0200");
Date endDate = HistoryCleanupHelper.parseTimeConfiguration("23:00+0200");
when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationImplMock);
when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowStartTimeAsDate()).thenReturn(startDate);
when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowEndTimeAsDate()).thenReturn(endDate);
SimpleDateFormat sdf = new SimpleDateFormat(JacksonConfigurator.dateFormatString);
Date now = sdf.parse("2017-09-01T22:00:00.000+0200");
ClockUtil.setCurrentTime(now);
Calendar today = Calendar.getInstance();
today.setTime(now);
Date dateToday = HistoryCleanupHelper.updateTime(today.getTime(), startDate);
Date dateTomorrow = HistoryCleanupHelper.updateTime(today.getTime(), endDate);
given().contentType(ContentType.JSON).then().expect().statusCode(Status.OK.getStatusCode()).body("batchWindowStartTime", containsString(sdf.format(dateToday))).body("batchWindowEndTime", containsString(sdf.format(dateTomorrow))).when().get(CONFIGURATION_URL);
verify(processEngineConfigurationImplMock).getHistoryCleanupBatchWindowStartTimeAsDate();
verify(processEngineConfigurationImplMock).getHistoryCleanupBatchWindowEndTimeAsDate();
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class HistoryCleanupRestServiceInteractionTest method testHistoryConfigurationWhenBatchNotDefined.
@Test
public void testHistoryConfigurationWhenBatchNotDefined() {
ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class);
when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationImplMock);
when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowStartTimeAsDate()).thenReturn(null);
when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowEndTimeAsDate()).thenReturn(null);
given().contentType(ContentType.JSON).then().expect().statusCode(Status.OK.getStatusCode()).body("batchWindowStartTime", equalTo(null)).body("batchWindowEndTime", equalTo(null)).when().get(CONFIGURATION_URL);
verify(processEngineConfigurationImplMock).getHistoryCleanupBatchWindowStartTimeAsDate();
verify(processEngineConfigurationImplMock).getHistoryCleanupBatchWindowEndTimeAsDate();
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl 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.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class HistoryLevelSetupCommand method dbCreateHistoryLevel.
public static void dbCreateHistoryLevel(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel();
PropertyEntity property = new PropertyEntity("historyLevel", Integer.toString(configuredHistoryLevel.getId()));
commandContext.getSession(DbEntityManager.class).insert(property);
LOG.creatingHistoryLevelPropertyInDatabase(configuredHistoryLevel);
}
Aggregations