use of org.camunda.bpm.model.bpmn.util.BpmnModelResource in project camunda-bpmn-model by camunda.
the class ProcessTest method shouldImportProcess.
@Test
@BpmnModelResource
public void shouldImportProcess() {
ModelElementInstance modelElementById = bpmnModelInstance.getModelElementById("exampleProcessId");
assertThat(modelElementById).isNotNull();
Collection<RootElement> rootElements = bpmnModelInstance.getDefinitions().getRootElements();
assertThat(rootElements).hasSize(1);
org.camunda.bpm.model.bpmn.instance.Process process = (Process) rootElements.iterator().next();
assertThat(process.getId()).isEqualTo("exampleProcessId");
assertThat(process.getName()).isNull();
assertThat(process.getProcessType()).isEqualTo(ProcessType.None);
assertThat(process.isExecutable()).isFalse();
assertThat(process.isClosed()).isFalse();
}
use of org.camunda.bpm.model.bpmn.util.BpmnModelResource in project camunda-bpmn-model by camunda.
the class DefinitionsTest method shouldNotAffectComments.
@Test
@BpmnModelResource
public void shouldNotAffectComments() throws IOException {
Definitions definitions = bpmnModelInstance.getDefinitions();
assertThat(definitions).isNotNull();
// create another Process element and add it to the definitions
Process process = bpmnModelInstance.newInstance(Process.class);
process.setId("another-process-id");
definitions.getRootElements().add(process);
// create another Import element and add it to the definitions
Import importElement = bpmnModelInstance.newInstance(Import.class);
importElement.setNamespace("Imports");
importElement.setLocation("there");
importElement.setImportType("example");
definitions.getImports().add(importElement);
// validate model
try {
Bpmn.validateModel(bpmnModelInstance);
} catch (ModelValidationException e) {
Assert.fail();
}
// convert the model to the XML string representation
OutputStream outputStream = new ByteArrayOutputStream();
Bpmn.writeModelToStream(outputStream, bpmnModelInstance);
InputStream inputStream = IoUtil.convertOutputStreamToInputStream(outputStream);
String modelString = IoUtil.getStringFromInputStream(inputStream);
IoUtil.closeSilently(outputStream);
IoUtil.closeSilently(inputStream);
// read test process from file as string
inputStream = getClass().getResourceAsStream("DefinitionsTest.shouldNotAffectCommentsResult.bpmn");
String fileString = IoUtil.getStringFromInputStream(inputStream);
IoUtil.closeSilently(inputStream);
// compare strings
assertThat(modelString).endsWith(fileString);
}
Aggregations