Search in sources :

Example 81 with ProcessEngineConfigurationImpl

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);
}
Also used : DefaultVariableSerializers(org.camunda.bpm.engine.impl.variable.serializer.DefaultVariableSerializers) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) URL(java.net.URL)

Example 82 with ProcessEngineConfigurationImpl

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();
}
Also used : Calendar(java.util.Calendar) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 83 with ProcessEngineConfigurationImpl

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();
}
Also used : ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 84 with ProcessEngineConfigurationImpl

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;
}
Also used : DetermineHistoryLevelCmd(org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 85 with ProcessEngineConfigurationImpl

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);
}
Also used : HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) PropertyEntity(org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Aggregations

ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)161 Test (org.junit.Test)35 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)22 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)18 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)17 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)17 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)13 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)12 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)12 Before (org.junit.Before)11 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)8 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)8 After (org.junit.After)8 Date (java.util.Date)7 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)7 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)7 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)7 IdentityService (org.camunda.bpm.engine.IdentityService)7 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)6