Java Code Examples for org.camunda.bpm.model.bpmn.instance.Process#setId()

The following examples show how to use org.camunda.bpm.model.bpmn.instance.Process#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReferenceTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Before
public void createModel() {
  testBpmnModelInstance = Bpmn.createEmptyModel();
  Definitions definitions = testBpmnModelInstance.newInstance(Definitions.class);
  testBpmnModelInstance.setDefinitions(definitions);

  message = testBpmnModelInstance.newInstance(Message.class);
  message.setId("message-id");
  definitions.getRootElements().add(message);

  Process process = testBpmnModelInstance.newInstance(Process.class);
  process.setId("process-id");
  definitions.getRootElements().add(process);

  startEvent = testBpmnModelInstance.newInstance(StartEvent.class);
  startEvent.setId("start-event-id");
  process.getFlowElements().add(startEvent);

  messageEventDefinition = testBpmnModelInstance.newInstance(MessageEventDefinition.class);
  messageEventDefinition.setId("msg-def-id");
  messageEventDefinition.setMessage(message);
  startEvent.getEventDefinitions().add(messageEventDefinition);

  startEvent.getEventDefinitionRefs().add(messageEventDefinition);
}
 
Example 2
Source File: ReferenceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void createModel() {
  testBpmnModelInstance = Bpmn.createEmptyModel();
  Definitions definitions = testBpmnModelInstance.newInstance(Definitions.class);
  testBpmnModelInstance.setDefinitions(definitions);

  message = testBpmnModelInstance.newInstance(Message.class);
  message.setId("message-id");
  definitions.getRootElements().add(message);

  Process process = testBpmnModelInstance.newInstance(Process.class);
  process.setId("process-id");
  definitions.getRootElements().add(process);

  startEvent = testBpmnModelInstance.newInstance(StartEvent.class);
  startEvent.setId("start-event-id");
  process.getFlowElements().add(startEvent);

  messageEventDefinition = testBpmnModelInstance.newInstance(MessageEventDefinition.class);
  messageEventDefinition.setId("msg-def-id");
  messageEventDefinition.setMessage(message);
  startEvent.getEventDefinitions().add(messageEventDefinition);

  startEvent.getEventDefinitionRefs().add(messageEventDefinition);
}
 
Example 3
Source File: DefinitionsTest.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldAddChildElementsInCorrectOrder() {
  // create an empty model
  BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();

  // add definitions
  Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
  definitions.setTargetNamespace("Examples");
  bpmnModelInstance.setDefinitions(definitions);

  // create a Process element and add it to the definitions
  Process process = bpmnModelInstance.newInstance(Process.class);
  process.setId("some-process-id");
  definitions.getRootElements().add(process);

  // create an Import element and add it to the definitions
  Import importElement = bpmnModelInstance.newInstance(Import.class);
  importElement.setNamespace("Imports");
  importElement.setLocation("here");
  importElement.setImportType("example");
  definitions.getImports().add(importElement);

  // create another Process element and add it to the definitions
  process = bpmnModelInstance.newInstance(Process.class);
  process.setId("another-process-id");
  definitions.getRootElements().add(process);

  // create another Import element and add it to the definitions
  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();
  }
}
 
Example 4
Source File: DefinitionsTest.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 5
Source File: DefinitionsTest.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldAddParentChildElementInCorrectOrder() {
  // create empty model
  BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();

  // add definitions to model
  Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
  definitions.setTargetNamespace("Examples");
  bpmnModelInstance.setDefinitions(definitions);

  // add process
  Process process = bpmnModelInstance.newInstance(Process.class);
  process.setId("messageEventDefinition");
  definitions.getRootElements().add(process);

  // add start event
  StartEvent startEvent = bpmnModelInstance.newInstance(StartEvent.class);
  startEvent.setId("theStart");
  process.getFlowElements().add(startEvent);

  // create and add message
  Message message = bpmnModelInstance.newInstance(Message.class);
  message.setId("start-message-id");
  definitions.getRootElements().add(message);

  // add message event definition to start event
  MessageEventDefinition startEventMessageEventDefinition = bpmnModelInstance.newInstance(MessageEventDefinition.class);
  startEventMessageEventDefinition.setMessage(message);
  startEvent.getEventDefinitions().add(startEventMessageEventDefinition);

  // add property after message event definition
  Property property = bpmnModelInstance.newInstance(Property.class);
  startEvent.getProperties().add(property);

  // finally add an extensions element
  ExtensionElements extensionElements = bpmnModelInstance.newInstance(ExtensionElements.class);
  process.setExtensionElements(extensionElements);

  // validate model
  try {
    Bpmn.validateModel(bpmnModelInstance);
  }
  catch (ModelValidationException e) {
    Assert.fail();
  }
}
 
Example 6
Source File: DefinitionsTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldAddChildElementsInCorrectOrder() {
  // create an empty model
  BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();

  // add definitions
  Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
  definitions.setTargetNamespace("Examples");
  bpmnModelInstance.setDefinitions(definitions);

  // create a Process element and add it to the definitions
  Process process = bpmnModelInstance.newInstance(Process.class);
  process.setId("some-process-id");
  definitions.getRootElements().add(process);

  // create an Import element and add it to the definitions
  Import importElement = bpmnModelInstance.newInstance(Import.class);
  importElement.setNamespace("Imports");
  importElement.setLocation("here");
  importElement.setImportType("example");
  definitions.getImports().add(importElement);

  // create another Process element and add it to the definitions
  process = bpmnModelInstance.newInstance(Process.class);
  process.setId("another-process-id");
  definitions.getRootElements().add(process);

  // create another Import element and add it to the definitions
  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();
  }
}
 
Example 7
Source File: DefinitionsTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 8
Source File: DefinitionsTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldAddParentChildElementInCorrectOrder() {
  // create empty model
  BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();

  // add definitions to model
  Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
  definitions.setTargetNamespace("Examples");
  bpmnModelInstance.setDefinitions(definitions);

  // add process
  Process process = bpmnModelInstance.newInstance(Process.class);
  process.setId("messageEventDefinition");
  definitions.getRootElements().add(process);

  // add start event
  StartEvent startEvent = bpmnModelInstance.newInstance(StartEvent.class);
  startEvent.setId("theStart");
  process.getFlowElements().add(startEvent);

  // create and add message
  Message message = bpmnModelInstance.newInstance(Message.class);
  message.setId("start-message-id");
  definitions.getRootElements().add(message);

  // add message event definition to start event
  MessageEventDefinition startEventMessageEventDefinition = bpmnModelInstance.newInstance(MessageEventDefinition.class);
  startEventMessageEventDefinition.setMessage(message);
  startEvent.getEventDefinitions().add(startEventMessageEventDefinition);

  // add property after message event definition
  Property property = bpmnModelInstance.newInstance(Property.class);
  startEvent.getProperties().add(property);

  // finally add an extensions element
  ExtensionElements extensionElements = bpmnModelInstance.newInstance(ExtensionElements.class);
  process.setExtensionElements(extensionElements);

  // validate model
  try {
    Bpmn.validateModel(bpmnModelInstance);
  }
  catch (ModelValidationException e) {
    Assert.fail();
  }
}