Search in sources :

Example 56 with NotValidException

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

the class CleanableHistoricCaseInstanceReportTest method testReportByInvalidCaseDefinitionKey.

@Test
public void testReportByInvalidCaseDefinitionKey() {
    CleanableHistoricCaseInstanceReport report = historyService.createCleanableHistoricCaseInstanceReport();
    try {
        report.caseDefinitionKeyIn(null);
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
    try {
        report.caseDefinitionKeyIn("abc", null, "def");
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport) Test(org.junit.Test)

Example 57 with NotValidException

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

the class CleanableHistoricCaseInstanceReportTest method testReportByInvalidCaseDefinitionId.

@Test
public void testReportByInvalidCaseDefinitionId() {
    CleanableHistoricCaseInstanceReport report = historyService.createCleanableHistoricCaseInstanceReport();
    try {
        report.caseDefinitionIdIn(null);
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
    try {
        report.caseDefinitionIdIn("abc", null, "def");
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CleanableHistoricCaseInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport) Test(org.junit.Test)

Example 58 with NotValidException

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

the class CleanableHistoricProcessInstanceReportTest method testReportByInvalidProcessDefinitionId.

@Test
public void testReportByInvalidProcessDefinitionId() {
    CleanableHistoricProcessInstanceReport report = historyService.createCleanableHistoricProcessInstanceReport();
    try {
        report.processDefinitionIdIn(null);
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
    try {
        report.processDefinitionIdIn("abc", null, "def");
        fail("Expected NotValidException");
    } catch (NotValidException e) {
    // expected
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CleanableHistoricProcessInstanceReport(org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReport) Test(org.junit.Test)

Example 59 with NotValidException

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

the class HistoricCaseInstanceTest method testHistoricCaseInstanceQuery.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn", "org/camunda/bpm/engine/test/api/repository/three_.cmmn" })
public void testHistoricCaseInstanceQuery() {
    CaseInstance oneTaskCase = createCaseInstanceByKey("oneTaskCase", "oneBusiness");
    CaseInstance twoTaskCase = createCaseInstanceByKey("twoTaskCase", "twoBusiness");
    createCaseInstanceByKey("xyz_", "xyz_");
    assertCount(1, historicQuery().caseInstanceId(oneTaskCase.getId()));
    assertCount(1, historicQuery().caseInstanceId(twoTaskCase.getId()));
    Set<String> caseInstanceIds = new HashSet<String>();
    caseInstanceIds.add(oneTaskCase.getId());
    caseInstanceIds.add("unknown1");
    caseInstanceIds.add(twoTaskCase.getId());
    caseInstanceIds.add("unknown2");
    assertCount(2, historicQuery().caseInstanceIds(caseInstanceIds));
    assertCount(0, historicQuery().caseInstanceIds(caseInstanceIds).caseInstanceId("someOtherId"));
    assertCount(1, historicQuery().caseDefinitionId(oneTaskCase.getCaseDefinitionId()));
    assertCount(1, historicQuery().caseDefinitionKey("oneTaskCase"));
    assertCount(3, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("unknown")));
    assertCount(2, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")));
    assertCount(1, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase", "twoTaskCase")));
    assertCount(0, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")).caseDefinitionKey("oneTaskCase"));
    try {
        // oracle handles empty string like null which seems to lead to undefined behavior of the LIKE comparison
        historicQuery().caseDefinitionKeyNotIn(Arrays.asList(""));
        fail("Exception expected");
    } catch (NotValidException e) {
    // expected
    }
    assertCount(1, historicQuery().caseDefinitionName("One Task Case"));
    assertCount(2, historicQuery().caseDefinitionNameLike("%T%"));
    assertCount(1, historicQuery().caseDefinitionNameLike("One%"));
    assertCount(0, historicQuery().caseDefinitionNameLike("%Process%"));
    assertCount(1, historicQuery().caseDefinitionNameLike("%z\\_"));
    assertCount(1, historicQuery().caseInstanceBusinessKey("oneBusiness"));
    assertCount(2, historicQuery().caseInstanceBusinessKeyLike("%Business"));
    assertCount(1, historicQuery().caseInstanceBusinessKeyLike("one%"));
    assertCount(0, historicQuery().caseInstanceBusinessKeyLike("%unknown%"));
    assertCount(1, historicQuery().caseInstanceBusinessKeyLike("%z\\_"));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) NotValidException(org.camunda.bpm.engine.exception.NotValidException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 60 with NotValidException

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

the class HistoricProcessInstanceTest method testHistoricProcessInstanceQuery.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneAsyncTaskProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQuery() {
    Calendar startTime = Calendar.getInstance();
    ClockUtil.setCurrentTime(startTime.getTime());
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "businessKey_123");
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
    Calendar hourAgo = Calendar.getInstance();
    hourAgo.add(Calendar.HOUR_OF_DAY, -1);
    Calendar hourFromNow = Calendar.getInstance();
    hourFromNow.add(Calendar.HOUR_OF_DAY, 1);
    // Start/end dates
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourAgo.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourFromNow.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourAgo.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourFromNow.getTime()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().startedBefore(hourFromNow.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().startedBefore(hourAgo.getTime()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().startedAfter(hourAgo.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().startedAfter(hourFromNow.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().startedAfter(hourFromNow.getTime()).startedBefore(hourAgo.getTime()).count());
    // General fields
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finished().count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey("businessKey_123").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKeyLike("business%").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKeyLike("%sinessKey\\_123").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKeyLike("%siness%").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionName("The One Task_Process").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionNameLike("The One Task%").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionNameLike("%One Task\\_Process").count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionNameLike("%One Task%").count());
    List<String> exludeIds = new ArrayList<String>();
    exludeIds.add("unexistingProcessDefinition");
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKeyNotIn(exludeIds).count());
    exludeIds.add("oneTaskProcess");
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneTaskProcess").processDefinitionKeyNotIn(exludeIds).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionKeyNotIn(exludeIds).count());
    try {
        // oracle handles empty string like null which seems to lead to undefined behavior of the LIKE comparison
        historyService.createHistoricProcessInstanceQuery().processDefinitionKeyNotIn(Arrays.asList(""));
        fail("Exception expected");
    } catch (NotValidException e) {
    // expected
    }
    // After finishing process
    taskService.complete(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourAgo.getTime()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourFromNow.getTime()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourAgo.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourFromNow.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourFromNow.getTime()).finishedBefore(hourAgo.getTime()).count());
    // No incidents should are created
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().withIncidents().count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().incidentMessageLike("Unknown property used%").count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().incidentMessage("Unknown property used in expression: #{failing}. Cause: Cannot resolve identifier 'failing'").count());
    // execute activities
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourAgo.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count());
    // execute jobs
    if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
        assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedJobAfter(hourAgo.getTime()).count());
        assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count());
        assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count());
        assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

NotValidException (org.camunda.bpm.engine.exception.NotValidException)121 Test (org.junit.Test)28 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)24 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 Deployment (org.camunda.bpm.engine.test.Deployment)12 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)10 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 CaseService (org.camunda.bpm.engine.CaseService)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 RestException (org.camunda.bpm.engine.rest.exception.RestException)8 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 HashMap (java.util.HashMap)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3