Search in sources :

Example 16 with DecisionDefinition

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

the class MultiTenancyDecisionDefinitionQueryTest method testQueryByLatestWithTenantIds.

public void testQueryByLatestWithTenantIds() {
    // deploy a second version for tenant one
    deploymentForTenant(TENANT_ONE, DMN);
    DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO).orderByTenantId().asc();
    // one definition for each tenant
    assertThat(query.count(), is(2L));
    Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list());
    assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2));
    assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
}
Also used : DecisionDefinitionQuery(org.camunda.bpm.engine.repository.DecisionDefinitionQuery) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 17 with DecisionDefinition

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

the class HistoryCleanupAuthorizationTest method prepareInstances.

protected void prepareInstances(Integer processInstanceTimeToLive, Integer decisionTimeToLive, Integer caseTimeToLive) {
    // update time to live
    disableAuthorization();
    List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testProcess").list();
    assertEquals(1, processDefinitions.size());
    repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinitions.get(0).getId(), processInstanceTimeToLive);
    final List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey("testDecision").list();
    assertEquals(1, decisionDefinitions.size());
    repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), decisionTimeToLive);
    List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").list();
    assertEquals(1, caseDefinitions.size());
    repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitions.get(0).getId(), caseTimeToLive);
    Date oldCurrentTime = ClockUtil.getCurrentTime();
    ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, -6));
    // create 3 process instances
    List<String> processInstanceIds = new ArrayList<String>();
    Map<String, Object> variables = Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37));
    for (int i = 0; i < 3; i++) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess", variables);
        processInstanceIds.add(processInstance.getId());
    }
    runtimeService.deleteProcessInstances(processInstanceIds, null, true, true);
    // +10 standalone decisions
    for (int i = 0; i < 10; i++) {
        decisionService.evaluateDecisionByKey("testDecision").variables(variables).evaluate();
    }
    // create 4 case instances
    for (int i = 0; i < 4; i++) {
        CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37 + i)));
        caseService.terminateCaseExecution(caseInstance.getId());
        caseService.closeCaseInstance(caseInstance.getId());
    }
    ClockUtil.setCurrentTime(oldCurrentTime);
    enableAuthorization();
}
Also used : ArrayList(java.util.ArrayList) TestPojo(org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Date(java.util.Date) CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 18 with DecisionDefinition

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

the class DecisionDefinitionAuthorizationTest method testQueryWithReadPermissionOnOneDecisionDefinition.

public void testQueryWithReadPermissionOnOneDecisionDefinition() {
    // given user gets read permission on the decision definition
    createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
    // when
    DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery();
    // then
    verifyQueryResults(query, 1);
    DecisionDefinition definition = query.singleResult();
    assertNotNull(definition);
    assertEquals(DECISION_DEFINITION_KEY, definition.getKey());
}
Also used : DecisionDefinitionQuery(org.camunda.bpm.engine.repository.DecisionDefinitionQuery) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 19 with DecisionDefinition

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

the class DecisionDefinitionAuthorizationTest method testGetDecisionDefinition.

public void testGetDecisionDefinition() {
    // given
    String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
    createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
    // when
    DecisionDefinition decisionDefinition = repositoryService.getDecisionDefinition(decisionDefinitionId);
    // then
    assertNotNull(decisionDefinition);
}
Also used : DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 20 with DecisionDefinition

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

the class EvaluateDecisionAuthorizationTest method evaluateDecisionById.

@Test
@Deployment(resources = DMN_FILE)
public void evaluateDecisionById() {
    // given
    DecisionDefinition decisionDefinition = engineRule.getRepositoryService().createDecisionDefinitionQuery().singleResult();
    // when
    authRule.init(scenario).withUser("userId").bindResource("decisionDefinitionKey", DECISION_DEFINITION_KEY).start();
    DmnDecisionTableResult decisionResult = engineRule.getDecisionService().evaluateDecisionTableById(decisionDefinition.getId(), createVariables());
    // then
    if (authRule.assertScenario(scenario)) {
        assertThatDecisionHasExpectedResult(decisionResult);
    }
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)68 Test (org.junit.Test)21 Deployment (org.camunda.bpm.engine.test.Deployment)18 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 Date (java.util.Date)6 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricDecisionInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity)3 Response (com.jayway.restassured.response.Response)2 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)2