WOUnitTest for relations
WOUnitTest for relations
- Subject: WOUnitTest for relations
- From: Wolfram Stebel <email@hidden>
- Date: Sat, 13 May 2006 17:21:20 +0200
- Thread-topic: WOUnitTest for relations
Hi again,
i try to create an object hierarchy in the test editing context.
the factory methods below set up the relations as required.
then i delete the root object from the ec. I want to see, that the delete
rule "cascade" realy does a cascaded delete!
i thought, i could test the remaining content like shown below in method
assertEditingContextRemovedInserted.
After creation there are 3 objects in ec.insertedObjects.
After deletion of "aPerson" there are 2 still objects in ec.insertedObjects.
This means, cascaded deletes are applied not earlier than on saveChanges?
How could i test the cascaded delete correct?
TIA
Wolfram
--------------
Code sample that creates the hierarchy:
...
EOEditingContext ec = this.editingContext (); // from WOUTTestCase
CMandant m = CMandant.getMandantForAlias ( this.editingContext (),
NSProperties.getProperty ( "DefaultMandant", "pappnase" ) );
CPerson c = ( CPerson ) m.creator();
CPerson aPerson = CPerson.newPersonForMandantAndPerson ( ec, m, c );
CAddress theAddress =
CAddress.newAddressForMandantAndBusinesPartnerAndPerson ( ec, m, aPerson, c
);
CTelecom theTelecom =
CTelecom.newTelecomForMandantAndBusinesPartnerAndPerson ( ec, m, aPerson, c
);
// ec.saveChanges ();
ec.deleteObject ( aPerson );
// ec.saveChanges ();
// all objects should be deleted via delete rule
this.assertEditingContextRemovedInserted ();
...
public void assertEditingContextRemovedInserted ()
{
// test if content is unchanged, i.e. added eos and removed eos
->unchanged
NSSet inserted = new NSSet ( editingContext().insertedObjects () );
NSSet deleted = new NSSet ( editingContext().deletedObjects () );
NSSet remaining = inserted.setBySubtractingSet ( deleted );
try
{
assertTrue ( remaining.count () == 0 );
}
catch ( Exception exception )
{
fail ( "not all inserted objects are removed : " +
exception.getMessage() );
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden