@Test public void should_fail_when_the_lock_cannot_be_constrained() throws SQLException { Statement constraintStatement = mock(Statement.class); when(connection.createStatement()).thenReturn(constraintStatement); ResultSet resultSet = mock(ResultSet.class); when(resultSet.next()).thenReturn(true, false); when(resultSet.getBoolean("result")).thenReturn(false); when(constraintStatement.executeQuery(anyString())).thenReturn(resultSet); when(constraintStatement.execute(anyString())).thenThrow(SQLException.class); assertThatThrownBy(() -> lock.acquire(connection)).isInstanceOf(LiquigraphLockException.class); }
void acquire(Connection connection) { if (addConnection(connection)) { LOGGER.debug("Acquiring lock {} on database", uuid); addShutdownHook(); ensureLockUniqueness(connection); tryWriteLock(connection); } }
LiquigraphLock { void acquire(Connection connection) { if (addConnection(connection)) { LOGGER.debug("Acquiring lock {} on database", uuid); addShutdownHook(); ensureLockUniqueness(connection); tryWriteLock(connection); } } }
LiquigraphLock { void acquire(Connection connection) { if (addConnection(connection)) { LOGGER.debug("Acquiring lock {} on database", uuid); addShutdownHook(); ensureLockUniqueness(connection); tryWriteLock(connection); } } LiquigraphLock(Supplier<Connection> connection); }
LiquigraphLock { void acquire(Connection connection) { if (addConnection(connection)) { LOGGER.debug("Acquiring lock {} on database", uuid); addShutdownHook(); ensureLockUniqueness(connection); tryWriteLock(connection); } } LiquigraphLock(Supplier<Connection> connection);  }
LiquigraphLock { void acquire(Connection connection) { if (addConnection(connection)) { LOGGER.debug("Acquiring lock {} on database", uuid); addShutdownHook(); ensureLockUniqueness(connection); tryWriteLock(connection); } } LiquigraphLock(Supplier<Connection> connection);   }