ConstantChainChoiceStrategy implements IChainChoiceStrategy { @Override public Object chooseChain(IMessageProcessor messageProcessor) throws ChainChoiceException { try { Object name = messageProcessor.getSequence().getCurrentReceiverArguments().getValue(chainIdFieldName); return IOC.resolve(Keys.getOrAdd("chain_id_from_map_name"), name); } catch (Exception e) { throw new ChainChoiceException("Exception occurred reading chain id for current step.", e); } } ConstantChainChoiceStrategy(); @Override Object chooseChain(IMessageProcessor messageProcessor);  }
@Test public void Should_chooseChainUsingIdentifierInCurrentStepArguments() throws Exception { IChainChoiceStrategy strategy = new ConstantChainChoiceStrategy(); assertSame(id, strategy.chooseChain(messageProcessorMock)); }
@Test(expected = ChainChoiceException.class) public void Should_wrapExceptionThrownByIOC() throws Exception { when(chainIdStrategy.resolve(any())).thenThrow(ResolveDependencyStrategyException.class); IChainChoiceStrategy strategy = new ConstantChainChoiceStrategy(); strategy.chooseChain(messageProcessorMock); }