Search in sources :

Example 11 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DecisionDefinitionDeployerTest method testDeployEmptyDecisionDefinition.

@Test
public void testDeployEmptyDecisionDefinition() throws Exception {
    // given empty decision model
    DmnModelInstance modelInstance = Dmn.createEmptyModel();
    Definitions definitions = modelInstance.newInstance(Definitions.class);
    definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
    definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
    definitions.setNamespace(DmnModelConstants.CAMUNDA_NS);
    modelInstance.setDefinitions(definitions);
    // when decision model is deployed
    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", modelInstance);
    DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder);
    // then deployment contains no definitions
    assertNull(deployment.getDeployedDecisionDefinitions());
    assertNull(deployment.getDeployedDecisionRequirementsDefinitions());
    // and there are no persisted definitions
    assertNull(repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName("foo.dmn").singleResult());
}
Also used : Definitions(org.camunda.bpm.model.dmn.instance.Definitions) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test)

Example 12 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DecisionDefinitionDeployerTest method testDeployAndGetDecisionDefinition.

@Test
public void testDeployAndGetDecisionDefinition() throws Exception {
    // given decision model
    DmnModelInstance dmnModelInstance = createDmnModelInstance();
    // when decision model is deployed
    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance);
    DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder);
    // then deployment contains definition
    List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions();
    assertEquals(1, deployedDecisionDefinitions.size());
    assertNull(deployment.getDeployedDecisionRequirementsDefinitions());
    assertNull(deployment.getDeployedProcessDefinitions());
    assertNull(deployment.getDeployedCaseDefinitions());
    // and persisted definition are equal to deployed definition
    DecisionDefinition persistedDecisionDef = repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName("foo.dmn").singleResult();
    assertEquals(persistedDecisionDef.getId(), deployedDecisionDefinitions.get(0).getId());
}
Also used : DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test)

Example 13 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class DmnModelElementInstanceCmdTest method testRepositoryService.

@Deployment(resources = "org/camunda/bpm/engine/test/repository/one.dmn")
public void testRepositoryService() {
    String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_KEY).singleResult().getId();
    DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);
    assertNotNull(modelInstance);
    Collection<Decision> decisions = modelInstance.getModelElementsByType(Decision.class);
    assertEquals(1, decisions.size());
    Collection<DecisionTable> decisionTables = modelInstance.getModelElementsByType(DecisionTable.class);
    assertEquals(1, decisionTables.size());
    Collection<Input> inputs = modelInstance.getModelElementsByType(Input.class);
    assertEquals(1, inputs.size());
    Collection<Output> outputs = modelInstance.getModelElementsByType(Output.class);
    assertEquals(1, outputs.size());
    Collection<Rule> rules = modelInstance.getModelElementsByType(Rule.class);
    assertEquals(2, rules.size());
}
Also used : DecisionTable(org.camunda.bpm.model.dmn.instance.DecisionTable) Input(org.camunda.bpm.model.dmn.instance.Input) Output(org.camunda.bpm.model.dmn.instance.Output) Rule(org.camunda.bpm.model.dmn.instance.Rule) Decision(org.camunda.bpm.model.dmn.instance.Decision) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyDecisionDefinitionCmdsTenantCheckTest method getDmnModelInstanceDisabledTenantCheck.

@Test
public void getDmnModelInstanceDisabledTenantCheck() {
    processEngineConfiguration.setTenantCheckEnabled(false);
    identityService.setAuthentication("user", null, null);
    DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);
    assertThat(modelInstance, notNullValue());
}
Also used : DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test)

Example 15 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyDecisionDefinitionCmdsTenantCheckTest method getDmnModelInstanceWithAuthenticatedTenant.

@Test
public void getDmnModelInstanceWithAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);
    assertThat(modelInstance, notNullValue());
}
Also used : DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test)

Aggregations

DmnModelInstance (org.camunda.bpm.model.dmn.DmnModelInstance)21 Test (org.junit.Test)16 InputStream (java.io.InputStream)10 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)10 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)5 Decision (org.camunda.bpm.model.dmn.instance.Decision)4 DmnTransformException (org.camunda.bpm.dmn.engine.impl.transform.DmnTransformException)3 Definitions (org.camunda.bpm.model.dmn.instance.Definitions)3 DecisionTable (org.camunda.bpm.model.dmn.instance.DecisionTable)2 Input (org.camunda.bpm.model.dmn.instance.Input)2 Output (org.camunda.bpm.model.dmn.instance.Output)2 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 InputExpression (org.camunda.bpm.model.dmn.instance.InputExpression)1 Rule (org.camunda.bpm.model.dmn.instance.Rule)1 Text (org.camunda.bpm.model.dmn.instance.Text)1