Search in sources :

Example 51 with BadUserRequestException

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

the class MigrationPlanCreationTest method testMigrateNonExistingSourceDefinition.

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

Example 52 with BadUserRequestException

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

the class MultiTenancyDecisionEvaluationTest method testFailToEvaluateDecisionByIdWithTenantId.

public void testFailToEvaluateDecisionByIdWithTenantId() {
    deploymentForTenant(TENANT_ONE, DMN_FILE);
    DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
    try {
        decisionService.evaluateDecisionById(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 53 with BadUserRequestException

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

the class MultiTenancyDecisionEvaluationTest method testFailToEvaluateDecisionByIdWithoutTenantId.

public void testFailToEvaluateDecisionByIdWithoutTenantId() {
    deployment(DMN_FILE);
    DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
    try {
        decisionService.evaluateDecisionById(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 54 with BadUserRequestException

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

the class CreateAndResolveIncidentTest method resolveIncidentOfTypeFailedJob.

@Test
public void resolveIncidentOfTypeFailedJob() {
    // given
    testRule.deploy("org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncident.bpmn");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
    // when
    List<Job> jobs = engineRule.getManagementService().createJobQuery().withRetriesLeft().list();
    for (Job job : jobs) {
        engineRule.getManagementService().setJobRetries(job.getId(), 1);
        try {
            engineRule.getManagementService().executeJob(job.getId());
        } catch (Exception e) {
        }
    }
    // then
    Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
    try {
        runtimeService.resolveIncident(incident.getId());
        fail("Exception expected");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot resolve an incident of type failedJob"));
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Job(org.camunda.bpm.engine.runtime.Job) ExpectedException(org.junit.rules.ExpectedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 55 with BadUserRequestException

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

the class RepositoryServiceTest method testDecisionDefinitionUpdateTimeToLiveNegative.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/dmn/Example.dmn" })
public void testDecisionDefinitionUpdateTimeToLiveNegative() {
    // given
    DecisionDefinition decisionDefinition = findOnlyDecisionDefinition();
    // when
    try {
        repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), -1);
        fail("Exception is expected, that negative value is not allowed.");
    } catch (BadUserRequestException ex) {
        assertTrue(ex.getMessage().contains("greater than"));
    }
}
Also used : BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

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