@Test public void shouldCreateSagaInstance() { when(sagaManager.create(sagaData1)).thenReturn(expectedSi1); when(sagaManager.create(sagaData2)).thenReturn(expectedSi2); SagaInstance si1 = sagaInstanceFactory.create(saga, sagaData1); assertEquals(expectedSi1, si1); verify(sagaManagerFactory, times(1)).make(saga); SagaInstance si2 = sagaInstanceFactory.create(saga, sagaData2); assertEquals(expectedSi2, si2); verify(sagaManagerFactory, times(1)).make(saga); }
public <SagaData> SagaInstance create(Saga<SagaData> saga, SagaData data) { SagaManager<SagaData> sagaManager = (SagaManager<SagaData>)sagaManagers.get(saga); if (sagaManager == null) throw new RuntimeException(("No SagaManager for " + saga)); return sagaManager.create(data); }
SagaInstanceFactory { public <SagaData> SagaInstance create(Saga<SagaData> saga, SagaData data) { SagaManager<SagaData> sagaManager = (SagaManager<SagaData>)sagaManagers.get(saga); if (sagaManager == null) throw new RuntimeException(("No SagaManager for " + saga)); return sagaManager.create(data); } }
SagaInstanceFactory { public <SagaData> SagaInstance create(Saga<SagaData> saga, SagaData data) { SagaManager<SagaData> sagaManager = (SagaManager<SagaData>)sagaManagers.get(saga); if (sagaManager == null) throw new RuntimeException(("No SagaManager for " + saga)); return sagaManager.create(data); } SagaInstanceFactory(SagaManagerFactory sagaManagerFactory, Collection<Saga<?>> sagas); }
SagaInstanceFactory { public <SagaData> SagaInstance create(Saga<SagaData> saga, SagaData data) { SagaManager<SagaData> sagaManager = (SagaManager<SagaData>)sagaManagers.get(saga); if (sagaManager == null) throw new RuntimeException(("No SagaManager for " + saga)); return sagaManager.create(data); } SagaInstanceFactory(SagaManagerFactory sagaManagerFactory, Collection<Saga<?>> sagas); SagaInstance create(Saga<SagaData> saga, SagaData data); }
SagaInstanceFactory { public <SagaData> SagaInstance create(Saga<SagaData> saga, SagaData data) { SagaManager<SagaData> sagaManager = (SagaManager<SagaData>)sagaManagers.get(saga); if (sagaManager == null) throw new RuntimeException(("No SagaManager for " + saga)); return sagaManager.create(data); } SagaInstanceFactory(SagaManagerFactory sagaManagerFactory, Collection<Saga<?>> sagas); SagaInstance create(Saga<SagaData> saga, SagaData data);  }