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 for ShieldDbBuilder, refactoring extract method for nesting shield #10

Merged

Conversation

bhegmanns
Copy link
Contributor

No description provided.

@bhegmanns
Copy link
Contributor Author

Hi,
written a little test for Add unit tests for the builder #4
and did a tiny refactoring.

private void doNestShields() {
Iterator<ShieldDBShield<T>> shieldIterator = shields.iterator();

ShieldDBShield<T> bindTo = shieldIterator.next();
Copy link
Owner

Choose a reason for hiding this comment

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

Do you think "previousShield" could be a better name for the bindTo variable?

Copy link
Contributor Author

@bhegmanns bhegmanns Oct 2, 2020

Choose a reason for hiding this comment

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

should be. In similar topics I like using "outer" and "inner".
I'll change it

}


private static class MockDBShield implements ShieldDBShield<String> {
Copy link
Owner

Choose a reason for hiding this comment

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

You can implements PassThroughShield (https://github.com/kuroidoruido/ShieldDB/blob/master/shielddb-core/src/main/java/nf/fr/k49/shielddb/core/shield/PassThroughShield.java) instead of ShieldDBShield. This way you can avoid implementing a lot of methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aaah, I don't get the complete survey of all classes ;)
My additional plan is using a really mock (e.g. via mockito) so that a test can check calling some methods like setNextShield etc. Would this a better way? If so, I change the test by using the mock. Alternatively I can use the PassThroughShield. Give me a hint ;)

Copy link
Owner

Choose a reason for hiding this comment

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

No problem. I notice you for that reason 😉
If you add Mockito and add some tests about binding, yeah no problem to add Mockito. I think we will use it one day, so adding it now or in the future it's the same thing for me 🙂

using outer and innter names
placed static imports
used Mockito for check proper builder-behavior
@bhegmanns
Copy link
Contributor Author

Hi,
updated the PR :)

@bhegmanns bhegmanns requested a review from kuroidoruido October 3, 2020 09:27
}


private static class MockDBShield implements ShieldDBShield<String> {
Copy link
Owner

Choose a reason for hiding this comment

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

No problem. I notice you for that reason 😉
If you add Mockito and add some tests about binding, yeah no problem to add Mockito. I think we will use it one day, so adding it now or in the future it's the same thing for me 🙂

@kuroidoruido kuroidoruido merged commit ac7edce into kuroidoruido:master Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants