Done
Details
Details
Assignee
Oleg Pak
Oleg PakReporter
Viacheslav Kolesnyk
Viacheslav KolesnykPriority
Story Points
2
Sprint
None
Development Team
Spitfire
Fix versions
Release
Quesnelia (R1 2024)
TestRail: Cases
Open TestRail: Cases
TestRail: Runs
Open TestRail: Runs
Created February 8, 2024 at 3:14 PM
Updated March 25, 2024 at 4:07 PM
Resolved February 15, 2024 at 7:08 PM
Overview
Hibernate requires
equals
not to be dependent on entity fields so our implementation usesgetClass
andid
field for entities equality. That makes it impossible to compare expected and actual results inline in tests as well as proper mocking.F.e. if we write
when(repository.save(expectedEntity)).thenReturn(mockResult)
then this repository call will returnmockResult
even if only id of entity passed to repository call matches withexpectedEntity
while other fields may differ.See f.e.
AuthoritySourceFileServiceTest
::shouldUpdateAuthoritySourceFileModifiableFields
where we have a separate assertion for each field in the end and using captor to intercept actual value passed to repository call.Approach
Write custom Mockito verifiers for entities which will compare all fields separately instead of using equals (they can use equals and if it’s true - compare all other fields).
Requirements
Custom verifiers created for entities that are mostly used (AuthoritySourceFile, Authority…). We may not need to create verifiers for some small entities that may have only one test case and not a lot of assertions
Custom verifiers are used in tests, separate assertions for fields removed from test cases