use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceQueryTest method testQueryByDecisionDefinitionIdIn.
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN, DRG_DMN })
public void testQueryByDecisionDefinitionIdIn() {
// given
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
String decisionDefinitionId2 = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DISH_DECISION).singleResult().getId();
// when
startProcessInstanceAndEvaluateDecision();
decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue("temperature", 21).putValue("dayType", "Weekend")).evaluate();
// then
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
assertThat(query.decisionDefinitionIdIn(decisionDefinitionId, decisionDefinitionId2).count(), is(2L));
assertThat(query.decisionDefinitionIdIn("other id", "anotherFake").count(), is(0L));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceQueryTest method testQueryByDecisionDefinitionKey.
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testQueryByDecisionDefinitionKey() {
startProcessInstanceAndEvaluateDecision();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
assertThat(query.decisionDefinitionKey(DECISION_DEFINITION_KEY).count(), is(1L));
assertThat(query.decisionDefinitionKey("other key").count(), is(0L));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testDecisionInstancePropertiesOfDecisionLiteralExpression.
@Deployment(resources = DECISION_LITERAL_EXPRESSION_DMN)
public void testDecisionInstancePropertiesOfDecisionLiteralExpression() {
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
decisionService.evaluateDecisionByKey("decision").variables(Variables.createVariables().putValue("sum", 2205)).evaluate();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().includeInputs().includeOutputs();
assertThat(query.count(), is(1L));
HistoricDecisionInstance historicDecisionInstance = query.singleResult();
assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinition.getId()));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is("decision"));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("Decision with Literal Expression"));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
assertThat(historicDecisionInstance.getInputs().size(), is(0));
List<HistoricDecisionOutputInstance> outputs = historicDecisionInstance.getOutputs();
assertThat(outputs.size(), is(1));
HistoricDecisionOutputInstance output = outputs.get(0);
assertThat(output.getVariableName(), is("result"));
assertThat(output.getTypeName(), is("string"));
assertThat((String) output.getValue(), is("ok"));
assertThat(output.getClauseId(), is(nullValue()));
assertThat(output.getClauseName(), is(nullValue()));
assertThat(output.getRuleId(), is(nullValue()));
assertThat(output.getRuleOrder(), is(nullValue()));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceQueryTest method setUpMockHistoricDecisionInstanceQuery.
protected HistoricDecisionInstanceQuery setUpMockHistoricDecisionInstanceQuery(List<HistoricDecisionInstance> mockedHistoricDecisionInstances) {
HistoricDecisionInstanceQuery mockedHistoricDecisionInstanceQuery = mock(HistoricDecisionInstanceQuery.class);
when(mockedHistoricDecisionInstanceQuery.list()).thenReturn(mockedHistoricDecisionInstances);
when(mockedHistoricDecisionInstanceQuery.count()).thenReturn((long) mockedHistoricDecisionInstances.size());
when(processEngine.getHistoryService().createHistoricDecisionInstanceQuery()).thenReturn(mockedHistoricDecisionInstanceQuery);
return mockedHistoricDecisionInstanceQuery;
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceInteractionTest method testDeleteAsyncWithQuery.
@Test
public void testDeleteAsyncWithQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(historyServiceMock.deleteHistoricDecisionInstancesAsync(anyListOf(String.class), any(HistoricDecisionInstanceQuery.class), anyString())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
HistoricDecisionInstanceQueryDto query = new HistoricDecisionInstanceQueryDto();
query.setDecisionDefinitionKey("decision");
messageBodyJson.put("historicDecisionInstanceQuery", query);
messageBodyJson.put("deleteReason", "a-delete-reason");
Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(HISTORIC_DECISION_INSTANCES_DELETE_ASYNC_URL);
verifyBatchJson(response.asString());
verify(historyServiceMock, times(1)).deleteHistoricDecisionInstancesAsync(eq((List<String>) null), any(HistoricDecisionInstanceQuery.class), eq("a-delete-reason"));
}
Aggregations