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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations