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

Polymorphic persistence Issue #70 #83

Merged
merged 61 commits into from
Nov 26, 2021
Merged

Polymorphic persistence Issue #70 #83

merged 61 commits into from
Nov 26, 2021

Conversation

JanSchankin
Copy link
Contributor

No description provided.

@JanSchankin JanSchankin self-assigned this Oct 22, 2021
@JanSchankin JanSchankin reopened this Oct 22, 2021
@JanSchankin JanSchankin changed the title +Test first: New Testcase for Issue #70 +Polymorphic persistence Issue #70 Oct 22, 2021
@JanSchankin JanSchankin added this to the v2.0.0 milestone Oct 22, 2021
@JanSchankin JanSchankin added the enhancement New feature or request label Oct 22, 2021

// Realen Typen Dog
// Declared Type Animal
// Generic null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

comments seem to be scratches, they should be removed

}
} else {
returnClass= sampledMethod.getMethod().getReturnType();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code shuld be reformatted. Missing spaces after = and too long lines.
Usage of string.format() with placeholders instead of string-concatenation using + would also be better. PersistenceException has a convenient constructor for that.

Copy link
Contributor

@chb-ppi chb-ppi Nov 26, 2021

Choose a reason for hiding this comment

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

I am unsure what do you mean by, that there is a convinient constructor for a concatination in the constuctor of the exception.


import java.util.Map;

public class PolymorphicPersistentBean extends DefaultPersistentBean{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some javaodc is needed to explain what this is and why we have built it

Copy link
Contributor

Choose a reason for hiding this comment

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

javadoc added

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class BeanConversion {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this class shouldn't be in this branch

Copy link
Contributor

Choose a reason for hiding this comment

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

class deleted

@Test
public void polymorphicSamplesCanBeRecordedAndLoaded() throws IOException {
// Ensure, that no Samples from previous tests exists...
Sampler.clear();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This aleady done by @beforeeach

final PersistentSampleManager source = PersistentSampler.source(JsonSourceManager.builder().buildWithFile(pathToFile));
source.record();

// Reset SampleRepository to ensure that only deserialized samples will be used in the next steps...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copied code. there is a method for that:

@@ -544,4 +544,40 @@ private PersistentSampleManager save(Path pathToFile) {
return source;
}

@Test
public void polymorphicSamplesCanBeRecordedAndLoaded() throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The extension TempJsonFile injects a Path to a tmp file and deletes that file after the test has run. You can add a parameter Path tempFile to the method to get access to the tmp file.

There is also a helper-method that uses the tmpFile to create a PersistnetSampleManager:

JanSchankin and others added 16 commits November 16, 2021 21:49
…rphic-feature

# Conflicts:
#	README.md
#	deepsampler-persistence/src/main/java/de/ppi/deepsampler/persistence/api/PersistentSampleManager.java
#	deepsampler-provider/src/testFixtures/java/de/ppi/deepsampler/provider/common/Cat.java
#	deepsampler-provider/src/testFixtures/java/de/ppi/deepsampler/provider/common/PersistentSamplerAspectTest.java
#	deepsampler-provider/src/testFixtures/java/de/ppi/deepsampler/provider/common/TestService.java
@JanSchankin JanSchankin changed the title +Polymorphic persistence Issue #70 Polymorphic persistence Issue #70 Nov 18, 2021
Copy link
Contributor

@chb-ppi chb-ppi left a comment

Choose a reason for hiding this comment

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

review should be completed

return (T) originalBean;
}

/**
* Todo
Copy link
Contributor

Choose a reason for hiding this comment

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

Todos resolved

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class BeanConversion {
Copy link
Contributor

Choose a reason for hiding this comment

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

class deleted


import java.util.Map;

public class PolymorphicPersistentBean extends DefaultPersistentBean{
Copy link
Contributor

Choose a reason for hiding this comment

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

javadoc added

@sonarcloud
Copy link

sonarcloud bot commented Nov 26, 2021

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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@JanSchankin JanSchankin merged commit 8a1dfea into dev Nov 26, 2021
@JanSchankin JanSchankin linked an issue Nov 26, 2021 that may be closed by this pull request
@JanSchankin JanSchankin deleted the polymorphic-feature branch December 5, 2021 12:33
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
None yet
Development

Successfully merging this pull request may close these issues.

Allow Polymorphic persistenence
3 participants