Search in sources :

Example 16 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticForRootDecisionEvaluation.

@Test
public void testStatisticForRootDecisionEvaluation() 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();
    HistoricDecisionInstanceStatisticsQuery statisticsQuery = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId());
    // then
    assertThat(statisticsQuery.count(), is(3L));
    assertThat(statisticsQuery.list().size(), is(3));
    assertThat(statisticsQuery.list().get(0).getEvaluations(), is(2));
    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 17 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticForNotEvaluatedDRD.

@Test
public void testStatisticForNotEvaluatedDRD() throws Exception {
    // when
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
    HistoricDecisionInstanceStatisticsQuery statisticsQuery = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId());
    // then
    assertThat("available statistics count", statisticsQuery.count(), is(0L));
    assertThat("available statistics elements", statisticsQuery.list().size(), is(0));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstanceStatisticsQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery) Test(org.junit.Test)

Example 18 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticForRootDecisionWithFakeInstanceConstraintEvaluation.

@Test
public void testStatisticForRootDecisionWithFakeInstanceConstraintEvaluation() throws Exception {
    // when
    decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND)).evaluate();
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
    HistoricDecisionInstanceStatisticsQuery query = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.getId()).decisionInstanceId(NON_EXISTING);
    // then
    assertThat(query.count(), is(0L));
    assertThat(query.list().size(), is(0));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstanceStatisticsQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery) Test(org.junit.Test)

Example 19 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceStatisticsQueryTest method testStatisticConstrainedToOneDRD.

@Test
public void testStatisticConstrainedToOneDRD() throws Exception {
    // given
    testRule.deploy(SCORE_DRG_DMN);
    // when
    decisionService.evaluateDecisionTableByKey("score-decision").variables(Variables.createVariables().putValue("input", "john")).evaluate();
    decisionService.evaluateDecisionTableByKey("season").variables(Variables.createVariables().putValue(TEMPERATURE, 21)).evaluate();
    DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().decisionRequirementsDefinitionName("Score").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 20 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition 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)

Aggregations

DecisionRequirementsDefinition (org.camunda.bpm.engine.repository.DecisionRequirementsDefinition)40 Test (org.junit.Test)25 HistoricDecisionInstanceStatisticsQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery)13 DecisionRequirementsDefinitionQuery (org.camunda.bpm.engine.repository.DecisionRequirementsDefinitionQuery)9 Deployment (org.camunda.bpm.engine.test.Deployment)6 InputStream (java.io.InputStream)5 Response (com.jayway.restassured.response.Response)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 DecisionService (org.camunda.bpm.engine.DecisionService)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 NullValueException (org.camunda.bpm.engine.exception.NullValueException)1 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)1 NativeHistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery)1