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

10 - enhancing the controller advice class #20

Closed
wants to merge 2 commits into from

Conversation

SivaTharun
Copy link

Overview

  • added different exception handler methods to handle BadRequestException,ErrorSavingEntityToDatabaseException, ResourceNotFoundException
    Connects FEATURE: Enable Global Exception #10

Notes

  • changes to add exception handler for different exception belonging to this application

- added different exception handler methods to handle BadRequestException,ErrorSavingEntityToDatabaseException, ResourceNotFoundException
@SivaTharun
Copy link
Author

@ohbus can i add new unit test class to verify the exception handler capability.

Copy link
Member

@ohbus ohbus left a comment

Choose a reason for hiding this comment

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

We need to use the @ControllerAdvice annotation or the @RestControllerAdvice

This was already implemented to check some functionalities, which will be removed in the final version.

Also, remember to add Unit tests for your code.

- added controller tests to assert and verify the exceptions handles from exception handler
- added the embedded h2 autoconfigure setup for jpa
@SivaTharun
Copy link
Author

@ohbus please check the unit tests added to the change

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@ohbus ohbus left a comment

Choose a reason for hiding this comment

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

Fix the Static Errors reported by Codacy.

Comment on lines +119 to +125
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

Copy link
Member

Choose a reason for hiding this comment

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

No need to add the JUnit dependency as it is already there.

Please use Junit5/Jupiter engine for writing the test cases.

@ohbus ohbus closed this Feb 20, 2024
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.

2 participants