StructuredAggregateRoot aggregateRoot = new StructuredAggregateRoot();
aggregateRoot.invoke();
assertEquals(2, aggregateRoot.getInvocations());
assertEquals(2, aggregateRoot.getEntity().getInvocations());
aggregateRoot.commitEvents();
XStreamSerializer serializer = new XStreamSerializer();
SerializedObject<byte[]> serialized = serializer.serialize(aggregateRoot, byte[].class);
StructuredAggregateRoot deserializedAggregate = (StructuredAggregateRoot) serializer.deserialize(serialized);
deserializedAggregate.invoke();
assertEquals(3, deserializedAggregate.getInvocations());
assertEquals(3, deserializedAggregate.getEntity().getInvocations());
}