Search in sources :

Example 1 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationBatchCmd method createBatch.

protected BatchEntity createBatch(CommandContext commandContext, List<AbstractProcessInstanceModificationCommand> instructions, Collection<String> processInstanceIds, ProcessDefinitionEntity processDefinition) {
    ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration();
    BatchJobHandler<ModificationBatchConfiguration> batchJobHandler = getBatchJobHandler(processEngineConfiguration);
    ModificationBatchConfiguration configuration = new ModificationBatchConfiguration(new ArrayList<String>(processInstanceIds), builder.getProcessDefinitionId(), instructions, builder.isSkipCustomListeners(), builder.isSkipIoMappings());
    BatchEntity batch = new BatchEntity();
    batch.setType(batchJobHandler.getType());
    batch.setTotalJobs(calculateSize(processEngineConfiguration, configuration));
    batch.setBatchJobsPerSeed(processEngineConfiguration.getBatchJobsPerSeed());
    batch.setInvocationsPerBatchJob(processEngineConfiguration.getInvocationsPerBatchJob());
    batch.setConfigurationBytes(batchJobHandler.writeConfiguration(configuration));
    batch.setTenantId(processDefinition.getTenantId());
    commandContext.getBatchManager().insert(batch);
    return batch;
}
Also used : BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ModificationBatchConfiguration(org.camunda.bpm.engine.impl.ModificationBatchConfiguration)

Example 2 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class MailActivityBehavior method setMailServerProperties.

protected void setMailServerProperties(Email email) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    String host = processEngineConfiguration.getMailServerHost();
    ensureNotNull("Could not send email: no SMTP host is configured", "host", host);
    email.setHostName(host);
    int port = processEngineConfiguration.getMailServerPort();
    email.setSmtpPort(port);
    email.setTLS(processEngineConfiguration.getMailServerUseTLS());
    String user = processEngineConfiguration.getMailServerUsername();
    String password = processEngineConfiguration.getMailServerPassword();
    if (user != null && password != null) {
        email.setAuthentication(user, password);
    }
}
Also used : ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 3 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class SpinProcessEnginePluginTest method testPluginDoesNotRegisterXmlSerializerIfNotPresentInClasspath.

public void testPluginDoesNotRegisterXmlSerializerIfNotPresentInClasspath() 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(XmlValueType.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 4 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class SpinProcessEnginePluginTest method testPluginRegistersJsonSerializerIfPresentInClasspath.

public void testPluginRegistersJsonSerializerIfPresentInClasspath() {
    DataFormats.loadDataFormats(null);
    ProcessEngineConfigurationImpl mockConfig = Mockito.mock(ProcessEngineConfigurationImpl.class);
    Mockito.when(mockConfig.getVariableSerializers()).thenReturn(processEngineConfiguration.getVariableSerializers());
    new SpinProcessEnginePlugin().registerSerializers(mockConfig);
    assertTrue(processEngineConfiguration.getVariableSerializers().getSerializerByName(JsonValueType.TYPE_NAME) instanceof JsonValueSerializer);
}
Also used : ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 5 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class HistoryCleanupRestServiceInteractionTest method testHistoryConfigurationOutsideBatchWindow.

@Test
public void testHistoryConfigurationOutsideBatchWindow() throws ParseException {
    ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class);
    Date startDate = HistoryCleanupHelper.parseTimeConfiguration("23:59+0200");
    Date endDate = HistoryCleanupHelper.parseTimeConfiguration("00: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);
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.setTime(HistoryCleanupHelper.addDays(now, 1));
    Date dateToday = HistoryCleanupHelper.updateTime(today.getTime(), startDate);
    Date dateTomorrow = HistoryCleanupHelper.updateTime(tomorrow.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)

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