Search in sources :

Example 76 with BadUserRequestException

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

the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdWithTenantId.

public void testFailToCreateCaseInstanceByIdWithTenantId() {
    deploymentForTenant(TENANT_ONE, CMMN_FILE);
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    try {
        caseService.withCaseDefinition(caseDefinition.getId()).caseDefinitionTenantId(TENANT_ONE).create();
        fail("BadUserRequestException exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 77 with BadUserRequestException

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

the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdWithoutTenantId.

public void testFailToCreateCaseInstanceByIdWithoutTenantId() {
    deployment(CMMN_FILE);
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    try {
        caseService.withCaseDefinition(caseDefinition.getId()).caseDefinitionWithoutTenantId().create();
        fail("BadUserRequestException exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 78 with BadUserRequestException

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

the class MigrationPlanCreationTest method testMigrateNullSourceDefinition.

@Test
public void testMigrateNullSourceDefinition() {
    ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    try {
        runtimeService.createMigrationPlan(null, processDefinition.getId()).mapActivities("userTask", "userTask").build();
        fail("Should not succeed");
    } catch (BadUserRequestException e) {
        assertExceptionMessage(e, "Source process definition id is null");
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 79 with BadUserRequestException

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

the class MigrationPlanCreationTest method testMigrateNullTargetDefinition.

@Test
public void testMigrateNullTargetDefinition() {
    ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    try {
        runtimeService.createMigrationPlan(processDefinition.getId(), null).mapActivities("userTask", "userTask").build();
        fail("Should not succeed");
    } catch (BadUserRequestException e) {
        assertExceptionMessage(e, "Target process definition id is null");
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 80 with BadUserRequestException

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

the class CaseExecutionManager method deleteCaseInstance.

public void deleteCaseInstance(String caseInstanceId, String deleteReason, boolean cascade) {
    CaseExecutionEntity execution = findCaseExecutionById(caseInstanceId);
    if (execution == null) {
        throw new BadUserRequestException("No case instance found for id '" + caseInstanceId + "'");
    }
    CommandContext commandContext = Context.getCommandContext();
    commandContext.getTaskManager().deleteTasksByCaseInstanceId(caseInstanceId, deleteReason, cascade);
    execution.deleteCascade();
    if (cascade) {
        Context.getCommandContext().getHistoricCaseInstanceManager().deleteHistoricCaseInstancesByIds(Arrays.asList(caseInstanceId));
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

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