@Test void testSagaAssociationsVisibleInOtherThreadsBeforeSagaIsCommitted() throws Exception { String sagaId = "sagaId"; AssociationValue associationValue = new AssociationValue("test", "value"); Thread otherProcess = new Thread(() -> { UnitOfWork<?> unitOfWork = DefaultUnitOfWork.startAndGet(null); testSubject.createInstance(sagaId, Object::new).getAssociationValues().add(associationValue); CurrentUnitOfWork.clear(unitOfWork); }); otherProcess.start(); otherProcess.join(); assertEquals(singleton(sagaId), testSubject.find(associationValue)); }
@Override public Set<String> find(AssociationValue associationValue) { Set<String> sagasFound = new TreeSet<>(); sagasFound.addAll(managedSagas.values().stream() .filter(saga -> saga.getAssociationValues().contains(associationValue)) .map(Saga::getSagaIdentifier).collect(Collectors.toList())); sagasFound.addAll(sagaStore.findSagas(sagaType, associationValue)); return sagasFound; }
AnnotatedSagaRepository extends LockingSagaRepository<T> { @Override public Set<String> find(AssociationValue associationValue) { Set<String> sagasFound = new TreeSet<>(); sagasFound.addAll(managedSagas.values().stream() .filter(saga -> saga.getAssociationValues().contains(associationValue)) .map(Saga::getSagaIdentifier).collect(Collectors.toList())); sagasFound.addAll(sagaStore.findSagas(sagaType, associationValue)); return sagasFound; } }
AnnotatedSagaRepository extends LockingSagaRepository<T> { @Override public Set<String> find(AssociationValue associationValue) { Set<String> sagasFound = new TreeSet<>(); sagasFound.addAll(managedSagas.values().stream() .filter(saga -> saga.getAssociationValues().contains(associationValue)) .map(Saga::getSagaIdentifier).collect(Collectors.toList())); sagasFound.addAll(sagaStore.findSagas(sagaType, associationValue)); return sagasFound; } protected  AnnotatedSagaRepository(Builder<T> builder); }
AnnotatedSagaRepository extends LockingSagaRepository<T> { @Override public Set<String> find(AssociationValue associationValue) { Set<String> sagasFound = new TreeSet<>(); sagasFound.addAll(managedSagas.values().stream() .filter(saga -> saga.getAssociationValues().contains(associationValue)) .map(Saga::getSagaIdentifier).collect(Collectors.toList())); sagasFound.addAll(sagaStore.findSagas(sagaType, associationValue)); return sagasFound; } protected  AnnotatedSagaRepository(Builder<T> builder); static Builder<T> builder(); @Override AnnotatedSaga<T> doLoad(String sagaIdentifier); @Override AnnotatedSaga<T> doCreateInstance(String sagaIdentifier, Supplier<T> sagaFactory); @Override Set<String> find(AssociationValue associationValue); }
AnnotatedSagaRepository extends LockingSagaRepository<T> { @Override public Set<String> find(AssociationValue associationValue) { Set<String> sagasFound = new TreeSet<>(); sagasFound.addAll(managedSagas.values().stream() .filter(saga -> saga.getAssociationValues().contains(associationValue)) .map(Saga::getSagaIdentifier).collect(Collectors.toList())); sagasFound.addAll(sagaStore.findSagas(sagaType, associationValue)); return sagasFound; } protected  AnnotatedSagaRepository(Builder<T> builder); static Builder<T> builder(); @Override AnnotatedSaga<T> doLoad(String sagaIdentifier); @Override AnnotatedSaga<T> doCreateInstance(String sagaIdentifier, Supplier<T> sagaFactory); @Override Set<String> find(AssociationValue associationValue);  }