Search in sources :

Example 11 with HistoricDecisionInstanceStatisticsQuery

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

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticForRootDecisionWithNullInstanceConstraintEvaluation.

@Test
public void testStatisticForRootDecisionWithNullInstanceConstraintEvaluation() throws Exception {
    // when
    decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND)).evaluate();
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
    // when
    HistoricDecisionInstanceStatisticsQuery query = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId()).decisionInstanceId(null);
    // then
    try {
        query.count();
    } catch (NullValueException e) {
    // expected
    }
    try {
        query.list();
    } catch (NullValueException e) {
    // expected
    }
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstanceStatisticsQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery) NullValueException(org.camunda.bpm.engine.exception.NullValueException) Test(org.junit.Test)

Example 12 with HistoricDecisionInstanceStatisticsQuery

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

the class MultiTenancySharedDecisionInstanceStatisticsQueryTest method testQueryNoAuthenticatedTenants.

@Test
public void testQueryNoAuthenticatedTenants() {
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
    identityService.setAuthentication(USER_ID, null, null);
    HistoricDecisionInstanceStatisticsQuery query = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId());
    assertThat(query.count(), is(0L));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstanceStatisticsQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery) Test(org.junit.Test)

Example 13 with HistoricDecisionInstanceStatisticsQuery

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

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticForChildDecisionEvaluation.

@Test
public void testStatisticForChildDecisionEvaluation() throws Exception {
    // when
    decisionService.evaluateDecisionTableByKey("season").variables(Variables.createVariables().putValue(TEMPERATURE, 21)).evaluate();
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
    HistoricDecisionInstanceStatisticsQuery statisticsQuery = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId());
    // then
    assertThat(statisticsQuery.count(), is(1L));
    assertThat(statisticsQuery.list().size(), is(1));
    assertThat(statisticsQuery.list().get(0).getEvaluations(), is(1));
    assertThat(statisticsQuery.list().get(0).getDecisionDefinitionKey(), is(notNullValue()));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstanceStatisticsQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery) Test(org.junit.Test)

Example 14 with HistoricDecisionInstanceStatisticsQuery

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

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticForRootDecisionWithInstanceConstraintEvaluation.

@Test
public void testStatisticForRootDecisionWithInstanceConstraintEvaluation() throws Exception {
    // when
    decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND)).evaluate();
    decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 11).putValue(DAY_TYPE, WEEKEND)).evaluate();
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
    String decisionInstanceId = engineRule.getHistoryService().createHistoricDecisionInstanceQuery().decisionRequirementsDefinitionId(decisionRequirementsDefinition.getId()).rootDecisionInstancesOnly().list().get(0).getId();
    HistoricDecisionInstanceStatisticsQuery query = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId()).decisionInstanceId(decisionInstanceId);
    // then
    assertThat(query.count(), is(3L));
    assertThat(query.list().size(), is(3));
    assertThat(query.list().get(0).getEvaluations(), is(1));
    assertThat(query.list().get(0).getDecisionDefinitionKey(), is(notNullValue()));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstanceStatisticsQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery) Test(org.junit.Test)

Aggregations

HistoricDecisionInstanceStatisticsQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery)14 DecisionRequirementsDefinition (org.camunda.bpm.engine.repository.DecisionRequirementsDefinition)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)1 NullValueException (org.camunda.bpm.engine.exception.NullValueException)1 HistoricDecisionInstanceStatistics (org.camunda.bpm.engine.history.HistoricDecisionInstanceStatistics)1 HistoricDecisionInstanceStatisticsDto (org.camunda.bpm.engine.rest.dto.history.HistoricDecisionInstanceStatisticsDto)1