Search in sources :

Example 1 with HistoricCaseInstance

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

the class HistoricCaseInstanceRestServiceImpl method queryHistoricCaseInstances.

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;
}
Also used : HistoricCaseInstanceDto(org.camunda.bpm.engine.rest.dto.history.HistoricCaseInstanceDto) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) ArrayList(java.util.ArrayList) HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)

Example 2 with HistoricCaseInstance

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

the class HistoricCaseInstanceRestServiceQueryTest method testCaseQueryNotClosed.

@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);
}
Also used : Response(com.jayway.restassured.response.Response) InOrder(org.mockito.InOrder) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 3 with HistoricCaseInstance

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

the class MockProvider method createMockHistoricCaseInstanceNotClosed.

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;
}
Also used : HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance)

Example 4 with HistoricCaseInstance

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

the class MultiTenancyCaseInstanceCmdsTenantCheckTest method terminateCaseExecutionWithAuthenticatedTenant.

@Test
public void terminateCaseExecutionWithAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    caseService.terminateCaseExecution(caseInstanceId);
    HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance();
    assertThat(historicCaseInstance, notNullValue());
    assertThat(historicCaseInstance.isTerminated(), is(true));
}
Also used : HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) Test(org.junit.Test)

Example 5 with HistoricCaseInstance

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

the class MultiTenancyCaseInstanceCmdsTenantCheckTest method closeCaseInstanceWithAuthenticatedTenant.

@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));
}
Also used : HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) Test(org.junit.Test)

Aggregations

HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)30 Deployment (org.camunda.bpm.engine.test.Deployment)14 HistoricCaseInstanceQuery (org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)3 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)3 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)3 After (org.junit.After)3 Response (com.jayway.restassured.response.Response)2 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)2 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 InOrder (org.mockito.InOrder)2 HashMap (java.util.HashMap)1 HistoryService (org.camunda.bpm.engine.HistoryService)1