context.persistAndReturnSelf().using(foo).with("barField", "oneToManyField",
"oneToManySetField", "simpleValue", "simpleValues").fire(
new Receiver<SimpleFooProxy>() {
@Override
public void onSuccess(SimpleFooProxy response) {
RequestMessage requestMessage =
AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, RequestMessage.class,
transport.lastRequestPayload).as();
int seenFoos = 0;
int seenValues = 0;
for (OperationMessage operationMessage : requestMessage.getOperations()) {
if (fooTypeToken.equals(operationMessage.getTypeToken())) {
seenFoos++;
@SuppressWarnings("unchecked")
SimpleProxyId<?> id = (SimpleProxyId<?>) foo.stableId();
assertEquals(id.getServerId(), operationMessage.getServerId());
assertEquals(2, operationMessage.getPropertyMap().size());
assertTrue(operationMessage.getPropertyMap().containsKey("simpleValue"));
assertTrue(operationMessage.getPropertyMap().containsKey("simpleValues"));
} else if (valueTypeToken.equals(operationMessage.getTypeToken())) {
seenValues++;
AutoBean<SimpleValueProxy> bean = AutoBeanUtils.getAutoBean(created);
SimpleProxyId<?> id = BaseProxyCategory.stableId(bean);
assertEquals(id.getClientId(), operationMessage.getClientId());
assertEquals(AutoBeanUtils.getAllProperties(bean).keySet(),
operationMessage.getPropertyMap().keySet());
}
}
assertTrue(seenFoos > 0);
assertTrue(seenValues > 0);
// Persist without any change
factory.simpleFooRequest().persistAndReturnSelf().using(response).fire(
new Receiver<SimpleFooProxy>() {
@Override
public void onSuccess(SimpleFooProxy response) {
RequestMessage requestMessage =
AutoBeanCodex.decode(MessageFactoryHolder.FACTORY,
RequestMessage.class, transport.lastRequestPayload).as();
int seenFoos = 0;
for (OperationMessage operationMessage : requestMessage.getOperations()) {
if (fooTypeToken.equals(operationMessage.getTypeToken())) {
seenFoos++;
assertNull(operationMessage.getPropertyMap());
}
}