Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(engine): include error message of unhandled BPMN error in log #4748

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sowmyahl21
Copy link

Related to git issue : #4667
@mboskamp could you please review this PR. Thanks!

@CLAassistant
Copy link

CLAassistant commented Oct 28, 2024

CLA assistant check
All committers have signed the CLA.

@sowmyahl21
Copy link
Author

Hi @mboskamp , hope you are doing good!
Requesting your support to kindly validate my PR. Thanks!

@mboskamp
Copy link
Member

Hi @sowmyahl21, thank you for the reminder. I will take a look this week.

Copy link
Member

@mboskamp mboskamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sowmyahl21, thank you again for your contribution!
👍 The solution you implemented looks very good already. I added a few hints for the test you wrote. We can make some adjustments to align it better with our testing best practices.

For this review, I used our emoji codes to signal the level of importance:

  • 👍 I like that!
  • ❓ I have a question. Can you clarify?
  • ❌ This has to change.
  • 🔧 I have a suggestion that you can take or ignore.
  • 🙃 This is nitpicking and should not block progress.
  • 💭 I want to start a discussion. Either by sharing my opinion or asking an open question.

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Please do not use wildcard imports. See our Java coding style guide for more information.

runtimeService.startProcessInstanceByKey("testProcess");
} catch (ProcessEngineException e) {
// then
assertTrue(e.getMessage()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Please use AssertJ assertions. See our Testing best practices guide for more information.

"org.camunda.bpm.engine.bpmn.behavior", Level.INFO);

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/behavior/UnhandledBpmnError.bpmn20.xml" })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Convention is to name the BPMN file after your test class and test method. Naming it BpmnBehaviorLoggerTest.testUnhandledBpmnErrorThrowException.bpmn20.xml would allow you to deploy it by just @Deployment without any more parameters. However, you want to reuse this file for both tests, so I would suggest to rename it to BpmnBehaviorLoggerTest.UnhandledBpmnError.bpmn20.xml. This way, it's clear where this file belongs to.

"Execution with id 'serviceTask' throws an error event with errorCode 'errorCode' and errorMessage 'ouch!', but no error handler was defined"));
}
// cleanup
processEngineConfiguration.setEnableExceptionsAfterUnhandledBpmnError(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ The cleanup code will not run if the test fails for any reason. I know this pattern exists in other tests but it's generally not recommended. Try using the @Before and @After jUnit annotations to set up and restore process engine configuration.

public void testUnhandledBpmnErrorLogException() {
String logMessage = "Execution with id 'serviceTask' throws an error event with errorCode 'errorCode' and errorMessage 'ouch!'";
runtimeService.startProcessInstanceByKey("testProcess");
assertThat(processEngineLoggingRule.getFilteredLog(logMessage)).hasSize(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Please add // given, // when, // then comments
❌ As per our Testing best practices, please not only assert the count of the result but also the content.

Copy link
Author

@sowmyahl21 sowmyahl21 Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mboskamp , regarding this comment to assert content along with the count - in this case, as we are filtering the log based on the given logMessage which asserts the content already along with the count, do we need to explicitly assert the content? please let me know your thoughts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good point, let's keep it like it is and only assert that the result list has size 1.


@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/behavior/UnhandledBpmnError.bpmn20.xml" })
public void testUnhandledBpmnErrorThrowException() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 As per our Testing best practices, please name the tests starting with should followed by a descriptive name e.g. shouldIncludeBpmnErrorMessageInUnhandledBpmnError. The same applies to the other test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants