Skip to content

Commit

Permalink
refactoring, minor improvements
Browse files Browse the repository at this point in the history
issue #346
  • Loading branch information
rsoika committed Jun 18, 2024
1 parent 7bbafce commit 15c17d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ public Set<MessageFlow> findMessageFlowsByElementId(String id) {
}

/**
* Returns all BPMN Edges associated with a geiven FlowElement.
* Returns all BPMN Edges associated with a given FlowElement.
*
* @param id
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openbpmn.bpmn.elements.BPMNProcess;
import org.openbpmn.bpmn.elements.Event;
import org.openbpmn.bpmn.elements.Gateway;
import org.openbpmn.bpmn.exceptions.BPMNModelException;

/**
* The BPMNValidationHandler validates a complete BPMNModel for validation
Expand All @@ -28,8 +29,9 @@ public class BPMNValidationHandler {
*
* @param forceValidation - if true the full model will be validated.
* @return
* @throws BPMNModelException
*/
public List<BPMNValidationMarker> validate(BPMNModel model, boolean forceValidation) {
public List<BPMNValidationMarker> validate(BPMNModel model, boolean forceValidation) throws BPMNModelException {
List<BPMNValidationMarker> result = new ArrayList<>();
// iterate over all process
Set<BPMNProcess> processes = model.getProcesses();
Expand All @@ -48,9 +50,13 @@ public List<BPMNValidationMarker> validate(BPMNModel model, boolean forceValidat
* for only new added or changed element nodes.
*
* @return
* @throws BPMNModelException
*/
private List<BPMNValidationMarker> validateProcess(BPMNProcess process, boolean forceValidation) {
public List<BPMNValidationMarker> validateProcess(BPMNProcess process, boolean forceValidation)
throws BPMNModelException {
List<BPMNValidationMarker> result = new ArrayList<>();
// make sure that the process is initialized
process.init();
// validate events....
Set<Event> events = process.getEvents();
for (Event event : events) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,19 @@ public void testValidationTaskWithMessageFlow() {
// Test default process
BPMNProcess process = model.openDefaultProces();
assertNotNull(process);
assertEquals(1, process.getActivities().size());

BPMNValidationHandler bpmnValidationHandler = new BPMNValidationHandler();
List<BPMNValidationMarker> result = bpmnValidationHandler.validate(model, true);

// we expect no errors
assertEquals(0, result.size());

// Now open the 'Pool-1' containing a receive Task
// Now verify the 'Pool-1'. We expect that the process was initialized by the
// validate method
process = model.findProcessByName("Pool-1");
process = model.openProcess(process.getId());
assertNotNull(process);
bpmnValidationHandler = new BPMNValidationHandler();
result = bpmnValidationHandler.validate(model, true);

// we expect no errors
assertEquals(0, result.size());
assertEquals(3, process.getActivities().size());

} catch (BPMNModelException e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<bpmn2:receiveTask id="task_MPPyxg" instantiate="true" name="Task-3">
<bpmn2:documentation id="documentation_qc8ghA"/>
<bpmn2:outgoing>sequenceFlow_kIA1WQ</bpmn2:outgoing>
<bpmn2:incoming>messageFlow_oBGang</bpmn2:incoming>
</bpmn2:receiveTask>
<bpmn2:sequenceFlow id="sequenceFlow_kIA1WQ" sourceRef="task_MPPyxg" targetRef="task_p9QtJg">
<bpmn2:documentation id="documentation_LFztyg"/>
Expand Down Expand Up @@ -151,9 +152,9 @@
<di:waypoint x="865.0" y="200.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="messageFlow_oBGang" id="BPMNEdge_3KHv0g" sourceElement="BPMNShape_OKyVyg" targetElement="BPMNShape_CTmfzQ">
<di:waypoint x="850.0" y="211.0"/>
<di:waypoint x="735.0" y="211.0"/>
<di:waypoint x="735.0" y="310.0"/>
<di:waypoint x="850.0" y="210.0"/>
<di:waypoint x="734.0" y="210.0"/>
<di:waypoint x="734.0" y="310.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_kIA1WQ" id="BPMNEdge_5NpCgA" sourceElement="BPMNShape_CTmfzQ" targetElement="BPMNShape_pKoMYQ">
<di:waypoint x="735.0" y="360.0"/>
Expand Down

0 comments on commit 15c17d5

Please sign in to comment.