ConfigurableTokenLifecycleStrategy implements TokenLifecycleStrategy { @Override public void afterTokenCallError(TokenLifecycleStrategyCallback callback, TokenWrapper tokenWrapper, Exception e) { if(addErrorOnTokenCallError) { addTokenError(callback, "Error while calling agent", e); } } ConfigurableTokenLifecycleStrategy(boolean addErrorOnTokenReleaseError,
			boolean addErrorOnTokenReservationError, boolean addErrorOnTokenCallError, boolean addErrorOnAgentError,
			Set<AgentErrorCode> concernedAgentErrors); boolean isAddErrorOnTokenReleaseError(); void setAddErrorOnTokenReleaseError(boolean addErrorOnTokenReleaseError); boolean isAddErrorOnTokenReservationError(); void setAddErrorOnTokenReservationError(boolean addErrorOnTokenReservationError); boolean isAddErrorOnTokenCallError(); void setAddErrorOnTokenCallError(boolean addErrorOnTokenCallError); boolean isAddErrorOnAgentError(); void setAddErrorOnAgentError(boolean addErrorOnAgentError); Set<AgentErrorCode> getConcernedAgentErrors(); void setConcernedAgentErrors(Set<AgentErrorCode> concernedAgentErrors); @Override void afterTokenReleaseError(TokenLifecycleStrategyCallback callback, TokenWrapper tokenWrapper,
			Exception e); @Override void afterTokenReservationError(TokenLifecycleStrategyCallback callback, TokenWrapper tokenWrapper,
			Exception e); @Override void afterTokenCallError(TokenLifecycleStrategyCallback callback, TokenWrapper tokenWrapper, Exception e); @Override void afterTokenCall(TokenLifecycleStrategyCallback callback, TokenWrapper tokenWrapper,
			OutputMessage outputMessage); boolean registerTokenErrorListener(TokenErrorListener e);  }
@Test public void testAddErrorOnTokenCallErrorTrue() { AtomicBoolean callBackCalled = new AtomicBoolean(false); TokenLifecycleStrategy s = new ConfigurableTokenLifecycleStrategy(true, true, true, true, null); s.afterTokenCallError(new TokenLifecycleStrategyCallback(null, null) { @Override public void addTokenError(String errorMessage, Exception exception) { Assert.assertEquals("my message", exception.getMessage()); callBackCalled.set(true); } }, new TokenWrapper(), new Exception("my message")); Assert.assertTrue(callBackCalled.get()); }
@Test public void testAddErrorOnTokenCallErrorFalse() { AtomicBoolean callBackCalled = new AtomicBoolean(false); TokenLifecycleStrategy s = new ConfigurableTokenLifecycleStrategy(true, true, false, true, null); s.afterTokenCallError(new TokenLifecycleStrategyCallback(null, null) { @Override public void addTokenError(String errorMessage, Exception exception) { Assert.assertEquals("my message", exception.getMessage()); callBackCalled.set(true); } }, new TokenWrapper(), new Exception("my message")); Assert.assertFalse(callBackCalled.get()); }