### Question:
RobustHazelcastWrapper { synchronized void perform( Consumer<HazelcastInstance> operation ) throws HazelcastInstanceNotActiveException { HazelcastInstance hzInstance = tryEnsureConnection(); try { operation.accept( hzInstance ); } catch ( com.hazelcast.core.HazelcastInstanceNotActiveException e ) { invalidateConnection(); throw new HazelcastInstanceNotActiveException( e ); } } RobustHazelcastWrapper( HazelcastConnector connector );   }### Answer:
@Test public void shouldReconnectIfHazelcastConnectionInvalidated() throws Exception { HazelcastConnector connector = mock( HazelcastConnector.class ); HazelcastInstance hzInstance = mock( HazelcastInstance.class ); when( connector.connectToHazelcast() ).thenReturn( hzInstance ); RobustHazelcastWrapper hzWrapper = new RobustHazelcastWrapper( connector ); hzWrapper.perform( hz -> { } ); verify( connector, times( 1 ) ).connectToHazelcast(); try { hzWrapper.perform( hz -> { throw new com.hazelcast.core.HazelcastInstanceNotActiveException(); } ); fail(); } catch ( HazelcastInstanceNotActiveException e ) { } hzWrapper.perform( hz -> { } ); hzWrapper.perform( hz -> { } ); verify( connector, times( 2 ) ).connectToHazelcast(); }