Skip to content

Commit

Permalink
bug(engine): Remove parser warning for intermediate catch timer event…
Browse files Browse the repository at this point in the history
… with a time cycle

- update the logged message to contain the process definition key
- clean up the unit test

related to camunda#3943
  • Loading branch information
Bragolgirith committed Jan 29, 2024
1 parent ea2b974 commit 5956ccb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3566,7 +3566,8 @@ protected void parseIntermediateTimerEventDefinition(Element timerEventDefinitio

Element timeCycleElement = timerEventDefinition.element("timeCycle");
if (timeCycleElement != null) {
LOG.intermediateCatchTimerEventWithTimeCycleNotRecommended(timerActivity.getId());
ProcessDefinition processDefinition = (ProcessDefinition) timerActivity.getProcessDefinition();
LOG.intermediateCatchTimerEventWithTimeCycleNotRecommended(processDefinition.getKey(), timerActivity.getId());
}

addTimerDeclaration(timerActivity.getEventScope(), timerDeclaration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public void parsingFailure(Throwable cause) {
logError("004", "Unexpected Exception with message: {} ", cause.getMessage());
}

public void intermediateCatchTimerEventWithTimeCycleNotRecommended(String elementId) {
logInfo("005", "Element with id '{}' is an intermediate catch timer event with a time cycle which is not recommended.", elementId);
public void intermediateCatchTimerEventWithTimeCycleNotRecommended(String definitionKey, String elementId) {
logInfo("005", "definitionKey: {}; It is not recommended to use an intermediate catch timer event with a time cycle, " +
"element with id '{}'.", definitionKey, elementId);
}

// EXCEPTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,25 +1372,16 @@ public void testMultipleTimerStartEvents() {
@Test
@WatchLogger(loggerNames = {"org.camunda.bpm.engine.bpmn.parser"}, level = "INFO")
public void testIntermediateCatchTimerEventWithTimeCycleNotRecommendedInfoMessage() {
String timerCycle = "<?xml version='1.0' encoding='UTF-8'?>" +
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
" xmlns='http://www.omg.org/spec/BPMN/20100524/MODEL'" +
" xmlns:camunda='http://camunda.org/schema/1.0/bpmn'" +
" targetNamespace='Examples'>" +
" <process id='process' isExecutable='true'>" +
" <startEvent id='theStart' name='Start'></startEvent>" +
" <endEvent id='theEnd' name='End'></endEvent>" +
" <intermediateCatchEvent id='timerintermediatecatchevent1' name='TimerCatchEvent'>" +
" <timerEventDefinition>" +
" <timeCycle>0 0/5 * * * ?</timeCycle>" +
" </timerEventDefinition>" +
" </intermediateCatchEvent>" +
" <sequenceFlow id='flow1' name='' sourceRef='theStart' targetRef='timerintermediatecatchevent1'></sequenceFlow>" +
" <sequenceFlow id='flow2' name='' sourceRef='timerintermediatecatchevent1' targetRef='theEnd'></sequenceFlow>" +
" </process>" +
"</definitions>";
repositoryService.createDeployment().addString("process.bpmn20.xml", timerCycle).deploy();
String logMessage = "Element with id 'timerintermediatecatchevent1' is an intermediate catch timer event with a time cycle which is not recommended.";
BpmnModelInstance process = Bpmn.createExecutableProcess("process")
.startEvent()
.intermediateCatchEvent("timerintermediatecatchevent1")
.timerWithCycle("0 0/5 * * * ?")
.endEvent()
.done();
testRule.deploy(process);

String logMessage = "definitionKey: process; It is not recommended to use an intermediate catch timer event with a time cycle, "
+ "element with id 'timerintermediatecatchevent1'.";
assertThat(loggingRule.getFilteredLog(logMessage)).hasSize(1);
}

Expand Down

0 comments on commit 5956ccb

Please sign in to comment.