Search in sources :

Example 11 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class MultiTenancyJobExecutorTest method hasAuthenticatedTenantId.

protected static DelegateExecutionAsserter hasAuthenticatedTenantId(final String expectedTenantId) {
    return new DelegateExecutionAsserter() {

        @Override
        public void doAssert(DelegateExecution execution) {
            IdentityService identityService = execution.getProcessEngineServices().getIdentityService();
            Authentication currentAuthentication = identityService.getCurrentAuthentication();
            assertThat(currentAuthentication, is(notNullValue()));
            assertThat(currentAuthentication.getTenantIds(), hasItem(expectedTenantId));
        }
    };
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 12 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class MultiTenancyJobExecutorTest method hasNoAuthenticatedTenantId.

protected static DelegateExecutionAsserter hasNoAuthenticatedTenantId() {
    return new DelegateExecutionAsserter() {

        @Override
        public void doAssert(DelegateExecution execution) {
            IdentityService identityService = execution.getProcessEngineServices().getIdentityService();
            Authentication currentAuthentication = identityService.getCurrentAuthentication();
            assertThat(currentAuthentication, is(nullValue()));
        }
    };
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 13 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class MocksTest method testMockAvailability.

// helper ////////////////////////////////////////////////////////////
private void testMockAvailability() {
    // given
    final String testStr = "testValue";
    Mocks.register("myMock", new Object() {

        public String getTest() {
            return testStr;
        }

        public void testMethod(DelegateExecution execution, String str) {
            execution.setVariable("testVar", str);
        }
    });
    // when
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("mocksTest");
    Mocks.reset();
    // then
    assertEquals(testStr, runtimeService.getVariable(pi.getId(), "testVar"));
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Example 14 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class RecorderTaskListener method notify.

public void notify(DelegateTask task) {
    DelegateExecution execution = task.getExecution();
    recordedEvents.add(new RecordedTaskEvent(task.getId(), task.getExecutionId(), task.getEventName(), execution.getActivityInstanceId()));
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution)

Example 15 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class TenantIdProviderTest method providerCalledWithSuperProcessInstance.

@Test
public void providerCalledWithSuperProcessInstance() {
    ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().done(), Bpmn.createExecutableProcess("superProcess").startEvent().callActivity().calledElement(PROCESS_DEFINITION_KEY).done());
    ProcessDefinition superProcessDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("superProcess").singleResult();
    // if a process instance is started
    engineRule.getRuntimeService().startProcessInstanceByKey("superProcess");
    // then the tenant id provider is passed in the process definition
    DelegateExecution superExecution = tenantIdProvider.parameters.get(1).getSuperExecution();
    assertThat(superExecution, is(notNullValue()));
    assertThat(superExecution.getProcessDefinitionId(), is(superProcessDefinition.getId()));
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Test(org.junit.Test)

Aggregations

DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)23 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)9 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)9 Deployment (org.camunda.bpm.engine.test.Deployment)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 DelegateExecutionAsserter (org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)6 DelegateTask (org.camunda.bpm.engine.delegate.DelegateTask)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 Task (org.camunda.bpm.engine.task.Task)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IdentityService (org.camunda.bpm.engine.IdentityService)2 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)1