* to Entity Persist
*/
public void testPersistNewEntityNewRelation() {
delayTestFinish(DELAY_TEST_FINISH);
SimpleFooRequest context = simpleFooRequest();
SimpleFooProxy newFoo = context.create(SimpleFooProxy.class);
final Request<SimpleFooProxy> fooReq = context.persistAndReturnSelf().using(newFoo);
newFoo = context.edit(newFoo);
newFoo.setUserName("Ray");
SimpleBarRequest context2 = simpleBarRequest();
SimpleBarProxy newBar = context2.create(SimpleBarProxy.class);
final Request<SimpleBarProxy> barReq = context2.persistAndReturnSelf().using(newBar);
newBar = context2.edit(newBar);
newBar.setUserName("Amit");
fooReq.fire(new Receiver<SimpleFooProxy>() {
@Override
public void onSuccess(final SimpleFooProxy response) {
final SimpleFooProxy persistedFoo = checkSerialization(response);
barReq.fire(new Receiver<SimpleBarProxy>() {
@Override
public void onSuccess(SimpleBarProxy response) {
final SimpleBarProxy persistedBar = checkSerialization(response);
assertEquals("Ray", persistedFoo.getUserName());
SimpleFooRequest context = simpleFooRequest();
final Request<Void> fooReq2 = context.persist().using(persistedFoo);
SimpleFooProxy editablePersistedFoo = context.edit(persistedFoo);
editablePersistedFoo.setBarField(persistedBar);
fooReq2.fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
req.simpleFooRequest().findSimpleFooById(persistedFoo.getId()).with(
"barField.userName").fire(new Receiver<SimpleFooProxy>() {