Search in sources :

Example 41 with HistoricDecisionInstanceQuery

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

Example 42 with HistoricDecisionInstanceQuery

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

Example 43 with HistoricDecisionInstanceQuery

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()));
}
Also used : HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 44 with HistoricDecisionInstanceQuery

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

Example 45 with HistoricDecisionInstanceQuery

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"));
}
Also used : Response(com.jayway.restassured.response.Response) Batch(org.camunda.bpm.engine.batch.Batch) HashMap(java.util.HashMap) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) HistoricDecisionInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricDecisionInstanceQueryDto) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Aggregations

HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)82 Deployment (org.camunda.bpm.engine.test.Deployment)37 NativeHistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery)36 Test (org.junit.Test)22 Batch (org.camunda.bpm.engine.batch.Batch)17 Job (org.camunda.bpm.engine.runtime.Job)9 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)7 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)7 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)6 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)4 Response (com.jayway.restassured.response.Response)3 HashMap (java.util.HashMap)3 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Date (java.util.Date)2 List (java.util.List)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)2 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)2 DecisionRequirementsDefinition (org.camunda.bpm.engine.repository.DecisionRequirementsDefinition)2