Search in sources :

Example 71 with BadUserRequestException

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

the class HandleExternalTaskCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    validateInput();
    ExternalTaskEntity externalTask = commandContext.getExternalTaskManager().findExternalTaskById(externalTaskId);
    EnsureUtil.ensureNotNull(NotFoundException.class, "Cannot find external task with id " + externalTaskId, "externalTask", externalTask);
    if (!workerId.equals(externalTask.getWorkerId())) {
        throw new BadUserRequestException(getErrorMessageOnWrongWorkerAccess() + "'. It is locked by worker '" + externalTask.getWorkerId() + "'.");
    }
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkUpdateProcessInstanceById(externalTask.getProcessInstanceId());
    }
    execute(externalTask);
    return null;
}
Also used : ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 72 with BadUserRequestException

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

the class MultiTenancyDecisionTableEvaluationTest method testFailToEvaluateDecisionByIdWithoutTenantId.

public void testFailToEvaluateDecisionByIdWithoutTenantId() {
    deployment(DMN_FILE);
    DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
    try {
        decisionService.evaluateDecisionTableById(decisionDefinition.getId()).variables(createVariables()).decisionDefinitionWithoutTenantId().evaluate();
        fail("BadUserRequestException exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 73 with BadUserRequestException

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

the class MultiTenancyDecisionTableEvaluationTest method testFailToEvaluateDecisionByIdWithTenantId.

public void testFailToEvaluateDecisionByIdWithTenantId() {
    deploymentForTenant(TENANT_ONE, DMN_FILE);
    DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
    try {
        decisionService.evaluateDecisionTableById(decisionDefinition.getId()).variables(createVariables()).decisionDefinitionTenantId(TENANT_ONE).evaluate();
        fail("BadUserRequestException exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 74 with BadUserRequestException

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

the class MultiTenancyProcessInstantiationTest method testFailToStartProcessInstanceByIdAndTenantId.

public void testFailToStartProcessInstanceByIdAndTenantId() {
    deploymentForTenant(TENANT_ONE, PROCESS);
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    try {
        runtimeService.createProcessInstanceById(processDefinition.getId()).processDefinitionTenantId(TENANT_ONE).execute();
        fail("expected exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 75 with BadUserRequestException

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

the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceSyncWithOtherTenantId.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceSyncWithOtherTenantId() {
    // given
    ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
    identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
    try {
        // when
        runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").processInstanceIds(processInstance.getId()).execute();
        fail("expected exception");
    } catch (BadUserRequestException e) {
        // then
        assertThat(e.getMessage(), containsString("Historic process instance cannot be found: historicProcessInstanceId is null"));
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)105 Test (org.junit.Test)68 Matchers.anyString (org.mockito.Matchers.anyString)43 HashMap (java.util.HashMap)22 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)19 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)16 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)16 ArrayList (java.util.ArrayList)14 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)13 Batch (org.camunda.bpm.engine.batch.Batch)12 Deployment (org.camunda.bpm.engine.test.Deployment)9 FluentAnswer (org.camunda.bpm.engine.rest.helper.FluentAnswer)8 JoinedMigrationPlanBuilderMock (org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock)8 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)8 Map (java.util.Map)7 RestException (org.camunda.bpm.engine.rest.exception.RestException)6 List (java.util.List)5 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)5 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5