podam icon indicating copy to clipboard operation
podam copied to clipboard

Exclude attributes without using annotations

Open mnd999 opened this issue 11 years ago • 8 comments

It would be nice to provide a mechanism where excluded attributes could be provided by the strategy without having to annotate them, perhaps by returning excluded attribute names.

mnd999 avatar Feb 26 '15 12:02 mnd999

Could you please give an overview of the background. Why do you exclude attributes? They don't work, heavy to fill, maybe some other reason?

daivanov avatar Feb 26 '15 12:02 daivanov

On Thursday 26 Feb 2015 04:50:19 Daniil Ivanov wrote:

Could you please give an overview of the background. Why do you exclude attributes? They don't work, heavy to fill, maybe some other reason?


Reply to this email directly or view it on GitHub: https://github.com/mtedone/podam/issues/80#issuecomment-76172636

Sure, we're writing a Dao test that generates a random object graph using Podam, saves it, loads it back and makes sure it hasn't changed.

In the application logic, the object is mostly populated on one flow and then a later message on another flow populates one of the child objects on the graph. We'd like to be able to test the whole object graph with and without this child object generated to ensure the Dao still works in both cases.

mnd999 avatar Feb 26 '15 13:02 mnd999

I think it might be the same concept as transient variables. It could be a good idea

On Thursday, February 26, 2015, Daniil Ivanov [email protected] wrote:

Could you please give an overview of the background. Why do you exclude attributes? They don't work, heavy to fill, maybe some other reason?

— Reply to this email directly or view it on GitHub https://github.com/mtedone/podam/issues/80#issuecomment-76172636.

mtedone avatar Feb 26 '15 14:02 mtedone

So PODAM produces a object graph with all nodes filled (or not?). Then instead of setting some child to null with something like this pojo.getNode().getAnotherNode().getOtherNode.setChild(null), you want PODAM to produce object graph with child attribute filled and another time without it?

daivanov avatar Feb 26 '15 16:02 daivanov

That's not what I meant. Podam should behave as is by default but if there was a way to instruct it not to fill only certain attributes on an exception basis (I think we have an Attribute...data structure that maybe we could leverage) it could be useful. But it should be users that would need to set that data structure according to their needs. Podam by default should fill in all attributes.

On Thursday, February 26, 2015, Daniil Ivanov [email protected] wrote:

So PODAM produces a object graph with all nodes filled (or not?). Then instead of setting some child to null with something like this pojo.getNode().getAnotherNode().getOtherNode.setChild(null), you want PODAM to produce object graph with child attribute filled and another time without it?

— Reply to this email directly or view it on GitHub https://github.com/mtedone/podam/issues/80#issuecomment-76216992.

mtedone avatar Feb 27 '15 02:02 mtedone

As use-case was stated (maybe it's more complex in reality?) setAttribute(null) does the trick. Doing it through DataProviderStrategy will method addExcludedAttibute(Class<?>, String attributeName); cause the twice larger code: two lines instead of one. Aditionally, one will be relying on very complicated solution (PODAM) instead of very simple and thus robust solution such as setter.

Also term object graph concerns me. Object graph typically means something like

class Node {
    String attribute;
    List<Node> children;
}

So if one tells PODAM to exclude attribute "attribute" all object graph's classes won't have it set. I don't think this is what is desired here.

daivanov avatar Feb 28 '15 09:02 daivanov

Fixed in PODAM 5.2.0.

daivanov avatar Mar 27 '15 20:03 daivanov

So how can I do that? Is there any examples for this? @daivanov

onacit avatar May 10 '25 11:05 onacit