public void testAddAndLoadSaga_MultipleHitsByAssociationValue() {
String identifier1 = UUID.randomUUID().toString();
String identifier2 = UUID.randomUUID().toString();
MyTestSaga saga1 = new MyTestSaga(identifier1);
MyOtherTestSaga saga2 = new MyOtherTestSaga(identifier2);
saga1.registerAssociationValue(new AssociationValue("key", "value"));
saga2.registerAssociationValue(new AssociationValue("key", "value"));
repository.add(saga1);
repository.add(saga2);
// load saga1
Set<String> loaded1 = repository.find(MyTestSaga.class, new AssociationValue("key", "value"));
assertEquals(1, loaded1.size());
MyTestSaga loadedSaga1 = (MyTestSaga) repository.load(loaded1.iterator().next());
assertEquals(identifier1, loadedSaga1.getSagaIdentifier());
assertNotNull(mongoTemplate.sagaCollection().find(SagaEntry.queryByIdentifier(identifier1)));
// load saga2
Set<String> loaded2 = repository.find(MyOtherTestSaga.class, new AssociationValue("key", "value"));
assertEquals(1, loaded2.size());
MyOtherTestSaga loadedSaga2 = (MyOtherTestSaga) repository.load(loaded2.iterator().next());
assertEquals(identifier2, loadedSaga2.getSagaIdentifier());
assertNotNull(mongoTemplate.sagaCollection().find(SagaEntry.queryByIdentifier(identifier2)));
}