-
Notifications
You must be signed in to change notification settings - Fork 26
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
Instantiating a pojo which ctor accepts another pojo #192
Comments
Hi, actually there is no way to override any |
Hi @sta-szek Thanks for replying. Yes, that works OK if the class under test is |
OK, I see. BTW |
Yes, I tried (my using a with(XXX), I'd be happy to contribute. I've read through the source code and would make a PR from a fork, but could definitely benefit from getting some pointers on where to extend it. I'm envisioning a "with"-like method on the Where in the lifecycle of the test would I hook up the logic of selecting such an instantiator? |
I like the idea with It would be nice to use lambda style e.g. Any contributions are welcomed. |
Was there any progress on this? Having a problem where my POJOS are taking a ZonedDateTime but it cannot instantiate a ZoneId to construct one as it doesn't have a default constructor and is created through static factory methods. |
@CCob, yes, I'm working on it. The implementation is really simple but some refactor is needed. After that I have to bring my CI back to life to avoid manually deploying new version and gitbook docs. It may take me some time but I think this can be done this week. |
Great. If there is anything you'd like me to test the feel free to ask. I have unit tests that are currently failing that I can run any new code base against 👍 |
@CCob nice! You can checkout the I have to refactor If you want to do some more work you can always checkout from Here is PR with my work: https://github.com/sta-szek/pojo-tester/pull/219/files |
Great, I'll take a look. Have you thought about exposing AbstractObjectInstantiator as a public class that users of the library can extend. That way we could add custom object instansiators when using the library. |
Yes, I was thinking about it and perhaps it will be very similar to http://www.pojo.pl/writing-tests/#configure-fvc That's why I said that
|
Yes, agreed. Perhaps the |
But I think that this deserves for new issue. If you are willing to do such a refactor and feature I will be happy :) And that should wait after my PR will be merged, otherwise there will be a lot of unobvious conflicts to resolve. |
I agree, certainly a new issue an PR. I can also confirm Certainly dont mind contributing but it will be as and when I can as I'm sure it is for you |
Nice to see pojos with ZonedDateTime constructor arguments merged. What time frame do you have in mind for 0.7.6 release? |
I did my best this week but I don't think that it will be sooner that december. |
No worries. Got a 0.7.6-SNAPSHOT on a branch right now. Will wait to merge when 0.7.6 is released. Thanks.
Sent from my Samsung Galaxy smartphone.
…-------- Original message --------
From: Piotr Joński <[email protected]>
Date: 18/11/2017 9:35 pm (GMT+00:00)
To: sta-szek/pojo-tester <[email protected]>
Cc: CCob <[email protected]>, Mention <[email protected]>
Subject: Re: [sta-szek/pojo-tester] Instantiating a pojo which ctor accepts another pojo (#192)
I did my best this week but I don't think that it will be sooner that december.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#192 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AC7BkkNTma8ZBxDb96xSN-ywG9OheeS-ks5s301_gaJpZM4MxySx>.
The contents of this e-mail (including my attachments) are confidential and may be legally privileged. If you are not the intended recipient of this e-mail, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete it (including any attachments) from your system.
The contents of this e-mail (including my attachments) are confidential and may be legally privileged. If you are not the intended recipient of this e-mail, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete it (including any attachments) from your system.
|
I think I might be running into the same issue when I have a class with a single constructor that takes a parameter of another POJO type. In this case, the method that tests equals reports that "The equals method should return false if objects should not be equal." but the two objects are actually equal and should be equal! I also get a similar error message for the hashCode test. If I add an empty parameter-less constructor, than my test turns green. |
Hi,
I have the following case:
The problem is when testing
A
, POJO-TESTER tries to instantiateB
with the parameterwww.pojo.pl
which will trigger the parameter check on classB
and makeA
's test error.There is probably a way of telling POJO-TESTER to use a custom instantiator for
B
that will always pass a valid parameter to the constructor.From what I can see, this will happen with any POJO which only ctor accepts non-trivial classes which in turn validate the parameters they accept on their ctors. I've traced the
www.pojo.nl
to the classStringClassInstantiator
but I don't know how to override this behaviourAm I missing something ?
The text was updated successfully, but these errors were encountered: