@Test(expected = IllegalArgumentException.class) public void testCheckInNotCheckedOut() { librarian.checkIn(mock(CachedConnection.class)); }
@Override public void checkIn(final CachedConnection connection) { if (!checkedOut.containsKey(connection)) { throw new IllegalArgumentException( "The given connection is either unknown to this librarian or has already been checked in."); } final String cacheKey = checkedOut.get(connection); final Set<Connection> connections = cast(cache.get(cacheKey).getObjectValue()); checkedOut.remove(connection); connections.add(connection); }
CachedLibrarian implements ConnectionLibrarian<CachedConnection> { @Override public void checkIn(final CachedConnection connection) { if (!checkedOut.containsKey(connection)) { throw new IllegalArgumentException( "The given connection is either unknown to this librarian or has already been checked in."); } final String cacheKey = checkedOut.get(connection); final Set<Connection> connections = cast(cache.get(cacheKey).getObjectValue()); checkedOut.remove(connection); connections.add(connection); } }
CachedLibrarian implements ConnectionLibrarian<CachedConnection> { @Override public void checkIn(final CachedConnection connection) { if (!checkedOut.containsKey(connection)) { throw new IllegalArgumentException( "The given connection is either unknown to this librarian or has already been checked in."); } final String cacheKey = checkedOut.get(connection); final Set<Connection> connections = cast(cache.get(cacheKey).getObjectValue()); checkedOut.remove(connection); connections.add(connection); } CachedLibrarian(final IdentifierGenerator idGenerator, final Cache cache); }
CachedLibrarian implements ConnectionLibrarian<CachedConnection> { @Override public void checkIn(final CachedConnection connection) { if (!checkedOut.containsKey(connection)) { throw new IllegalArgumentException( "The given connection is either unknown to this librarian or has already been checked in."); } final String cacheKey = checkedOut.get(connection); final Set<Connection> connections = cast(cache.get(cacheKey).getObjectValue()); checkedOut.remove(connection); connections.add(connection); } CachedLibrarian(final IdentifierGenerator idGenerator, final Cache cache); @Override void checkIn(final CachedConnection connection); @Override CachedConnection checkOut(final String username, final String password, final URI serverAddress); @Override CachedConnection checkOut(final String username, final String salt, final URI privateKeyLocation,
            final URI serverAddress); }
CachedLibrarian implements ConnectionLibrarian<CachedConnection> { @Override public void checkIn(final CachedConnection connection) { if (!checkedOut.containsKey(connection)) { throw new IllegalArgumentException( "The given connection is either unknown to this librarian or has already been checked in."); } final String cacheKey = checkedOut.get(connection); final Set<Connection> connections = cast(cache.get(cacheKey).getObjectValue()); checkedOut.remove(connection); connections.add(connection); } CachedLibrarian(final IdentifierGenerator idGenerator, final Cache cache); @Override void checkIn(final CachedConnection connection); @Override CachedConnection checkOut(final String username, final String password, final URI serverAddress); @Override CachedConnection checkOut(final String username, final String salt, final URI privateKeyLocation,
            final URI serverAddress);  }