We didn't thought about implementing DomainObjectContainer. We will explore 
that. Thanks for pointing that out.

We were experimenting now about implementing "common work" on abstract 
repositories (for all Domain Objects, for Multi-Tenant Entities, etc.) that are 
inherited for each .

This method was called only on tests for factory methods on those repositories, 
in order to avoid forgotten "persist()", initialization without all mandatory 
fields as defined by the Isis programming model, and other future validations.







El 14/05/2013, a las 12:47, Dan Haywood <[email protected]> 
escribió:

> On 14 May 2013 11:33, GESCONSULTOR - Óscar Bou <[email protected]>wrote:
> 
>> 
>> Your experiment is working nicely! :-))
>> 
>> We have defined an abstract base test class with the following validation
>> method, that it's called for testing any DomainObject creation. Is there
>> anything redundant? Any other generic validations we could perform specific
>> for Apache Isis? Any comment that it's not correct?
>> 
> 
> 
> the last line in the method...
> 
> domainObject = wrapped(domainObject);
> 
> isn't going to do anything; Java is pass-by-value, not pass-by-reference.
> 
> The rest looks ok, though I wonder whether you should require all your
> tests to make these assertions; you could probably test more generally
> elsewhere.
> 
> For example, you could register your own implementation of
> DomainObjectContainer, and then it could ensure that each domain Object's
> getId() is populated as a post-condition check.  You would therefore just
> need to unit test your DOC implementation in one place only.
> 
> You might also move the call to validate(...) into your DOC impl too.
> 
> Cheers
> Dan
> 
> 
> 
>> 
>> /**
>>         * @param communicationPathAssociatedWithNode
>>         */
>>        public void validateCommonAssertions(DomainObject domainObject) {
>> 
>>                // The Business Id. must be assigned.
>>                assertTrue(!domainObject.getId().isEmpty());
>> 
>>                // Test if the Domain Object has been persisted.
>> 
>> assertTrue(this.getDomainObjectContainer().isPersistent(domainObject));
>> 
>>                // Validation must be invoked over the original Domain
>> Object, not the
>>                // wrapped object (it would fail for setters of Services
>> injected to the
>>                // Domain Object).
>> 
>> assertTrue(this.getDomainObjectContainer().validate(domainObject) == null);
>> 
>>                // Node must be wrapped for the Apache Isis validators to
>> be launched.
>>                domainObject = wrapped(domainObject);
>> 
>>        }
>> 
>> Thanks,
>> 
>> Oscar
>> 
>> 

Reply via email to