@Test public void findSagaInstanceKey_sagaHasBothReadesrWithSuperclassOfMessageAndMessageClass_returnsDefinedKey() { final String keyValue = "theKeyValue"; KeyReader numberReader = FunctionKeyReader.create(Number.class, new KeyReadFunction<Number>() { @Override public String key(final Number number) { return "some key"; } }); KeyReader integerReader = FunctionKeyReader.create(Integer.class, new KeyReadFunction<Integer>() { @Override public String key(final Integer integer) { return keyValue; } }); when(testSaga.keyReaders()).thenReturn(Lists.newArrayList(numberReader, integerReader)); Object foundKey = sut.findSagaInstanceKey(Saga.class, SagaLookupContext.forMessage(Integer.valueOf(123))); assertThat("Expected returned key to match key value provided reader.", foundKey, equalTo((Object)keyValue)); }
@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);  }