Search in sources :

Example 21 with EmbeddedProcessApplication

use of org.camunda.bpm.application.impl.EmbeddedProcessApplication in project camunda-bpm-platform by camunda.

the class UserOperationLogDeploymentTest method testCreateDeploymentPa.

public void testCreateDeploymentPa() {
    // given
    EmbeddedProcessApplication application = new EmbeddedProcessApplication();
    // when
    Deployment deployment = repositoryService.createDeployment(application.getReference()).name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)).deploy();
    // then
    UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().singleResult();
    assertNotNull(userOperationLogEntry);
    assertEquals(EntityTypes.DEPLOYMENT, userOperationLogEntry.getEntityType());
    assertEquals(deployment.getId(), userOperationLogEntry.getDeploymentId());
    assertEquals(UserOperationLogEntry.OPERATION_TYPE_CREATE, userOperationLogEntry.getOperationType());
    assertEquals("duplicateFilterEnabled", userOperationLogEntry.getProperty());
    assertNull(userOperationLogEntry.getOrgValue());
    assertFalse(Boolean.valueOf(userOperationLogEntry.getNewValue()));
    assertEquals(USER_ID, userOperationLogEntry.getUserId());
    assertNull(userOperationLogEntry.getJobDefinitionId());
    assertNull(userOperationLogEntry.getProcessInstanceId());
    assertNull(userOperationLogEntry.getProcessDefinitionId());
    assertNull(userOperationLogEntry.getProcessDefinitionKey());
    assertNull(userOperationLogEntry.getCaseInstanceId());
    assertNull(userOperationLogEntry.getCaseDefinitionId());
}
Also used : EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Deployment(org.camunda.bpm.engine.repository.Deployment)

Example 22 with EmbeddedProcessApplication

use of org.camunda.bpm.application.impl.EmbeddedProcessApplication in project camunda-bpm-platform by camunda.

the class DeploymentAuthorizationTest method testGetProcessApplicationForDeploymentWithoutAuthorization.

// get process application for deployment ///////////////////////////////////
public void testGetProcessApplicationForDeploymentWithoutAuthorization() {
    // given
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();
    String deploymentId = createDeployment(null, FIRST_RESOURCE).getId();
    ProcessApplicationReference reference = processApplication.getReference();
    registerProcessApplication(deploymentId, reference);
    try {
        // when
        managementService.getProcessApplicationForDeployment(deploymentId);
        fail("Exception expected: It should not be possible to get the process application");
    } catch (AuthorizationException e) {
        // then
        String message = e.getMessage();
        assertTextPresent("ENGINE-03029 Required authenticated group 'camunda-admin'", message);
    }
    deleteDeployment(deploymentId);
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AuthorizationException(org.camunda.bpm.engine.AuthorizationException)

Example 23 with EmbeddedProcessApplication

use of org.camunda.bpm.application.impl.EmbeddedProcessApplication in project camunda-bpm-platform by camunda.

the class DeploymentAuthorizationTest method testUnregisterProcessApplicationWithoutAuthorization.

// unregister process application ///////////////////////////////////
public void testUnregisterProcessApplicationWithoutAuthorization() {
    // given
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();
    String deploymentId = createDeployment(null, FIRST_RESOURCE).getId();
    ProcessApplicationReference reference = processApplication.getReference();
    registerProcessApplication(deploymentId, reference);
    try {
        // when
        managementService.unregisterProcessApplication(deploymentId, true);
        fail("Exception expected: It should not be possible to unregister a process application");
    } catch (AuthorizationException e) {
        // then
        String message = e.getMessage();
        assertTextPresent("ENGINE-03029 Required authenticated group 'camunda-admin'", message);
    }
    deleteDeployment(deploymentId);
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AuthorizationException(org.camunda.bpm.engine.AuthorizationException)

Example 24 with EmbeddedProcessApplication

use of org.camunda.bpm.application.impl.EmbeddedProcessApplication in project camunda-bpm-platform by camunda.

the class DeploymentAuthorizationTest method testGetProcessApplicationForDeploymentAsCamundaAdmin.

public void testGetProcessApplicationForDeploymentAsCamundaAdmin() {
    // given
    identityService.setAuthentication(userId, Collections.singletonList(Groups.CAMUNDA_ADMIN));
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();
    String deploymentId = createDeployment(null, FIRST_RESOURCE).getId();
    ProcessApplicationReference reference = processApplication.getReference();
    registerProcessApplication(deploymentId, reference);
    // when
    String application = managementService.getProcessApplicationForDeployment(deploymentId);
    // then
    assertNotNull(application);
    deleteDeployment(deploymentId);
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication)

Example 25 with EmbeddedProcessApplication

use of org.camunda.bpm.application.impl.EmbeddedProcessApplication in project camunda-bpm-platform by camunda.

the class ProcessApplicationEventListenerTest method testTaskListener.

@Deployment
public void testTaskListener() {
    final List<String> events = new ArrayList<String>();
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {

        public TaskListener getTaskListener() {
            return new TaskListener() {

                public void notify(DelegateTask delegateTask) {
                    events.add(delegateTask.getEventName());
                }
            };
        }
    };
    // register app so that it is notified about events
    managementService.registerProcessApplication(deploymentId, processApplication.getReference());
    // start process instance
    ProcessInstance taskListenerProcess = runtimeService.startProcessInstanceByKey("taskListenerProcess");
    // create event received
    assertEquals(1, events.size());
    assertEquals(TaskListener.EVENTNAME_CREATE, events.get(0));
    Task task = taskService.createTaskQuery().singleResult();
    // assign task:
    taskService.setAssignee(task.getId(), "jonny");
    assertEquals(2, events.size());
    assertEquals(TaskListener.EVENTNAME_ASSIGNMENT, events.get(1));
    // complete task
    taskService.complete(task.getId());
    assertEquals(4, events.size());
    assertEquals(TaskListener.EVENTNAME_COMPLETE, events.get(2));
    // next task was created
    assertEquals(TaskListener.EVENTNAME_CREATE, events.get(3));
    // delete process instance so last task will be deleted
    runtimeService.deleteProcessInstance(taskListenerProcess.getProcessInstanceId(), "test delete event");
    assertEquals(5, events.size());
    assertEquals(TaskListener.EVENTNAME_DELETE, events.get(4));
}
Also used : DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) ArrayList(java.util.ArrayList) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)30 Deployment (org.camunda.bpm.engine.test.Deployment)11 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)9 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)9 ProcessApplicationDeployment (org.camunda.bpm.engine.repository.ProcessApplicationDeployment)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)6 ScriptEngine (javax.script.ScriptEngine)5 ProcessApplicationRegistration (org.camunda.bpm.application.ProcessApplicationRegistration)4 DelegateTask (org.camunda.bpm.engine.delegate.DelegateTask)4 Task (org.camunda.bpm.engine.task.Task)4 ArrayList (java.util.ArrayList)3 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)3 Resource (org.camunda.bpm.engine.repository.Resource)3 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)3 List (java.util.List)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)1 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)1