new FastBlobWriter(stateEngine2, 0).writeDelta(new DataOutputStream(serializedDeltaState2));
/// now we need to deserialize. Deserialize first the snapshot produced by server 1, then the delta produced by server 2 (with different serializers)
new FastBlobReader(stateEngine1).readSnapshot(new ByteArrayInputStream(serializedSnapshotState1.toByteArray()));
new FastBlobReader(stateEngine1).readDelta(new ByteArrayInputStream(serializedDeltaState2.toByteArray()));
/// get the type As
FastBlobTypeDeserializationState<TypeAState1> typeAs = stateEngine1.getTypeDeserializationState("TypeA");
/// here we use some implicit knowledge about how the state engine works to verify the functionality...
/// A's serializer changed, so the ordinals for the new objects should not overlap with any of the original
/// ordinals (0, 1, 2).
Assert.assertEquals(1, typeAs.get(3).getA1());
Assert.assertEquals(2, typeAs.get(4).getA1());
Assert.assertEquals(4, typeAs.get(5).getA1());
FastBlobTypeDeserializationState<TypeB> typeBs = stateEngine1.getTypeDeserializationState("TypeB");
/// B's serializer did not change. The ordinals for objects which exist across states will be reused (0, 2)
/// one new ordinal will be added for the changed object (3)
Assert.assertEquals(1, typeBs.get(0).getB1());
Assert.assertEquals(3, typeBs.get(2).getB1());
Assert.assertEquals(9, typeBs.get(3).getB1());
FastBlobStateEngine removedTypeBStateEngine = new FastBlobStateEngine(removedTypeBFactory());
new FastBlobReader(removedTypeBStateEngine).readSnapshot(new ByteArrayInputStream(serializedSnapshotState1.toByteArray()));
new FastBlobReader(removedTypeBStateEngine).readDelta(new ByteArrayInputStream(serializedDeltaState2.toByteArray()));
/// get the type As
FastBlobTypeDeserializationState<TypeAState2> typeA2s = removedTypeBStateEngine.getTypeDeserializationState("TypeA");