@DirtiesContext
@Test
public void testSaveSaga() {
String identifier = UUID.randomUUID().toString();
MyTestSaga saga = new MyTestSaga(identifier);
mongoTemplate.sagaCollection().save(new SagaEntry(saga, new JavaSerializer()).asDBObject());
MyTestSaga loaded = (MyTestSaga) repository.load(identifier);
loaded.counter = 1;
repository.commit(loaded);
SagaEntry entry = new SagaEntry(mongoTemplate.sagaCollection().findOne(SagaEntry
.queryByIdentifier(identifier)));
MyTestSaga actualSaga = (MyTestSaga) entry.getSaga(new JavaSerializer());
assertNotSame(loaded, actualSaga);
assertEquals(1, actualSaga.counter);
}