@Test
public void testExecuteClientActionWhereObjectMadePersistent() {
final ObjectAdapter adapter = system.createTransientTestObject();
final DummyObjectData data = new DummyObjectData(adapter.getOid(), "none", true, new TestProxyVersion(1));
// restore the object on the server
mockery.checking(new Expectations() {
{
one(mockEncoder).decode(data, new KnownObjectsRequest());
will(returnValue(adapter));
one(mockEncoder).encodeIdentityData(adapter);
will(returnValue(null));
}
});
// return results
final ExecuteClientActionResponse results =
new ExecuteClientActionResponse(new ObjectData[0], new Version[0], new ObjectData[0]);
mockery.checking(new Expectations() {
{
one(mockEncoder).encodeClientActionResult(with(equalTo(new ReferenceData[1])),
with(equalTo(new Version[1])), with(equalTo(new ObjectData[0])));
will(returnValue(results));
}
});
// don't start xactn here, since within call.
final ExecuteClientActionRequest request =
new ExecuteClientActionRequest(session, new ReferenceData[] { data },
new int[] { ClientTransactionEvent.ADD });
final ExecuteClientActionResponse response = server.executeClientAction(request);
final ObjectAdapter object =
IsisContext.getPersistenceSession().loadObject(adapter.getOid(), adapter.getSpecification());
assertEquals(results, response);
assertEquals(adapter, object);
assertEquals(new TestProxyVersion(1), object.getVersion());
}