@Test
public void persist_then_update_using_persistentAdapterFor() throws Exception {
iswf.beginTran();
UnidirReferencedEntity referencedEntity1 = referencedRepo.newEntity();
referencedEntity1.setName("Referenced 1");
UnidirReferencedEntity referencedEntity2 = referencedRepo.newEntity();
referencedEntity2.setName("Referenced 2");
UnidirReferencingEntity referencingEntity1 = referencingRepo.newEntity();
referencingEntity1.setName("Referencing 1");
referencingEntity1.setReferenced(referencedEntity1);
UnidirReferencingEntity referencingEntity2 = referencingRepo.newEntity();
referencingEntity2.setName("Referencing 2");
referencingEntity2.setReferenced(referencedEntity1);
UnidirReferencingEntity referencingEntity3 = referencingRepo.newEntity();
referencingEntity3.setName("Referencing 3");
referencingEntity3.setReferenced(referencedEntity2);
iswf.commitTran();
TypedOid referencingOid2 = (TypedOid) iswf.adapterFor(referencingEntity2).getOid();
TypedOid referencedOid1 = (TypedOid) iswf.adapterFor(referencedEntity1).getOid();
TypedOid referencedOid2 = (TypedOid) iswf.adapterFor(referencedEntity2).getOid();
// when ...
iswf.bounceSystem();
iswf.beginTran();
ObjectAdapter referencingAdapter2 = iswf.getAdapterManager().adapterFor(referencingOid2);
referencingEntity2 = (UnidirReferencingEntity) referencingAdapter2.getObject();
UnidirReferencedEntity referenced = referencingEntity2.getReferenced();
ObjectAdapter referencedAdapter1 = iswf.getAdapterManager().adapterFor(referencedOid1);
assertThat(referenced, is(referencedAdapter1.getObject()));
// ...switch to refer to other