package replicant;

import arez.Arez;
import arez.annotations.ArezComponent;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@SuppressWarnings( "SameParameterValue" )
@ArezComponent
abstract class TestConnector
  extends Connector
{
  private boolean _errorOnConnect;
  private boolean _errorOnDisconnect;

  static TestConnector create( @Nonnull final Class<?> systemType )
  {
    return create( systemType, ReplicantRuntime.create() );
  }

  static TestConnector create( @Nonnull final Class<?> systemType,
                               @Nonnull final ReplicantRuntime replicantRuntime )
  {
    return Arez.context().safeAction( () -> new Arez_TestConnector( systemType, replicantRuntime ) );
  }

  TestConnector( @Nonnull final Class<?> systemType, @Nonnull final ReplicantRuntime replicantRuntime )
  {
    super( systemType, replicantRuntime );
  }

  void setErrorOnConnect( final boolean errorOnConnect )
  {
    _errorOnConnect = errorOnConnect;
  }

  void setErrorOnDisconnect( final boolean errorOnDisconnect )
  {
    _errorOnDisconnect = errorOnDisconnect;
  }

  @Override
  protected void doConnect( @Nonnull final SafeProcedure action )
  {
    if ( _errorOnConnect )
    {
      throw new IllegalStateException();
    }
  }

  @Override
  protected void doDisconnect( @Nonnull final SafeProcedure action )
  {
    if ( _errorOnDisconnect )
    {
      throw new IllegalStateException();
    }
  }

  @Override
  public boolean isAreaOfInterestActionPending( @Nonnull final AreaOfInterestAction action,
                                                @Nonnull final ChannelAddress address,
                                                @Nullable final Object filter )
  {
    return false;
  }

  @Override
  public int indexOfPendingAreaOfInterestAction( @Nonnull final AreaOfInterestAction action,
                                                 @Nonnull final ChannelAddress address,
                                                 @Nullable final Object filter )
  {
    return 0;
  }

  @Override
  public void requestSubscribe( @Nonnull final ChannelAddress address, @Nullable final Object filterParameter )
  {
  }

  @Override
  public void requestSubscriptionUpdate( @Nonnull final ChannelAddress address, @Nullable final Object filterParameter )
  {
  }

  @Override
  public void requestUnsubscribe( @Nonnull final ChannelAddress address )
  {
  }
}

@@ -195,16 +195,23 @@
 mponent%0A
+public 
 abstract
@@ -325,24 +325,31 @@
 connect;%0A%0A  
+public 
 static TestC

Make class public so that it can be used elsewhere in project