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; }
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; }
@Test public void closeCaseInstanceWithAuthenticatedTenant() { caseService.completeCaseExecution(caseInstanceId); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); caseService.closeCaseInstance(caseInstanceId); identityService.clearAuthentication(); HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance(); assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.isClosed(), is(true)); }
@Test public void closeCaseInstanceDisabledTenantCheck() { caseService.completeCaseExecution(caseInstanceId); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); caseService.closeCaseInstance(caseInstanceId); identityService.clearAuthentication(); HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance(); assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.isClosed(), is(true)); }
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; }
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; }
@Test public void closeCaseInstanceWithAuthenticatedTenant() { caseService.completeCaseExecution(caseInstanceId); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); caseService.closeCaseInstance(caseInstanceId); identityService.clearAuthentication(); HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance(); assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.isClosed(), is(true)); }
@Test public void closeCaseInstanceDisabledTenantCheck() { caseService.completeCaseExecution(caseInstanceId); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); caseService.closeCaseInstance(caseInstanceId); identityService.clearAuthentication(); HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance(); assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.isClosed(), is(true)); }
assertTrue(historicCaseInstance.isClosed()); assertCount(1, historicQuery().closed()); assertCount(0, historicQuery().notClosed());
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; }
assertTrue(historicCaseInstance.isClosed()); assertCount(1, historicQuery().closed()); assertCount(0, historicQuery().notClosed());