Search in sources :

Example 11 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-bpm-platform by camunda.

the class CmmnDeployerTest method testDeployAndGetCaseDefinition.

public void testDeployAndGetCaseDefinition() throws Exception {
    // given case model
    final CmmnModelInstance modelInstance = createCmmnModelInstance();
    // when case model is deployed
    DeploymentWithDefinitions deployment = repositoryService.createDeployment().addModelInstance("foo.cmmn", modelInstance).deployWithResult();
    deploymentIds.add(deployment.getId());
    // then deployment contains deployed case definition
    List<CaseDefinition> deployedCaseDefinitions = deployment.getDeployedCaseDefinitions();
    assertEquals(1, deployedCaseDefinitions.size());
    assertNull(deployment.getDeployedProcessDefinitions());
    assertNull(deployment.getDeployedDecisionDefinitions());
    assertNull(deployment.getDeployedDecisionRequirementsDefinitions());
    // and persisted case definition is equal to deployed case definition
    CaseDefinition persistedCaseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult();
    assertEquals(persistedCaseDefinition.getId(), deployedCaseDefinitions.get(0).getId());
}
Also used : CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance)

Example 12 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-bpm-platform by camunda.

the class CmmnDeployerTest method testDeployCmmnModelInstance.

public void testDeployCmmnModelInstance() throws Exception {
    // given
    CmmnModelInstance modelInstance = createCmmnModelInstance();
    // when
    deploymentWithBuilder(repositoryService.createDeployment().addModelInstance("foo.cmmn", modelInstance));
    // then
    assertNotNull(repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult());
}
Also used : CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance)

Example 13 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-bpm-platform by camunda.

the class CmmnDeployerTest method testDeployEmptyCaseDefinition.

public void testDeployEmptyCaseDefinition() throws Exception {
    // given empty case model
    final CmmnModelInstance modelInstance = Cmmn.createEmptyModel();
    org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(org.camunda.bpm.model.cmmn.instance.Definitions.class);
    definitions.setTargetNamespace("http://camunda.org/examples");
    modelInstance.setDefinitions(definitions);
    // when case model is deployed
    DeploymentWithDefinitions deployment = repositoryService.createDeployment().addModelInstance("foo.cmmn", modelInstance).deployWithResult();
    deploymentIds.add(deployment.getId());
    // then no case definition is deployed
    assertNull(deployment.getDeployedCaseDefinitions());
    // and there exist not persisted case definition
    assertNull(repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult());
}
Also used : CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance)

Example 14 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-bpm-platform by camunda.

the class DeployCmd method retrieveProcessKeysFromResources.

protected Set<String> retrieveProcessKeysFromResources(Map<String, ResourceEntity> resources) {
    Set<String> keys = new HashSet<String>();
    for (ResourceEntity resource : resources.values()) {
        if (isBpmnResource(resource)) {
            ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes());
            BpmnModelInstance model = Bpmn.readModelFromStream(byteStream);
            for (Process process : model.getDefinitions().getChildElementsByType(Process.class)) {
                keys.add(process.getId());
            }
        } else if (isCmmnResource(resource)) {
            ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes());
            CmmnModelInstance model = Cmmn.readModelFromStream(byteStream);
            for (Case cmmnCase : model.getDefinitions().getCases()) {
                keys.add(cmmnCase.getId());
            }
        }
    }
    return keys;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) HashSet(java.util.HashSet) Case(org.camunda.bpm.model.cmmn.instance.Case)

Example 15 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-bpm-platform by camunda.

the class CmmnDeployerTest method createCmmnModelInstance.

protected static CmmnModelInstance createCmmnModelInstance() {
    final CmmnModelInstance modelInstance = Cmmn.createEmptyModel();
    org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(org.camunda.bpm.model.cmmn.instance.Definitions.class);
    definitions.setTargetNamespace("http://camunda.org/examples");
    modelInstance.setDefinitions(definitions);
    Case caseElement = modelInstance.newInstance(Case.class);
    caseElement.setId("a-case");
    definitions.addChildElement(caseElement);
    CasePlanModel casePlanModel = modelInstance.newInstance(CasePlanModel.class);
    caseElement.setCasePlanModel(casePlanModel);
    Cmmn.writeModelToStream(System.out, modelInstance);
    return modelInstance;
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Case(org.camunda.bpm.model.cmmn.instance.Case) PluggableProcessEngineTestCase(org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase)

Aggregations

CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)22 Test (org.junit.Test)14 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)6 Case (org.camunda.bpm.model.cmmn.instance.Case)4 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)4 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)3 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)2 PluggableProcessEngineTestCase (org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase)2 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)2 Event (org.camunda.bpm.model.cmmn.instance.Event)2 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)2 TimerEvent (org.camunda.bpm.model.cmmn.instance.TimerEvent)2 UserEvent (org.camunda.bpm.model.cmmn.instance.UserEvent)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)1