Skip to content

Refactoring: Relationship.any()#1331

Merged
kingthorin merged 2 commits intomainfrom
refactoring/relationships.any
Aug 22, 2024
Merged

Refactoring: Relationship.any()#1331
kingthorin merged 2 commits intomainfrom
refactoring/relationships.any

Conversation

@asolntsev
Copy link
Collaborator

No description provided.

... to avoid using stack trace and returning a new instance of "self".
@asolntsev asolntsev requested review from bodiam and kingthorin August 22, 2024 16:47
@what-the-diff
Copy link

what-the-diff bot commented Aug 22, 2024

PR Summary

  • Introduction of Kind Enum in Relationship.java
    A new Kind enumeration is introduced with its corresponding values and expressions in Relationship.java file. This enhances the readability and maintainability of the code, as relationship expressions are now represented using this enum directly, making it easier to keep track of them.

  • Modification in methods in Relationship.java
    The direct(), extended(), inLaw(), spouse(), parent(), and sibling() methods are altered to utilize the expressions from the Kind enum. This simplifies the way these methods operate and deliver values. The any() function also adapts to employing the Kind enum to pick a random relationship expression and resolve it to provide a value.

  • Reset Mocks in RelationshipTest.java
    The beforeEach() method in the RelationshipTest.java file is updated to conduct a reset on the mockFaker and fakeValuesService mocks - ensuring that every test runs in a clean state.

  • Updating Tests in RelationshipTest.java
    Certain exceptions are introduced in the test methods to check if the system behavior is reliable when faced with unexpected circumstances. The method anyWithIllegalArgumentExceptionThrown() is updated to throw an IllegalArgumentException during invocation of resolve(). Similarly, anyWithInvocationTargetExceptionThrown() is adapted to throw a NullPointerException during the same invocation. These changes help validate and improve the robustness of the application's exception handling mechanism.

  • Modifying any() Method Handling in Test
    The any() method located in the test suite now throws the corresponding exceptions when resolve() is called on fakeValuesService. This helps ensure that the method operates robustly, even when faced with unexpected behaviors or exceptions. This ensures that the reliability and stability of the overall system are maintained.

@kingthorin
Copy link
Collaborator

kingthorin commented Aug 22, 2024

Re: build failure
Run 'mvn spotless:apply' to fix these violations.

Now it doesn't use reflection at all, at can throw only runtime exceptions. Some tests are not needed anymore. :)
@asolntsev asolntsev force-pushed the refactoring/relationships.any branch from cf8681e to 413b707 Compare August 22, 2024 19:11
@asolntsev
Copy link
Collaborator Author

Re: build failure Run 'mvn spotless:apply' to fix these violations.

Oops, my bad :)
Fixed.

@codecov
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.87%. Comparing base (90b032a) to head (413b707).
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1331      +/-   ##
============================================
+ Coverage     91.78%   91.87%   +0.08%     
+ Complexity     3160     3159       -1     
============================================
  Files           316      316              
  Lines          6236     6237       +1     
  Branches        634      634              
============================================
+ Hits           5724     5730       +6     
+ Misses          353      351       -2     
+ Partials        159      156       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

Thanks

@kingthorin kingthorin merged commit ad9322d into main Aug 22, 2024
@kingthorin kingthorin deleted the refactoring/relationships.any branch August 22, 2024 19:22
@asolntsev asolntsev self-assigned this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants