@Test void testSetSchemaVersion() throws SQLException { Connection connection = mock(Connection.class); when(dataSource.getConnection()).thenReturn(connection); PreparedStatement preparedStatement = mock(PreparedStatement.class); when(connection.prepareStatement("UPDATE \"Version\" SET \"id\"=?")) .thenReturn(preparedStatement); molgenisVersionService.setSchemaVersion(30); verify(preparedStatement).setInt(1, 30); verify(preparedStatement).execute(); }
void setSchemaVersion(int version) { try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE \"Version\" SET \"id\"=?")) { statement.setInt(1, version); statement.execute(); } } catch (SQLException e) { throw new UncheckedSqlException(e); } }
MolgenisVersionService { void setSchemaVersion(int version) { try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE \"Version\" SET \"id\"=?")) { statement.setInt(1, version); statement.execute(); } } catch (SQLException e) { throw new UncheckedSqlException(e); } } }
MolgenisVersionService { void setSchemaVersion(int version) { try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE \"Version\" SET \"id\"=?")) { statement.setInt(1, version); statement.execute(); } } catch (SQLException e) { throw new UncheckedSqlException(e); } } MolgenisVersionService(DataSource dataSource); }
MolgenisVersionService { void setSchemaVersion(int version) { try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE \"Version\" SET \"id\"=?")) { statement.setInt(1, version); statement.execute(); } } catch (SQLException e) { throw new UncheckedSqlException(e); } } MolgenisVersionService(DataSource dataSource); @PostConstruct void init(); }
MolgenisVersionService { void setSchemaVersion(int version) { try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE \"Version\" SET \"id\"=?")) { statement.setInt(1, version); statement.execute(); } } catch (SQLException e) { throw new UncheckedSqlException(e); } } MolgenisVersionService(DataSource dataSource); @PostConstruct void init();  }