Search in sources :

Example 81 with BadUserRequestException

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

the class SetExternalTasksRetriesTest method shouldFailForNegativeRetriesAsync.

@Test
public void shouldFailForNegativeRetriesAsync() {
    List<String> externalTaskIds = Arrays.asList("externalTaskId");
    try {
        Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, null, -10);
        executeSeedAndBatchJobs(batch);
        fail("exception expected");
    } catch (BadUserRequestException e) {
        Assert.assertThat(e.getMessage(), containsString("The number of retries cannot be negative"));
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 82 with BadUserRequestException

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

the class ExternalTaskServiceTest method testExtendLockTimeWithoutLock.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testExtendLockTimeWithoutLock() {
    // given
    runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
    ExternalTask externalTask = externalTaskService.createExternalTaskQuery().singleResult();
    // when
    try {
        externalTaskService.extendLock(externalTask.getId(), WORKER_ID, 100);
        fail("Exception expected");
    } catch (BadUserRequestException e) {
        assertTrue(e.getMessage().contains("The lock of the External Task " + externalTask.getId() + " cannot be extended by worker '" + WORKER_ID));
    }
}
Also used : BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 83 with BadUserRequestException

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

the class ProcessInstanceSuspensionTest method testProcessInstanceSignalFailAfterSuspend.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceSignalFailAfterSuspend() {
    // Suspend process instance
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    try {
        runtimeService.signal(processInstance.getId());
        fail();
    } catch (SuspendedEntityInteractionException e) {
        // This is expected
        assertTextPresent("is suspended", e.getMessage());
        assertTrue(e instanceof BadUserRequestException);
    }
    try {
        runtimeService.signal(processInstance.getId(), new HashMap<String, Object>());
        fail();
    } catch (SuspendedEntityInteractionException e) {
        // This is expected
        assertTextPresent("is suspended", e.getMessage());
        assertTrue(e instanceof BadUserRequestException);
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 84 with BadUserRequestException

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

the class RestartProcessInstanceAsyncTest method restartNotExistingProcessInstance.

@Test
public void restartNotExistingProcessInstance() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("bar").processInstanceIds("aaa").executeAsync();
    helper.executeSeedJob(batch);
    try {
        helper.executeJobs(batch);
        fail("exception expected");
    } catch (BadUserRequestException e) {
        Assert.assertThat(e.getMessage(), containsString("Historic process instance cannot be found"));
    }
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 85 with BadUserRequestException

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

the class RepositoryServiceTest method testUpdateHistoryTimeToLiveNegative.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testUpdateHistoryTimeToLiveNegative() {
    // given
    // there exists a deployment containing a case definition with key "oneTaskCase"
    CaseDefinition caseDefinition = findOnlyCaseDefinition();
    // when
    try {
        repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinition.getId(), -1);
        fail("Exception is expected, that negative value is not allowed.");
    } catch (BadUserRequestException ex) {
        assertTrue(ex.getMessage().contains("greater than"));
    }
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) 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