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

test: split and improve ObjectFieldMapTypeHandlerFactoryTests #5168

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

jdrueckert
Copy link
Member

@jdrueckert jdrueckert commented Nov 8, 2023

  • split into multiple tests to avoid testing different aspects in single test
  • remove usage of implicit member type knowledge in assertion phase
  • add negative assertions to ensure only expected calls are made
  • improve test case documentation

Once #5154 is merged, we'll need to update the suppression of UUF_UNUSED_FIELD spotbugs findings for SingleTypeClass and MultiTypeClass.

@jdrueckert jdrueckert added Type: Improvement Request for or addition/enhancement of a feature Topic: Stabilization Requests, Issues and Changes related to improving stablity and reducing flakyness Category: Test/QA Requests, Issues and Changes targeting tests and quality assurance labels Nov 8, 2023
@jdrueckert jdrueckert added this to the 2023 Revive - Milestone 2 milestone Nov 8, 2023
Comment on lines +64 to +67
verify(typeHandlerLibrary, times(1)).getTypeHandler((Type) any());
verify(typeHandlerLibrary, times(1)).getTypeHandler(eq(TypeInfo.of(Integer.class).getType()));
verify(typeHandlerLibrary, never()).getTypeHandler((Class<Object>) any());
verify(typeHandlerLibrary, never()).getTypeHandler((TypeInfo<Object>) any());
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to explain what we are doing here at least once.

Also, I'd move the specific test up (test happy path) and then make the "negative tests" afterwards.

Suggested change
verify(typeHandlerLibrary, times(1)).getTypeHandler((Type) any());
verify(typeHandlerLibrary, times(1)).getTypeHandler(eq(TypeInfo.of(Integer.class).getType()));
verify(typeHandlerLibrary, never()).getTypeHandler((Class<Object>) any());
verify(typeHandlerLibrary, never()).getTypeHandler((TypeInfo<Object>) any());
// verify that the expected typehandler was created
verify(typeHandlerLibrary, times(1)).getTypeHandler(eq(TypeInfo.of(Integer.class).getType()));
// verify that creation was triggered only for the expected typehandler, but not for others
// 'getTypeHandler' can be called with either Type, Class, or TypeInfo, and we only expect one call with Type
verify(typeHandlerLibrary, times(1)).getTypeHandler((Type) any());
verify(typeHandlerLibrary, never()).getTypeHandler((Class<Object>) any());
verify(typeHandlerLibrary, never()).getTypeHandler((TypeInfo<Object>) any());

@jdrueckert
Copy link
Member Author

Failing test ExampleTest.testClientConnection is a known sporadic and unrelated to code changes in this PR.
Merging despite the failing test.

@jdrueckert jdrueckert merged commit 1b286a6 into develop Nov 13, 2023
6 of 9 checks passed
@jdrueckert jdrueckert deleted the test/split-type-handler-tests branch November 13, 2023 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Test/QA Requests, Issues and Changes targeting tests and quality assurance Topic: Stabilization Requests, Issues and Changes related to improving stablity and reducing flakyness Type: Improvement Request for or addition/enhancement of a feature
Projects
Status: No status
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants