### Question:
DelegateInvocationHandler implements InvocationHandler { @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { if ( delegate == null ) { throw new StateChangedTransactionFailureException( "This transaction made assumptions about the instance it is executing " + "on that no longer hold true. This normally happens when a transaction " + "expects the instance it is executing on to be in some specific cluster role" + "(such as 'master' or 'slave') and the instance " + "changing state while the transaction is executing. Simply retry your " + "transaction and you should see a successful outcome." ); } return proxyInvoke( delegate, method, args ); } DelegateInvocationHandler( final Class<T> interfaceClass ); T setDelegate( T delegate ); @Override Object invoke( Object proxy, Method method, Object[] args ); T cement(); @Override String toString();  }### Answer:
@Test public void throwsWhenDelegateIsNotSet() { DelegateInvocationHandler<Value> handler = newDelegateInvocationHandler(); try { handler.invoke( new Object(), Value.class.getDeclaredMethod( "get" ), new Object[0] ); fail( "Exception expected" ); } catch ( Throwable t ) { assertThat( t, instanceOf( TransactionFailureException.class ) ); } }