org.camunda.bpm.engine.history.HistoricCaseInstance Java Examples
The following examples show how to use
org.camunda.bpm.engine.history.HistoricCaseInstance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BulkHistoryDeleteTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testCleanupHistoryCaseInstance() { // given // create case instances int instanceCount = 10; List<String> caseInstanceIds = prepareHistoricCaseInstance(instanceCount); // assume List<HistoricCaseInstance> caseInstanceList = historyService.createHistoricCaseInstanceQuery().list(); assertEquals(instanceCount, caseInstanceList.size()); // when historyService.deleteHistoricCaseInstancesBulk(caseInstanceIds); // then assertEquals(0, historyService.createHistoricCaseInstanceQuery().count()); assertEquals(0, historyService.createHistoricTaskInstanceQuery().count()); }
Example #2
Source File: HistoricCaseInstanceDto.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public static HistoricCaseInstanceDto fromHistoricCaseInstance(HistoricCaseInstance historicCaseInstance) { HistoricCaseInstanceDto dto = new HistoricCaseInstanceDto(); dto.id = historicCaseInstance.getId(); dto.businessKey = historicCaseInstance.getBusinessKey(); dto.caseDefinitionId = historicCaseInstance.getCaseDefinitionId(); dto.caseDefinitionKey = historicCaseInstance.getCaseDefinitionKey(); dto.caseDefinitionName = historicCaseInstance.getCaseDefinitionName(); dto.createTime = historicCaseInstance.getCreateTime(); dto.closeTime = historicCaseInstance.getCloseTime(); dto.durationInMillis = historicCaseInstance.getDurationInMillis(); dto.createUserId = historicCaseInstance.getCreateUserId(); dto.superCaseInstanceId = historicCaseInstance.getSuperCaseInstanceId(); dto.superProcessInstanceId = historicCaseInstance.getSuperProcessInstanceId(); dto.tenantId = historicCaseInstance.getTenantId(); dto.active = historicCaseInstance.isActive(); dto.completed = historicCaseInstance.isCompleted(); dto.terminated = historicCaseInstance.isTerminated(); dto.closed = historicCaseInstance.isClosed(); return dto; }
Example #3
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testQueryBySubCaseInstanceId() { String superCaseInstanceId = caseService.createCaseInstanceByKey("oneCaseTaskCase").getId(); String subCaseInstanceId = caseService .createCaseInstanceQuery() .superCaseInstanceId(superCaseInstanceId) .singleResult() .getId(); HistoricCaseInstanceQuery query = historyService .createHistoricCaseInstanceQuery() .subCaseInstanceId(subCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricCaseInstance caseInstance = query.singleResult(); assertEquals(superCaseInstanceId, caseInstance.getId()); assertNull(caseInstance.getSuperProcessInstanceId()); assertNull(caseInstance.getSuperCaseInstanceId()); }
Example #4
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testQueryBySuperCaseInstanceId() { String superCaseInstanceId = caseService.createCaseInstanceByKey("oneCaseTaskCase").getId(); HistoricCaseInstanceQuery query = historyService .createHistoricCaseInstanceQuery() .superCaseInstanceId(superCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricCaseInstance caseInstance = query.singleResult(); assertEquals(superCaseInstanceId, caseInstance.getSuperCaseInstanceId()); assertNull(caseInstance.getSuperProcessInstanceId()); }
Example #5
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testQueryBySubProcessInstanceId() { String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId(); String subProcessInstanceId = runtimeService .createProcessInstanceQuery() .superCaseInstanceId(superCaseInstanceId) .singleResult() .getId(); HistoricCaseInstanceQuery query = historyService .createHistoricCaseInstanceQuery() .subProcessInstanceId(subProcessInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricCaseInstance caseInstance = query.singleResult(); assertEquals(superCaseInstanceId, caseInstance.getId()); assertNull(caseInstance.getSuperCaseInstanceId()); assertNull(caseInstance.getSuperProcessInstanceId()); }
Example #6
Source File: DeleteHistoricCaseInstanceCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Object execute(CommandContext commandContext) { ensureNotNull("caseInstanceId", caseInstanceId); // Check if case instance is still running HistoricCaseInstance instance = commandContext .getHistoricCaseInstanceManager() .findHistoricCaseInstance(caseInstanceId); ensureNotNull("No historic case instance found with id: " + caseInstanceId, "instance", instance); for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { checker.checkDeleteHistoricCaseInstance(instance); } ensureNotNull("Case instance is still running, cannot delete historic case instance: " + caseInstanceId, "instance.getCloseTime()", instance.getCloseTime()); commandContext.getOperationLogManager().logCaseInstanceOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE_HISTORY, caseInstanceId, Collections.singletonList(PropertyChange.EMPTY_CHANGE)); commandContext .getHistoricCaseInstanceManager() .deleteHistoricCaseInstancesByIds(Arrays.asList(caseInstanceId)); return null; }
Example #7
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcessWithCaseCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testQueryBySuperProcessInstanceId() { String superProcessInstanceId = runtimeService.startProcessInstanceByKey("subProcessQueryTest").getId(); HistoricCaseInstanceQuery query = historyService .createHistoricCaseInstanceQuery() .superProcessInstanceId(superProcessInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricCaseInstance subCaseInstance = query.singleResult(); assertNotNull(subCaseInstance); assertEquals(superProcessInstanceId, subCaseInstance.getSuperProcessInstanceId()); assertNull(subCaseInstance.getSuperCaseInstanceId()); }
Example #8
Source File: HistoricCaseInstanceRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public List<HistoricCaseInstanceDto> queryHistoricCaseInstances(HistoricCaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) { HistoricCaseInstanceQuery query = queryDto.toQuery(processEngine); List<HistoricCaseInstance> matchingHistoricCaseInstances; if (firstResult != null || maxResults != null) { matchingHistoricCaseInstances = executePaginatedQuery(query, firstResult, maxResults); } else { matchingHistoricCaseInstances = query.list(); } List<HistoricCaseInstanceDto> historicCaseInstanceDtoResults = new ArrayList<HistoricCaseInstanceDto>(); for (HistoricCaseInstance historicCaseInstance : matchingHistoricCaseInstances) { HistoricCaseInstanceDto resultHistoricCaseInstanceDto = HistoricCaseInstanceDto.fromHistoricCaseInstance(historicCaseInstance); historicCaseInstanceDtoResults.add(resultHistoricCaseInstanceDto); } return historicCaseInstanceDtoResults; }
Example #9
Source File: HistoricCaseActivityInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/stage/AutoCompleteTest.testCasePlanModel.cmmn"}) public void testAutoCompleteEnabled() { String caseInstanceId = createCaseInstanceByKey("case").getId(); HistoricCaseInstance caseInstance = historyService .createHistoricCaseInstanceQuery() .caseInstanceId(caseInstanceId) .singleResult(); assertNotNull(caseInstance); assertTrue(caseInstance.isCompleted()); HistoricCaseActivityInstanceQuery query = historyService.createHistoricCaseActivityInstanceQuery(); HistoricCaseActivityInstance humanTask1 = query.caseActivityId("PI_HumanTask_1").singleResult(); assertNotNull(humanTask1); assertTrue(humanTask1.isTerminated()); assertNotNull(humanTask1.getEndTime()); assertNotNull(humanTask1.getDurationInMillis()); HistoricCaseActivityInstance humanTask2 = query.caseActivityId("PI_HumanTask_2").singleResult(); assertNotNull(humanTask2); assertTrue(humanTask2.isTerminated()); assertNotNull(humanTask2.getEndTime()); assertNotNull(humanTask2.getDurationInMillis()); }
Example #10
Source File: MockProvider.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public static HistoricCaseInstance createMockHistoricCaseInstance(String tenantId) { HistoricCaseInstance mock = mock(HistoricCaseInstance.class); when(mock.getId()).thenReturn(EXAMPLE_CASE_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_CASE_INSTANCE_BUSINESS_KEY); when(mock.getCaseDefinitionId()).thenReturn(EXAMPLE_CASE_DEFINITION_ID); when(mock.getCaseDefinitionKey()).thenReturn(EXAMPLE_CASE_DEFINITION_KEY); when(mock.getCaseDefinitionName()).thenReturn(EXAMPLE_CASE_DEFINITION_NAME); when(mock.getCreateTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_CASE_INSTANCE_CREATE_TIME)); when(mock.getCloseTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_CASE_INSTANCE_CLOSE_TIME)); when(mock.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_DURATION_MILLIS); when(mock.getCreateUserId()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_CREATE_USER_ID); when(mock.getSuperCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_SUPER_CASE_INSTANCE_ID); when(mock.getSuperProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_SUPER_PROCESS_INSTANCE_ID); when(mock.getTenantId()).thenReturn(tenantId); when(mock.isActive()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_IS_ACTIVE); when(mock.isCompleted()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_IS_COMPLETED); when(mock.isTerminated()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_IS_TERMINATED); when(mock.isClosed()).thenReturn(EXAMPLE_HISTORIC_CASE_INSTANCE_IS_CLOSED); return mock; }
Example #11
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testNativeQueryPaging() { createCaseInstance(); createCaseInstance(); createCaseInstance(); createCaseInstance(); String tableName = managementService.getTableName(HistoricCaseInstance.class); assertEquals(3, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT * FROM " + tableName).listPage(0, 3).size()); assertEquals(2, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT * FROM " + tableName).listPage(2, 2).size()); }
Example #12
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageCase.cmmn"}) public void testCaseInstanceProperties() { CaseInstance caseInstance = createCaseInstance(); HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstance.getId()); // assert case instance properties are set correctly assertEquals(caseInstance.getId(), historicInstance.getId()); assertEquals(caseInstance.getBusinessKey(), historicInstance.getBusinessKey()); assertEquals(caseInstance.getCaseDefinitionId(), historicInstance.getCaseDefinitionId()); }
Example #13
Source File: CleanableHistoricCaseInstanceReportTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@After public void cleanUp() { List<HistoricCaseInstance> instanceList = historyService.createHistoricCaseInstanceQuery().active().list(); if (!instanceList.isEmpty()) { for (HistoricCaseInstance instance : instanceList) { caseService.terminateCaseExecution(instance.getId()); caseService.closeCaseInstance(instance.getId()); } } List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list(); for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) { historyService.deleteHistoricCaseInstance(historicCaseInstance.getId()); } }
Example #14
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageCase.cmmn"}) public void testCreateUser() { String userId = "test"; identityService.setAuthenticatedUserId(userId); String caseInstanceId = createCaseInstance().getId(); HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); assertEquals(userId, historicCaseInstance.getCreateUserId()); assertCount(1, historicQuery().createdBy(userId)); identityService.setAuthenticatedUserId(null); }
Example #15
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testNativeQuery() { String id = createCaseInstance().getId(); createCaseInstance(); createCaseInstance(); createCaseInstance(); String tablePrefix = processEngineConfiguration.getDatabaseTablePrefix(); String tableName = managementService.getTableName(HistoricCaseInstance.class); assertEquals(tablePrefix + "ACT_HI_CASEINST", tableName); assertEquals(tableName, managementService.getTableName(HistoricCaseInstanceEntity.class)); assertEquals(4, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT * FROM " + tableName).list().size()); assertEquals(4, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT count(*) FROM " + tableName).count()); assertEquals(16, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT count(*) FROM " + tableName + " H1, " + tableName + " H2").count()); // select with distinct assertEquals(4, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT DISTINCT * FROM " + tableName).list().size()); assertEquals(1, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT count(*) FROM " + tableName + " H WHERE H.ID_ = '" + id + "'").count()); assertEquals(1, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT * FROM " + tableName + " H WHERE H.ID_ = '" + id + "'").list().size()); // use parameters assertEquals(1, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT count(*) FROM " + tableName + " H WHERE H.ID_ = #{caseInstanceId}").parameter("caseInstanceId", id).count()); }
Example #16
Source File: HistoricCaseInstanceResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public HistoricCaseInstanceDto getHistoricCaseInstance() { HistoryService historyService = engine.getHistoryService(); HistoricCaseInstance instance = historyService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult(); if (instance == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Historic case instance with id '" + caseInstanceId + "' does not exist"); } return HistoricCaseInstanceDto.fromHistoricCaseInstance(instance); }
Example #17
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageWithManualActivationCase.cmmn"}) public void testDeleteHistoricCaseInstance() { CaseInstance caseInstance = createCaseInstance(); String caseInstanceId = caseInstance.getId(); HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstanceId); assertNotNull(historicInstance); try { // should not be able to delete historic case instance cause the case instance is still running historyService.deleteHistoricCaseInstance(historicInstance.getId()); fail("Exception expected"); } catch (NullValueException e) { // expected } terminate(caseInstanceId); close(caseInstanceId); identityService.setAuthenticatedUserId("testUser"); historyService.deleteHistoricCaseInstance(historicInstance.getId()); identityService.clearAuthentication(); if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_FULL.getId()) { // a user operation log should have been created assertEquals(1, historyService.createUserOperationLogQuery().count()); UserOperationLogEntry entry = historyService.createUserOperationLogQuery().singleResult(); assertEquals(UserOperationLogEntry.CATEGORY_OPERATOR, entry.getCategory()); assertEquals(EntityTypes.CASE_INSTANCE, entry.getEntityType()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE_HISTORY, entry.getOperationType()); assertEquals(caseInstanceId, entry.getCaseInstanceId()); assertNull(entry.getProperty()); assertNull(entry.getOrgValue()); assertNull(entry.getNewValue()); } assertCount(0, historicQuery()); }
Example #18
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn") public void testRetrieveCaseDefinitionKey() { // given String id = createCaseInstance("oneTaskCase").getId(); // when HistoricCaseInstance caseInstance = historyService.createHistoricCaseInstanceQuery() .caseInstanceId(id) .singleResult(); // then assertEquals("oneTaskCase", caseInstance.getCaseDefinitionKey()); }
Example #19
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn") public void testRetrieveCaseDefinitionName() { // given String id = createCaseInstance("oneTaskCase").getId(); // when HistoricCaseInstance caseInstance = historyService.createHistoricCaseInstanceQuery() .caseInstanceId(id) .singleResult(); // then assertEquals("One Task Case", caseInstance.getCaseDefinitionName()); }
Example #20
Source File: HistoricCaseInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected HistoricCaseInstance queryHistoricCaseInstance(String caseInstanceId) { HistoricCaseInstance historicCaseInstance = historicQuery() .caseInstanceId(caseInstanceId) .singleResult(); assertNotNull(historicCaseInstance); return historicCaseInstance; }
Example #21
Source File: BulkHistoryDeleteTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testCleanupHistoryCaseInstanceOperationLog() { // given // create case instances int instanceCount = 10; List<String> caseInstanceIds = prepareHistoricCaseInstance(instanceCount); // assume List<HistoricCaseInstance> caseInstanceList = historyService.createHistoricCaseInstanceQuery().list(); assertEquals(instanceCount, caseInstanceList.size()); // when identityService.setAuthenticatedUserId(USER_ID); historyService.deleteHistoricCaseInstancesBulk(caseInstanceIds); identityService.clearAuthentication(); // then assertEquals(1, historyService.createUserOperationLogQuery().operationType(OPERATION_TYPE_DELETE_HISTORY).count()); UserOperationLogEntry entry = historyService.createUserOperationLogQuery().operationType(OPERATION_TYPE_DELETE_HISTORY).singleResult(); assertEquals(UserOperationLogEntry.CATEGORY_OPERATOR, entry.getCategory()); assertEquals(EntityTypes.CASE_INSTANCE, entry.getEntityType()); assertEquals(OPERATION_TYPE_DELETE_HISTORY, entry.getOperationType()); assertNull(entry.getCaseInstanceId()); assertEquals("nrOfInstances", entry.getProperty()); assertNull(entry.getOrgValue()); assertEquals(String.valueOf(instanceCount), entry.getNewValue()); }
Example #22
Source File: HistoricCaseInstanceRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private List<HistoricCaseInstance> executePaginatedQuery(HistoricCaseInstanceQuery query, Integer firstResult, Integer maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return query.listPage(firstResult, maxResults); }
Example #23
Source File: MultiTenancyHistoricCaseInstanceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldQuerySortingDesc() { // exclude historic case instances without tenant id because of database-specific ordering List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(historicCaseInstances.size()).isEqualTo(2); assertThat(historicCaseInstances.get(0).getTenantId()).isEqualTo(TENANT_TWO); assertThat(historicCaseInstances.get(1).getTenantId()).isEqualTo(TENANT_ONE); }
Example #24
Source File: MultiTenancyHistoricCaseInstanceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldQuerySortingAsc() { // exclude historic case instances without tenant id because of database-specific ordering List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(historicCaseInstances.size()).isEqualTo(2); assertThat(historicCaseInstances.get(0).getTenantId()).isEqualTo(TENANT_ONE); assertThat(historicCaseInstances.get(1).getTenantId()).isEqualTo(TENANT_TWO); }
Example #25
Source File: HistoricCaseInstanceQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public List<HistoricCaseInstance> executeList(CommandContext commandContext, Page page) { checkQueryOk(); ensureVariablesInitialized(); return commandContext .getHistoricCaseInstanceManager() .findHistoricCaseInstancesByQueryCriteria(this, page); }
Example #26
Source File: MockProvider.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static HistoricCaseInstance createMockHistoricCaseInstanceNotClosed() { HistoricCaseInstance mock = createMockHistoricCaseInstance(); when(mock.getCloseTime()).thenReturn(null); when(mock.getDurationInMillis()).thenReturn(null); when(mock.isActive()).thenReturn(true); when(mock.isCompleted()).thenReturn(false); when(mock.isTerminated()).thenReturn(false); when(mock.isClosed()).thenReturn(false); return mock; }
Example #27
Source File: HistoricCaseInstanceManager.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public List<HistoricCaseInstance> findHistoricCaseInstancesByQueryCriteria(HistoricCaseInstanceQueryImpl historicCaseInstanceQuery, Page page) { if (isHistoryEnabled()) { configureHistoricCaseInstanceQuery(historicCaseInstanceQuery); return getDbEntityManager().selectList("selectHistoricCaseInstancesByQueryCriteria", historicCaseInstanceQuery, page); } return Collections.EMPTY_LIST; }
Example #28
Source File: HistoricCaseInstanceRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected HistoricCaseInstanceQuery setUpMockHistoricCaseInstanceQuery(List<HistoricCaseInstance> mockedHistoricCaseInstances) { HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class); when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances); when(mockedHistoricCaseInstanceQuery.count()).thenReturn((long) mockedHistoricCaseInstances.size()); when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery); return mockedHistoricCaseInstanceQuery; }
Example #29
Source File: HistoricCaseInstanceRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testCaseQueryNotClosed() { List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances(); HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class); when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances); when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery); Response response = given() .queryParam("notClosed", true) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery); inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed(); inOrder.verify(mockedHistoricCaseInstanceQuery).list(); String content = response.asString(); List<String> instances = from(content).getList(""); Assert.assertEquals(1, instances.size()); Assert.assertNotNull(instances.get(0)); String returnedCaseInstanceId = from(content).getString("[0].id"); String returnedCloseTime = from(content).getString("[0].closeTime"); Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId); Assert.assertEquals(null, returnedCloseTime); }
Example #30
Source File: HistoricCaseInstanceRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testCaseQueryNotClosedAsPost() { List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances(); HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class); when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances); when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery); Map<String, Boolean> body = new HashMap<String, Boolean>(); body.put("notClosed", true); Response response = given() .contentType(POST_JSON_CONTENT_TYPE) .body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery); inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed(); inOrder.verify(mockedHistoricCaseInstanceQuery).list(); String content = response.asString(); List<String> instances = from(content).getList(""); Assert.assertEquals(1, instances.size()); Assert.assertNotNull(instances.get(0)); String returnedCaseInstanceId = from(content).getString("[0].id"); String returnedCloseTime = from(content).getString("[0].closeTime"); Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId); Assert.assertEquals(null, returnedCloseTime); }