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());
}
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());
}
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());
}
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;
}
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;
}
Aggregations