Search in sources :

Example 1 with CaseInstance

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

the class CaseInstanceRestServiceImpl method queryCaseInstances.

public List<CaseInstanceDto> queryCaseInstances(CaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    CaseInstanceQuery query = queryDto.toQuery(engine);
    List<CaseInstance> matchingInstances;
    if (firstResult != null || maxResults != null) {
        matchingInstances = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingInstances = query.list();
    }
    List<CaseInstanceDto> instanceResults = new ArrayList<CaseInstanceDto>();
    for (CaseInstance instance : matchingInstances) {
        CaseInstanceDto resultInstance = CaseInstanceDto.fromCaseInstance(instance);
        instanceResults.add(resultInstance);
    }
    return instanceResults;
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) ArrayList(java.util.ArrayList) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 2 with CaseInstance

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

the class ProcessEngineRestServiceTest method createCaseInstanceMock.

private void createCaseInstanceMock() {
    List<CaseInstance> caseInstances = new ArrayList<CaseInstance>();
    CaseInstance mockCaseInstance = MockProvider.createMockCaseInstance();
    caseInstances.add(mockCaseInstance);
    CaseInstanceQuery mockCaseInstanceQuery = mock(CaseInstanceQuery.class);
    when(mockCaseInstanceQuery.list()).thenReturn(caseInstances);
    when(mockCaseService.createCaseInstanceQuery()).thenReturn(mockCaseInstanceQuery);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) ArrayList(java.util.ArrayList) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery)

Example 3 with CaseInstance

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

the class CaseInstanceRestServiceInteractionTest method setUpRuntime.

@Before
public void setUpRuntime() {
    CaseInstance mockCaseInstance = MockProvider.createMockCaseInstance();
    caseServiceMock = mock(CaseService.class);
    when(processEngine.getCaseService()).thenReturn(caseServiceMock);
    caseInstanceQueryMock = mock(CaseInstanceQuery.class);
    when(caseServiceMock.createCaseInstanceQuery()).thenReturn(caseInstanceQueryMock);
    when(caseInstanceQueryMock.caseInstanceId(MockProvider.EXAMPLE_CASE_INSTANCE_ID)).thenReturn(caseInstanceQueryMock);
    when(caseInstanceQueryMock.singleResult()).thenReturn(mockCaseInstance);
    when(caseServiceMock.getVariableTyped(anyString(), eq(EXAMPLE_VARIABLE_KEY), anyBoolean())).thenReturn(EXAMPLE_VARIABLE_VALUE);
    when(caseServiceMock.getVariableTyped(anyString(), eq(EXAMPLE_BYTES_VARIABLE_KEY), eq(false))).thenReturn(EXAMPLE_VARIABLE_VALUE_BYTES);
    when(caseServiceMock.getVariablesTyped(anyString(), eq(true))).thenReturn(EXAMPLE_VARIABLES);
    when(caseServiceMock.getVariablesTyped(anyString(), Matchers.<Collection<String>>any(), eq(true))).thenReturn(EXAMPLE_VARIABLES);
    caseExecutionCommandBuilderMock = mock(CaseExecutionCommandBuilder.class);
    when(caseServiceMock.withCaseExecution(MockProvider.EXAMPLE_CASE_INSTANCE_ID)).thenReturn(caseExecutionCommandBuilderMock);
    when(caseExecutionCommandBuilderMock.setVariable(anyString(), any())).thenReturn(caseExecutionCommandBuilderMock);
    when(caseExecutionCommandBuilderMock.setVariables(Matchers.<Map<String, Object>>any())).thenReturn(caseExecutionCommandBuilderMock);
    when(caseExecutionCommandBuilderMock.removeVariable(anyString())).thenReturn(caseExecutionCommandBuilderMock);
    when(caseExecutionCommandBuilderMock.removeVariables(Matchers.<Collection<String>>any())).thenReturn(caseExecutionCommandBuilderMock);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseService(org.camunda.bpm.engine.CaseService) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseExecutionCommandBuilder(org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder) Before(org.junit.Before)

Example 4 with CaseInstance

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

the class CaseDefinitionRestServiceInteractionTest method setUpRuntime.

@Before
public void setUpRuntime() {
    CaseDefinition mockCaseDefinition = MockProvider.createMockCaseDefinition();
    setUpRuntimeData(mockCaseDefinition);
    caseServiceMock = mock(CaseService.class);
    when(processEngine.getCaseService()).thenReturn(caseServiceMock);
    caseInstanceBuilder = mock(CaseInstanceBuilder.class);
    CaseInstance mockCaseInstance = MockProvider.createMockCaseInstance();
    when(caseServiceMock.withCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID)).thenReturn(caseInstanceBuilder);
    when(caseInstanceBuilder.businessKey(anyString())).thenReturn(caseInstanceBuilder);
    when(caseInstanceBuilder.setVariables(Matchers.<Map<String, Object>>any())).thenReturn(caseInstanceBuilder);
    when(caseInstanceBuilder.create()).thenReturn(mockCaseInstance);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceBuilder(org.camunda.bpm.engine.runtime.CaseInstanceBuilder) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseService(org.camunda.bpm.engine.CaseService) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Before(org.junit.Before)

Example 5 with CaseInstance

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

the class CaseInstanceResourceImpl method getCaseInstance.

public CaseInstanceDto getCaseInstance() {
    CaseService caseService = engine.getCaseService();
    CaseInstance instance = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
    if (instance == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Case instance with id " + caseInstanceId + " does not exist.");
    }
    CaseInstanceDto result = CaseInstanceDto.fromCaseInstance(instance);
    return result;
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseService(org.camunda.bpm.engine.CaseService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) CaseInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto)

Aggregations

CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)183 Deployment (org.camunda.bpm.engine.test.Deployment)149 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)62 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)23 Test (org.junit.Test)21 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)18 Task (org.camunda.bpm.engine.task.Task)18 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)16 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)13 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)10 HashMap (java.util.HashMap)9 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)9 ArrayList (java.util.ArrayList)6 CaseService (org.camunda.bpm.engine.CaseService)6 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)6 Date (java.util.Date)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)5 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 VariableMap (org.camunda.bpm.engine.variable.VariableMap)5