@Test(expected = IllegalStateException.class) public void connectToStorageAgain() { final SharedShellState state = new SharedShellState(); final AccumuloConnectionDetails connectionDetails = mock(AccumuloConnectionDetails.class); final RyaClient connectedCommands = mock(RyaClient.class); state.connectedToAccumulo(connectionDetails, connectedCommands); state.connectedToAccumulo(connectionDetails, connectedCommands); }
public void connectedToAccumulo( final AccumuloConnectionDetails connectionDetails, final RyaClient connectedCommands) throws IllegalStateException { requireNonNull(connectionDetails); requireNonNull(connectedCommands); lock.lock(); try { if(shellState.getConnectionState() != ConnectionState.DISCONNECTED) { throw new IllegalStateException("You must clear the old connection state before you may set a new connection state."); } shellState = ShellState.builder() .setConnectionState( ConnectionState.CONNECTED_TO_STORAGE ) .setAccumuloDetails( connectionDetails ) .setConnectedCommands( connectedCommands ) .build(); } finally { lock.unlock(); } }
SharedShellState { public void connectedToAccumulo( final AccumuloConnectionDetails connectionDetails, final RyaClient connectedCommands) throws IllegalStateException { requireNonNull(connectionDetails); requireNonNull(connectedCommands); lock.lock(); try { if(shellState.getConnectionState() != ConnectionState.DISCONNECTED) { throw new IllegalStateException("You must clear the old connection state before you may set a new connection state."); } shellState = ShellState.builder() .setConnectionState( ConnectionState.CONNECTED_TO_STORAGE ) .setAccumuloDetails( connectionDetails ) .setConnectedCommands( connectedCommands ) .build(); } finally { lock.unlock(); } } }
SharedShellState { public void connectedToAccumulo( final AccumuloConnectionDetails connectionDetails, final RyaClient connectedCommands) throws IllegalStateException { requireNonNull(connectionDetails); requireNonNull(connectedCommands); lock.lock(); try { if(shellState.getConnectionState() != ConnectionState.DISCONNECTED) { throw new IllegalStateException("You must clear the old connection state before you may set a new connection state."); } shellState = ShellState.builder() .setConnectionState( ConnectionState.CONNECTED_TO_STORAGE ) .setAccumuloDetails( connectionDetails ) .setConnectedCommands( connectedCommands ) .build(); } finally { lock.unlock(); } }  }
SharedShellState { public void connectedToAccumulo( final AccumuloConnectionDetails connectionDetails, final RyaClient connectedCommands) throws IllegalStateException { requireNonNull(connectionDetails); requireNonNull(connectedCommands); lock.lock(); try { if(shellState.getConnectionState() != ConnectionState.DISCONNECTED) { throw new IllegalStateException("You must clear the old connection state before you may set a new connection state."); } shellState = ShellState.builder() .setConnectionState( ConnectionState.CONNECTED_TO_STORAGE ) .setAccumuloDetails( connectionDetails ) .setConnectedCommands( connectedCommands ) .build(); } finally { lock.unlock(); } }  ShellState getShellState(); void connectedToAccumulo(
            final AccumuloConnectionDetails connectionDetails,
            final RyaClient connectedCommands); void connectedToMongo(
            final MongoConnectionDetails connectionDetails,
            final RyaClient connectedCommands); void connectedToInstance(final String instanceName); void connectedToRyaStreams(
            final RyaStreamsClient ryaStreamsCommands); void disconnected(); }
SharedShellState { public void connectedToAccumulo( final AccumuloConnectionDetails connectionDetails, final RyaClient connectedCommands) throws IllegalStateException { requireNonNull(connectionDetails); requireNonNull(connectedCommands); lock.lock(); try { if(shellState.getConnectionState() != ConnectionState.DISCONNECTED) { throw new IllegalStateException("You must clear the old connection state before you may set a new connection state."); } shellState = ShellState.builder() .setConnectionState( ConnectionState.CONNECTED_TO_STORAGE ) .setAccumuloDetails( connectionDetails ) .setConnectedCommands( connectedCommands ) .build(); } finally { lock.unlock(); } }  ShellState getShellState(); void connectedToAccumulo(
            final AccumuloConnectionDetails connectionDetails,
            final RyaClient connectedCommands); void connectedToMongo(
            final MongoConnectionDetails connectionDetails,
            final RyaClient connectedCommands); void connectedToInstance(final String instanceName); void connectedToRyaStreams(
            final RyaStreamsClient ryaStreamsCommands); void disconnected();  }