Re: WOUnitTest for relations
Re: WOUnitTest for relations
- Subject: Re: WOUnitTest for relations
- From: Christian Pekeler <email@hidden>
- Date: Sat, 13 May 2006 10:00:57 -0600
public void testPersonDeletesManadant() {
Person person = (Person)mockEditingContext
().createSavedObject("Person");
CMandant mandant = (CMandant)mockEditingContext
().createSavedObject("CMandant");
person.addObjectToBothSidesOfRelationshipWithKey(mandant,
"mandanten");
mockEditingContext().deleteObject(person);
mockEditingContext().saveChanges();
assertFalse(mockEditingContext().registeredObjects
().containsObject(person));
assertFalse(mockEditingContext().registeredObjects
().containsObject(mandant));
}
Christian
On May 13, 2006, at 9:21, Wolfram Stebel wrote:
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:
40pekeler.org
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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