Search in sources :

Example 1 with CasePlanModel

use of org.camunda.bpm.model.cmmn.instance.CasePlanModel in project camunda-cmmn-model by camunda.

the class CreateModelTest method createCaseWithOneHumanTask.

@Test
public void createCaseWithOneHumanTask() {
    // create process
    Case caseInstance = createElement(definitions, "case-with-one-human-task", Case.class);
    // create case plan model
    CasePlanModel casePlanModel = createElement(caseInstance, "casePlanModel_1", CasePlanModel.class);
    // create elements
    HumanTask humanTask = createElement(casePlanModel, "HumanTask_1", HumanTask.class);
    // create a plan item
    PlanItem planItem = createElement(casePlanModel, "PlanItem_1", PlanItem.class);
    // set definition to human task
    planItem.setDefinition(humanTask);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Case(org.camunda.bpm.model.cmmn.instance.Case) Test(org.junit.Test)

Example 2 with CasePlanModel

use of org.camunda.bpm.model.cmmn.instance.CasePlanModel in project camunda-cmmn-model by camunda.

the class GenerateIdTest method shouldNotGenerateIdsOnRead.

@Test
public void shouldNotGenerateIdsOnRead() {
    CmmnModelInstance modelInstance = Cmmn.readModelFromStream(GenerateIdTest.class.getResourceAsStream("GenerateIdTest.cmmn"));
    Definitions definitions = modelInstance.getDefinitions();
    assertThat(definitions.getId()).isNull();
    Case caseElement = modelInstance.getModelElementsByType(Case.class).iterator().next();
    assertThat(caseElement.getId()).isNull();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    assertThat(casePlanModel.getId()).isNull();
    HumanTask humanTask = modelInstance.getModelElementsByType(HumanTask.class).iterator().next();
    assertThat(humanTask.getId()).isNull();
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Definitions(org.camunda.bpm.model.cmmn.instance.Definitions) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) Case(org.camunda.bpm.model.cmmn.instance.Case) Test(org.junit.Test)

Example 3 with CasePlanModel

use of org.camunda.bpm.model.cmmn.instance.CasePlanModel in project camunda-cmmn-model by camunda.

the class SimpleTest method shouldGetElements.

@Test
@CmmnModelResource
public void shouldGetElements() {
    ModelElementInstance modelElementById = cmmnModelInstance.getModelElementById("Case_1");
    assertThat(modelElementById).isNotNull();
    Collection<Case> caseElements = cmmnModelInstance.getDefinitions().getCases();
    assertThat(caseElements).hasSize(1);
    Case caseElement = caseElements.iterator().next();
    assertThat(caseElement.getId()).isEqualTo("Case_1");
    assertThat(caseElement.getName()).isNull();
    CasePlanModel casePlanModel = caseElement.getCasePlanModel();
    assertThat(casePlanModel).isNotNull();
    assertThat(casePlanModel.getId()).isEqualTo("CasePlanModel_1");
    Collection<PlanItemDefinition> planItemDefinitions = casePlanModel.getPlanItemDefinitions();
    assertThat(planItemDefinitions).hasSize(1);
    PlanItemDefinition planItemDefinition = planItemDefinitions.iterator().next();
    assertThat(planItemDefinition).isInstanceOf(HumanTask.class);
    assertThat(planItemDefinition.getId()).isEqualTo("HumanTask_1");
    assertThat(planItemDefinition.getName()).isEqualTo("A HumanTask");
    Collection<PlanItem> planItems = casePlanModel.getPlanItems();
    PlanItem planItem = planItems.iterator().next();
    assertThat(planItem.getId()).isEqualTo("PI_HumanTask_1");
    assertThat(planItem.getDefinition()).isEqualTo(planItemDefinition);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Case(org.camunda.bpm.model.cmmn.instance.Case) CmmnModelResource(org.camunda.bpm.model.cmmn.util.CmmnModelResource) Test(org.junit.Test)

Example 4 with CasePlanModel

use of org.camunda.bpm.model.cmmn.instance.CasePlanModel in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldNotAbleToAddCmmn10Element.

@Test
public void shouldNotAbleToAddCmmn10Element() {
    CmmnModelInstance modelInstance = Cmmn.readModelFromStream(Cmmn10Test.class.getResourceAsStream("Cmmn11Test.cmmn"));
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    Event event = modelInstance.newInstance(Event.class);
    casePlanModel.getPlanItemDefinitions().add(event);
    try {
        Cmmn.writeModelToStream(System.out, modelInstance);
        fail("cannot save cmmn 1.1 model");
    } catch (Exception e) {
    // expected exception
    }
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) TimerEvent(org.camunda.bpm.model.cmmn.instance.TimerEvent) Event(org.camunda.bpm.model.cmmn.instance.Event) UserEvent(org.camunda.bpm.model.cmmn.instance.UserEvent) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Example 5 with CasePlanModel

use of org.camunda.bpm.model.cmmn.instance.CasePlanModel in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldReturnCmmn11Namespace.

@Test
public void shouldReturnCmmn11Namespace() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    assertThat(casePlanModel.getElementType().getTypeNamespace()).isEqualTo(CmmnModelConstants.CMMN11_NS);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Aggregations

CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)15 Test (org.junit.Test)10 Case (org.camunda.bpm.model.cmmn.instance.Case)9 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)6 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)5 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)4 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)2 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)2 Before (org.junit.Before)2 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)1 CmmnHandlerContext (org.camunda.bpm.engine.impl.cmmn.handler.CmmnHandlerContext)1 DefaultCmmnElementHandlerRegistry (org.camunda.bpm.engine.impl.cmmn.handler.DefaultCmmnElementHandlerRegistry)1 CmmnTransform (org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransform)1 CmmnTransformer (org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformer)1 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)1 DeploymentEntity (org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity)1 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)1 PluggableProcessEngineTestCase (org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase)1 Documentation (org.camunda.bpm.model.cmmn.instance.Documentation)1