@Test public void findSagaInstanceKey_sagaCalledWithContext_contextUsedAsReaderParameter() { LookupContext originalContext = SagaLookupContext.forMessage("my input event message"); final LookupContext[] providedReaderContext = new LookupContext[1]; KeyReader reader = KeyReaders.forMessage(String.class, new ContextKeyExtractFunction<String, String>() { @Nullable @Override public String key(final String message, final LookupContext context) { providedReaderContext[0] = context; return null; } }); when(testSaga.keyReaders()).thenReturn(Lists.newArrayList(reader)); sut.findSagaInstanceKey(Saga.class, originalContext); assertThat("Expected context in key reader to be the same as the original.", providedReaderContext[0], sameInstance(originalContext)); }
@Override public Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context) { Object keyValue = null; KeyReader reader = tryGetKeyReader(sagaClazz, context.message()); if (reader != null) { keyValue = reader.readKey(context.message(), context); } return keyValue; }
SagaKeyReaderExtractor implements KeyExtractor { @Override public Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context) { Object keyValue = null; KeyReader reader = tryGetKeyReader(sagaClazz, context.message()); if (reader != null) { keyValue = reader.readKey(context.message(), context); } return keyValue; } }
SagaKeyReaderExtractor implements KeyExtractor { @Override public Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context) { Object keyValue = null; KeyReader reader = tryGetKeyReader(sagaClazz, context.message()); if (reader != null) { keyValue = reader.readKey(context.message(), context); } return keyValue; } @Inject  SagaKeyReaderExtractor(final SagaProviderFactory sagaProviderFactory); }
SagaKeyReaderExtractor implements KeyExtractor { @Override public Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context) { Object keyValue = null; KeyReader reader = tryGetKeyReader(sagaClazz, context.message()); if (reader != null) { keyValue = reader.readKey(context.message(), context); } return keyValue; } @Inject  SagaKeyReaderExtractor(final SagaProviderFactory sagaProviderFactory); @Override Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context); }
SagaKeyReaderExtractor implements KeyExtractor { @Override public Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context) { Object keyValue = null; KeyReader reader = tryGetKeyReader(sagaClazz, context.message()); if (reader != null) { keyValue = reader.readKey(context.message(), context); } return keyValue; } @Inject  SagaKeyReaderExtractor(final SagaProviderFactory sagaProviderFactory); @Override Object findSagaInstanceKey(final Class<? extends Saga> sagaClazz, final LookupContext context);  }