### Question:
Monitor { public T waitUntilEqAndSet( T desiredValue, T newValue ) throws InterruptedException, TimeoutException { return waitUntilEqAndSet( desiredValue, 0, newValue ); } Monitor( String description, T initialValue );  Monitor( String description ); String getDescription(); @Override String toString(); T get(); synchronized T set( T newValue ); T waitUntilEqAndSet( T desiredValue, T newValue ); synchronized T waitUntilEqAndSet( T desiredValue, int maxDelay,
		T newValue ); void waitUntilEq( T desiredValue ); synchronized void waitUntilEq( T desiredValue, int maxDelay ); T waitUntilNotEqAndSet( T undesiredValue, T newValue ); synchronized T waitUntilNotEqAndSet( T undesiredValue, int maxDelay,
		T newValue ); T waitUntilNotEq( T undesiredValue ); synchronized T waitUntilNotEq( T undesiredValue, int maxDelay );  }### Answer:
@Test public void waitUntilEqAndSet1() throws Exception { Monitor<Integer> m = new Monitor<Integer>( "a", null ); assertEquals( null, m.waitUntilEqAndSet( null, 1 ) ); assertEquals( 1, m.waitUntilEqAndSet( 1, 2 ) ); assertEquals( 2, m.waitUntilEqAndSet( 2, null ) ); assertEquals( null, m.waitUntilEqAndSet( null, null ) ); assertEquals( null, m.waitUntilEqAndSet( null, 0, 1 ) ); assertEquals( 1, m.waitUntilEqAndSet( 1, 0, 2 ) ); assertEquals( 2, m.waitUntilEqAndSet( 2, 0, null ) ); assertEquals( null, m.waitUntilEqAndSet( null, 0, null ) ); }