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

Allow Polymorphic persistenence #70

Closed
JanSchankin opened this issue Jun 30, 2021 · 3 comments · Fixed by #83
Closed

Allow Polymorphic persistenence #70

JanSchankin opened this issue Jun 30, 2021 · 3 comments · Fixed by #83
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@JanSchankin
Copy link
Contributor

When DeepSampler wants to deserialize an Object, the concrete type of the object must be known, so that a new instance of that type can be created.

There are two cases where different deserialization approaches are used:

  • Serialization and Deserialization is completely done by the underlying persistence framework (Jackson by default)
  • Serialization and Deserialization is done using PersistentBeans by DeepSamplers PersistentBeanConverter`.

In the first case type information is completely handled by the persistence framework (Jackson).

In the second case DeepSampler uses the declared return type of the method that is supposed to return the persistent object. Now, there are circumstances where this doesn't work. In general, this is always the case if the actually returned object is a sub type of the declared return type. E.g. in many cases this happens if the declared return type is an interface.

That's why we need to add a type information to PersistentBean in all cases where the original type cannot be determined by the declared return type of the sampled method.

@JanSchankin JanSchankin added the enhancement New feature or request label Jun 30, 2021
@JanSchankin JanSchankin added this to the v2.0.0 milestone Jun 30, 2021
@JanSchankin
Copy link
Contributor Author

JanSchankin commented Jun 30, 2021

I've added a branch and a first Testcase to accelerate your kickoff:

https://github.com/ppi-ag/deep-sampler/tree/polymorphic-feature

public void polymorphicSamplesCanBeRecordedAndLoaded() throws IOException {

@JanSchankin JanSchankin added this to To do in Dev via automation Jul 30, 2021
@chb-ppi
Copy link
Contributor

chb-ppi commented Sep 17, 2021

Test fails now

@JanSchankin
Copy link
Contributor Author

The test was intended to fail until the polymorphic feature is implemented. It should throw an InstantionationError because it is trying to instantiate the interface Animal. Or is it something else? I think the branch is quite old, maybe dev needs to be merged into polymorphic-feature. The test doesn't use PersistentSampler yet.

@JanSchankin JanSchankin moved this from To do to In progress in Dev Oct 22, 2021
JanSchankin added a commit that referenced this issue Nov 26, 2021
* +Test first: New Testcase for Issue #70

* Intermediate state

* Intermediate state

* Cleanup for new annotations

* Additional tests and fixes

* +javadoc

* -sonar code smells

* -sonar code smells

* -instantiation of inner classes in non public classes is possible now

* Dublicated paths refeactored

* Increased precision in tests

* BeanConverterExtensions can be configured using annotations

* Cleaning and Javadoc

* CodeSmells beseitigt

* linting

* Polymorphic persistence ist now possible. Deserializing works in minimal testcases

* Review

* +Test first: New Testcase for Issue #70

* Polymorphic persistence ist now possible. Deserializing works in minimal testcases

* Update README.md

* Update README.md

* Update README.md

* Removed some typos

* Update README.md

* New graphics and explanations

* Update README.md

* Update README.md

* Refactoring

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* transparency

* transparency reverted

* text revised

* Refactoring

* Refactoring

* Refactoring

* Refactoring

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Additional tests

* Refactorings

* Generic properties of Beans can be deserialized using PolymorphicPersistentBean

* The class was moved to the new branch refactoring_simplified_bean_extension. The class is not used yet, and it messes up the test coverage

* Refactoring

* The class was moved to the new branch refactoring_simplified_bean_extension. The class is not used yet, and it messes up the test coverage

* Housekeeping

* Even more tests

* Added javadoc in PolymorphicPersistentBean.java

Co-authored-by: JanSchankin <jas@treeno.de>
Co-authored-by: chb <chb@ppi.de>
Co-authored-by: jas <jan.schankin@ppi.de>
@JanSchankin JanSchankin linked a pull request Nov 26, 2021 that will close this issue
@JanSchankin JanSchankin moved this from In progress to Done in Dev Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Dev
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants