use of io.camunda.zeebe.model.bpmn.instance.Definitions in project zeebe by camunda.
the class ProcessBuilderTest method testCreateEmptyProcess.
@Test
public void testCreateEmptyProcess() {
modelInstance = Bpmn.createProcess().done();
final Definitions definitions = modelInstance.getDefinitions();
assertThat(definitions).isNotNull();
assertThat(definitions.getTargetNamespace()).isEqualTo(BPMN20_NS);
final Collection<ModelElementInstance> processes = modelInstance.getModelElementsByType(processType);
assertThat(processes).hasSize(1);
final Process process = (Process) processes.iterator().next();
assertThat(process.getId()).isNotNull();
}
use of io.camunda.zeebe.model.bpmn.instance.Definitions in project zeebe by camunda.
the class DefinitionsTest method shouldNotAffectComments.
@Test
@BpmnModelResource
public void shouldNotAffectComments() throws IOException {
final Definitions definitions = bpmnModelInstance.getDefinitions();
assertThat(definitions).isNotNull();
// create another Process element and add it to the definitions
final 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
final 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 (final ModelValidationException e) {
Assert.fail();
}
// convert the model to the XML string representation
final OutputStream outputStream = new ByteArrayOutputStream();
Bpmn.writeModelToStream(outputStream, bpmnModelInstance);
InputStream inputStream = IoUtil.convertOutputStreamToInputStream(outputStream);
final String modelString = IoUtil.getStringFromInputStream(inputStream);
IoUtil.closeSilently(outputStream);
IoUtil.closeSilently(inputStream);
// read test process from file as string
inputStream = getClass().getResourceAsStream("DefinitionsTest.shouldNotAffectCommentsResult.bpmn");
final String fileString = IoUtil.getStringFromInputStream(inputStream);
IoUtil.closeSilently(inputStream);
// compare strings
assertThat(modelString).endsWith(fileString);
}
use of io.camunda.zeebe.model.bpmn.instance.Definitions in project zeebe by camunda.
the class DefinitionsTest method shouldImportEmptyDefinitions.
@Test
@BpmnModelResource
public void shouldImportEmptyDefinitions() {
final Definitions definitions = bpmnModelInstance.getDefinitions();
assertThat(definitions).isNotNull();
// provided in file
assertThat(definitions.getTargetNamespace()).isEqualTo("http://camunda.org/test");
// defaults provided in Schema
assertThat(definitions.getExpressionLanguage()).isEqualTo(XPATH_NS);
assertThat(definitions.getTypeLanguage()).isEqualTo(XML_SCHEMA_NS);
// not provided in file
assertThat(definitions.getExporter()).isNull();
assertThat(definitions.getExporterVersion()).isNull();
assertThat(definitions.getId()).isNull();
assertThat(definitions.getName()).isNull();
// has no imports
assertThat(definitions.getImports()).isEmpty();
}
use of io.camunda.zeebe.model.bpmn.instance.Definitions in project zeebe by camunda.
the class GenerateIdTest method shouldGenerateIdsOnCreate.
@Test
public void shouldGenerateIdsOnCreate() {
final BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
final Definitions definitions = modelInstance.newInstance(Definitions.class);
assertThat(definitions.getId()).isNotNull();
final Process process = modelInstance.newInstance(Process.class);
assertThat(process.getId()).isNotNull();
final StartEvent startEvent = modelInstance.newInstance(StartEvent.class);
assertThat(startEvent.getId()).isNotNull();
final UserTask userTask = modelInstance.newInstance(UserTask.class);
assertThat(userTask.getId()).isNotNull();
}
use of io.camunda.zeebe.model.bpmn.instance.Definitions in project zeebe by camunda.
the class ModelTest method testCreateEmptyModel.
@Test
public void testCreateEmptyModel() {
final BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();
Definitions definitions = bpmnModelInstance.getDefinitions();
assertThat(definitions).isNull();
definitions = bpmnModelInstance.newInstance(Definitions.class);
bpmnModelInstance.setDefinitions(definitions);
definitions = bpmnModelInstance.getDefinitions();
assertThat(definitions).isNotNull();
}
Aggregations